GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/navierstokes/mass/1pnc/model.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 0 0 -%
Branches: 0 0 -%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup NavierStokesModel
10 *
11 * \brief A single-phase, isothermal Navier-Stokes model
12 *
13 * This model implements a single-phase, isothermal Navier-Stokes model, solving the <B> momentum balance equation </B>
14 * \f[
15 \frac{\partial (\varrho \textbf{v})}{\partial t} + \nabla \cdot (\varrho \textbf{v} \textbf{v}^{\text{T}}) = \nabla \cdot (\mu (\nabla \textbf{v} + \nabla \textbf{v}^{\text{T}}))
16 - \nabla p + \varrho \textbf{g} - \textbf{f}
17 * \f]
18 * By setting the runtime parameter <code>Problem.EnableInertiaTerms</code> to <code>false</code> the Stokes
19 * equation can be solved. In this case the term
20 * \f[
21 * \nabla \cdot (\varrho \textbf{v} \textbf{v}^{\text{T}})
22 * \f]
23 * is neglected.
24 *
25 * The <B> mass balance equation </B>
26 * \f[
27 \frac{\partial \varrho}{\partial t} + \nabla \cdot (\varrho \textbf{v}) - q = 0
28 * \f]
29 *
30 * closes the system.
31 *
32 *
33 * So far, only the staggered grid spatial discretization (for structured grids) is available.
34 */
35
36 #ifndef DUMUX_NAVIERSTOKES_1PNC_MODEL_HH
37 #define DUMUX_NAVIERSTOKES_1PNC_MODEL_HH
38
39 #include <dumux/common/properties.hh>
40 #include <dumux/common/properties/model.hh>
41
42 #include <dumux/freeflow/spatialparams.hh>
43 #include <dumux/freeflow/turbulencemodel.hh>
44 #include "dumux/freeflow/navierstokes/iofields.hh"
45 #include <dumux/freeflow/navierstokes/energy/model.hh>
46 #include <dumux/freeflow/navierstokes/scalarfluxvariablescachefiller.hh>
47 #include <dumux/material/fluidstates/compositional.hh>
48
49 #include <dumux/flux/fickslaw.hh>
50 #include <dumux/flux/fourierslaw.hh>
51
52 #include "localresidual.hh"
53 #include "volumevariables.hh"
54 #include "fluxvariables.hh"
55 #include "indices.hh"
56 #include "iofields.hh"
57
58 namespace Dumux {
59
60 /*!
61 * \ingroup NavierStokesModel
62 * \brief Traits for the Navier-Stokes model
63 *
64 * \tparam dimension The dimension of the problem
65 */
66 template<int nComp, bool useM, int repCompEqIdx = nComp>
67 struct NavierStokesMassOnePNCModelTraits
68 {
69 //! There are as many momentum balance equations as dimensions
70 //! and one mass balance equation.
71 static constexpr int numEq() { return nComp; }
72
73 //! The number of phases is 1
74 static constexpr int numFluidPhases() { return 1; }
75
76 //! The number of components is 1
77 static constexpr int numFluidComponents() { return nComp; }
78
79 //! Use moles or not
80 static constexpr bool useMoles() { return useM; }
81
82 // Enable advection
83 static constexpr bool enableAdvection() { return true; }
84
85 //! The model is isothermal
86 static constexpr bool enableEnergyBalance() { return false; }
87
88 //! The one-phase model has no molecular diffusion
89 static constexpr bool enableMolecularDiffusion() { return true; }
90
91 //! Index of of a component balance eq. to be replaced by a total mass/mole balance
92 static constexpr int replaceCompEqIdx() { return repCompEqIdx; }
93
94 //! The model does not include a turbulence model
95 static constexpr bool usesTurbulenceModel() { return false; }
96
97 //! return the type of turbulence model used
98 static constexpr auto turbulenceModel()
99 { return TurbulenceModel::none; }
100
101 //! the indices
102 using Indices = NavierStokesMassOnePIndices;
103 };
104
105 /*!
106 * \ingroup NavierStokesModel
107 * \brief Traits class for the volume variables of the Navier-Stokes model.
108 *
109 * \tparam PV The type used for primary variables
110 * \tparam FSY The fluid system type
111 * \tparam FST The fluid state type
112 * \tparam MT The model traits
113 */
114 template<class PV,
115 class FSY,
116 class FST,
117 class MT>
118 struct NavierStokesMassOnePNCVolumeVariablesTraits
119 {
120 using PrimaryVariables = PV;
121 using FluidSystem = FSY;
122 using FluidState = FST;
123 using ModelTraits = MT;
124 };
125
126 // \{
127 ///////////////////////////////////////////////////////////////////////////
128 // properties for the single-phase Navier-Stokes model
129 ///////////////////////////////////////////////////////////////////////////
130 namespace Properties {
131
132 //////////////////////////////////////////////////////////////////
133 // Type tags
134 //////////////////////////////////////////////////////////////////
135
136 // Create new type tags
137 namespace TTag {
138 //! The type tag for the single-phase, isothermal Navier-Stokes model
139 struct NavierStokesMassOnePNC{ using InheritsFrom = std::tuple<ModelProperties>; };
140 struct NavierStokesMassOnePNCNI{ using InheritsFrom = std::tuple<NavierStokesMassOnePNC>; };
141
142 }
143
144 //! The base model traits. Per default, we use the number of components of the fluid system.
145 template<class TypeTag>
146 struct BaseModelTraits<TypeTag, TTag::NavierStokesMassOnePNC>
147 {
148 private:
149 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
150 public:
151 using type = NavierStokesMassOnePNCModelTraits<FluidSystem::numComponents, getPropValue<TypeTag, Properties::UseMoles>(), getPropValue<TypeTag, Properties::ReplaceCompEqIdx>()>;
152 };
153
154
155 //!< states some specifics of the Navier-Stokes model
156 template<class TypeTag>
157 struct ModelTraits<TypeTag, TTag::NavierStokesMassOnePNC>
158 { using type = GetPropType<TypeTag, Properties::BaseModelTraits>; };
159
160 /*!
161 * \brief The fluid state which is used by the volume variables to
162 * store the thermodynamic state. This should be chosen
163 * appropriately for the model ((non-)isothermal, equilibrium, ...).
164 * This can be done in the problem.
165 */
166 template<class TypeTag>
167 struct FluidState<TypeTag, TTag::NavierStokesMassOnePNC>
168 {
169 private:
170 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
171 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
172 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
173 public:
174 using type = CompositionalFluidState<Scalar, FluidSystem>;
175 };
176
177 //! The local residual
178 template<class TypeTag>
179 struct LocalResidual<TypeTag, TTag::NavierStokesMassOnePNC>
180 { using type = NavierStokesMassOnePNCLocalResidual<TypeTag>; };
181
182 //! Set the volume variables property
183 template<class TypeTag>
184 struct VolumeVariables<TypeTag, TTag::NavierStokesMassOnePNC>
185 {
186 private:
187 using PV = GetPropType<TypeTag, Properties::PrimaryVariables>;
188 using FSY = GetPropType<TypeTag, Properties::FluidSystem>;
189 using FST = GetPropType<TypeTag, Properties::FluidState>;
190 using MT = GetPropType<TypeTag, Properties::ModelTraits>;
191
192 static_assert(FSY::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid system");
193 static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state");
194 // static_assert(!FSY::isMiscible(), "The Navier-Stokes model only works with immiscible fluid systems.");
195
196 using BaseTraits = NavierStokesMassOnePNCVolumeVariablesTraits<PV, FSY, FST, MT>;
197 using DT = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
198 using EDM = GetPropType<TypeTag, Properties::EffectiveDiffusivityModel>;
199
200 template<class BaseTraits, class DT, class EDM>
201 struct NCTraits : public BaseTraits
202 {
203 using DiffusionType = DT;
204 using EffectiveDiffusivityModel = EDM;
205 };
206
207 public:
208 using type = NavierStokesMassOnePNCVolumeVariables<NCTraits<BaseTraits, DT, EDM>>;
209 };
210
211 //! By default, we use fick's law for the diffusive fluxes
212 template<class TypeTag>
213 struct MolecularDiffusionType<TypeTag, TTag::NavierStokesMassOnePNC> { using type = FicksLaw<TypeTag>; };
214
215 //! Use the model after Millington (1961) for the effective diffusivity
216 template<class TypeTag>
217 struct EffectiveDiffusivityModel<TypeTag, TTag::NavierStokesMassOnePNC>
218 {
219 struct type
220 {
221 template<class VolumeVariables>
222 static auto effectiveDiffusionCoefficient(const VolumeVariables& volVars,
223 const int phaseIdx,
224 const int compIdxI,
225 const int compIdxJ)
226 {
227 return volVars.diffusionCoefficient(phaseIdx, compIdxI, compIdxJ);
228 }
229 };
230 };
231
232 //! The flux variables
233 template<class TypeTag>
234 struct FluxVariables<TypeTag, TTag::NavierStokesMassOnePNC>
235 {
236 using Problem = GetPropType<TypeTag, Properties::Problem>;
237 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
238
239 struct FluxTypes
240 {
241 using MolecularDiffusionType = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
242 };
243
244 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
245 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
246
247 using type = NavierStokesMassOnePNCFluxVariables<Problem, ModelTraits, FluxTypes, ElementVolumeVariables, ElementFluxVariablesCache>;
248 };
249
250 template<class TypeTag>
251 struct SolutionDependentMolecularDiffusion<TypeTag, TTag::NavierStokesMassOnePNC> { static constexpr bool value = true; };
252
253
254 template<class TypeTag>
255 struct FluxVariablesCache<TypeTag, TTag::NavierStokesMassOnePNC>
256 {
257 struct type : public GetPropType<TypeTag, Properties::MolecularDiffusionType>::Cache
258 {};
259 };
260
261 template<class TypeTag>
262 struct FluxVariablesCacheFiller<TypeTag, TTag::NavierStokesMassOnePNC>
263 {
264 using Problem = GetPropType<TypeTag, Properties::Problem>;
265 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
266 static constexpr bool diffusionIsSolDependent = getPropValue<TypeTag, Properties::SolutionDependentMolecularDiffusion>();
267 static constexpr bool heatConductionIsSolDependent = false; // no heat conduction
268
269 using type = FreeFlowScalarFluxVariablesCacheFiller<Problem, ModelTraits, diffusionIsSolDependent, heatConductionIsSolDependent>;
270 };
271
272 // ! The specific I/O fields
273 template<class TypeTag>
274 struct IOFields<TypeTag, TTag::NavierStokesMassOnePNC> { using type = NavierStokesMassOnePNCIOFields<NavierStokesIOFields>; };
275
276 template<class TypeTag>
277 struct CouplingManager<TypeTag, TTag::NavierStokesMassOnePNC>
278 {
279 private:
280 struct EmptyCouplingManager {};
281 public:
282 using type = EmptyCouplingManager;
283 };
284
285 // Set the default spatial parameters
286 template<class TypeTag>
287 struct SpatialParams<TypeTag, TTag::NavierStokesMassOnePNC>
288 {
289 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
290 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
291 using type = FreeFlowDefaultSpatialParams<GridGeometry, Scalar>;
292 };
293 ///////////////////////////////////////////////////////////////////////////
294 // Properties for the non-isothermal single phase model
295 ///////////////////////////////////////////////////////////////////////////
296
297 //! Add temperature to the output
298 template<class TypeTag>
299 struct IOFields<TypeTag, TTag::NavierStokesMassOnePNCNI> { using type = NavierStokesEnergyIOFields<NavierStokesMassOnePNCIOFields<NavierStokesIOFields>>; };
300
301 //! The model traits of the non-isothermal model
302 template<class TypeTag>
303 struct ModelTraits<TypeTag, TTag::NavierStokesMassOnePNCNI> { using type = NavierStokesEnergyModelTraits<GetPropType<TypeTag, Properties::BaseModelTraits>>; };
304
305 //! Set the volume variables property
306 template<class TypeTag>
307 struct VolumeVariables<TypeTag, TTag::NavierStokesMassOnePNCNI>
308 {
309 private:
310 using PV = GetPropType<TypeTag, Properties::PrimaryVariables>;
311 using FSY = GetPropType<TypeTag, Properties::FluidSystem>;
312 using FST = GetPropType<TypeTag, Properties::FluidState>;
313 using MT = GetPropType<TypeTag, Properties::ModelTraits>;
314
315 static_assert(FSY::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid system");
316 static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state");
317 static_assert(!FSY::isMiscible(), "The Navier-Stokes model only works with immiscible fluid systems.");
318
319 using BaseTraits = NavierStokesMassOnePNCVolumeVariablesTraits<PV, FSY, FST, MT>;
320
321 using DT = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
322 using EDM = GetPropType<TypeTag, Properties::EffectiveDiffusivityModel>;
323 using ETCM = GetPropType<TypeTag, Properties::ThermalConductivityModel>;
324 using HCT = GetPropType<TypeTag, Properties::HeatConductionType>;
325
326 struct NCNITraits : public BaseTraits
327 {
328 using DiffusionType = DT;
329 using EffectiveDiffusivityModel = EDM;
330 using EffectiveThermalConductivityModel = ETCM;
331 using HeatConductionType = HCT;
332 };
333
334 public:
335 using type = NavierStokesMassOnePNCVolumeVariables<NCNITraits>;
336 };
337
338 //! Use the average for effective conductivities
339 template<class TypeTag>
340 struct ThermalConductivityModel<TypeTag, TTag::NavierStokesMassOnePNCNI>
341 {
342 struct type
343 {
344 template<class VolVars>
345 static auto effectiveThermalConductivity(const VolVars& volVars)
346 {
347 4743315 return volVars.fluidThermalConductivity();
348 }
349 };
350 };
351
352 template<class TypeTag>
353 struct HeatConductionType<TypeTag, TTag::NavierStokesMassOnePNCNI>
354 { using type = FouriersLaw<TypeTag>; };
355
356 //! The flux variables
357 template<class TypeTag>
358 struct FluxVariables<TypeTag, TTag::NavierStokesMassOnePNCNI>
359 {
360 using Problem = GetPropType<TypeTag, Properties::Problem>;
361 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
362
363 struct FluxTypes
364 {
365 using MolecularDiffusionType = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
366 using HeatConductionType = GetPropType<TypeTag, Properties::HeatConductionType>;
367 };
368
369 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
370 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
371
372 using type = NavierStokesMassOnePNCFluxVariables<Problem, ModelTraits, FluxTypes, ElementVolumeVariables, ElementFluxVariablesCache>;
373 };
374
375 template<class TypeTag>
376 struct FluxVariablesCache<TypeTag, TTag::NavierStokesMassOnePNCNI>
377 {
378 struct type
379 : public GetPropType<TypeTag, Properties::MolecularDiffusionType>::Cache
380 , public GetPropType<TypeTag, Properties::HeatConductionType>::Cache
381 {};
382 };
383
384 template<class TypeTag>
385 struct FluxVariablesCacheFiller<TypeTag, TTag::NavierStokesMassOnePNCNI>
386 {
387 using Problem = GetPropType<TypeTag, Properties::Problem>;
388 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
389 static constexpr bool diffusionIsSolDependent = getPropValue<TypeTag, Properties::SolutionDependentMolecularDiffusion>();
390 static constexpr bool heatConductionIsSolDependent = getPropValue<TypeTag, Properties::SolutionDependentHeatConduction>();
391
392 using type = FreeFlowScalarFluxVariablesCacheFiller<Problem, ModelTraits, diffusionIsSolDependent, heatConductionIsSolDependent>;
393 };
394
395 template<class TypeTag>
396 struct SolutionDependentHeatConduction<TypeTag, TTag::NavierStokesMassOnePNCNI> { static constexpr bool value = true; };
397
398 } // end namespace Properties
399
400 } // end namespace Dumux
401
402 #endif // DUMUX_NAVIERSTOKES_MODEL_HH
403