GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/navierstokes/mass/1pnc/model.hh
Date: 2024-09-21 20:52:54
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 */
65 template<int nComp, bool useM, int repCompEqIdx = nComp>
66 struct NavierStokesMassOnePNCModelTraits
67 {
68 //! There are as many momentum balance equations as dimensions
69 //! and one mass balance equation.
70 static constexpr int numEq() { return nComp; }
71
72 //! The number of phases is 1
73 static constexpr int numFluidPhases() { return 1; }
74
75 //! The number of components can be freely chosen
76 static constexpr int numFluidComponents() { return nComp; }
77
78 //! Use moles or not
79 static constexpr bool useMoles() { return useM; }
80
81 // Enable advection
82 static constexpr bool enableAdvection() { return true; }
83
84 //! The model is isothermal
85 static constexpr bool enableEnergyBalance() { return false; }
86
87 //! The one-phase model has no molecular diffusion
88 static constexpr bool enableMolecularDiffusion() { return true; }
89
90 //! Index of of a component balance eq. to be replaced by a total mass/mole balance
91 static constexpr int replaceCompEqIdx() { return repCompEqIdx; }
92
93 //! The model does not include a turbulence model
94 static constexpr bool usesTurbulenceModel() { return false; }
95
96 //! return the type of turbulence model used
97 static constexpr auto turbulenceModel()
98 { return TurbulenceModel::none; }
99
100 //! the indices
101 using Indices = NavierStokesMassOnePNCIndices;
102 };
103
104 /*!
105 * \ingroup NavierStokesModel
106 * \brief Traits class for the volume variables of the Navier-Stokes model.
107 *
108 * \tparam PV The type used for primary variables
109 * \tparam FSY The fluid system type
110 * \tparam FST The fluid state type
111 * \tparam MT The model traits
112 */
113 template<class PV,
114 class FSY,
115 class FST,
116 class MT>
117 struct NavierStokesMassOnePNCVolumeVariablesTraits
118 {
119 using PrimaryVariables = PV;
120 using FluidSystem = FSY;
121 using FluidState = FST;
122 using ModelTraits = MT;
123 };
124
125 // \{
126 ///////////////////////////////////////////////////////////////////////////
127 // properties for the single-phase Navier-Stokes model
128 ///////////////////////////////////////////////////////////////////////////
129 namespace Properties {
130
131 //////////////////////////////////////////////////////////////////
132 // Type tags
133 //////////////////////////////////////////////////////////////////
134
135 // Create new type tags
136 namespace TTag {
137 //! The type tag for the single-phase, isothermal Navier-Stokes model
138 struct NavierStokesMassOnePNC{ using InheritsFrom = std::tuple<ModelProperties>; };
139 struct NavierStokesMassOnePNCNI{ using InheritsFrom = std::tuple<NavierStokesMassOnePNC>; };
140
141 }
142
143 //! The base model traits. Per default, we use the number of components of the fluid system.
144 template<class TypeTag>
145 struct BaseModelTraits<TypeTag, TTag::NavierStokesMassOnePNC>
146 {
147 private:
148 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
149 public:
150 using type = NavierStokesMassOnePNCModelTraits<FluidSystem::numComponents, getPropValue<TypeTag, Properties::UseMoles>(), getPropValue<TypeTag, Properties::ReplaceCompEqIdx>()>;
151 };
152
153
154 //!< states some specifics of the Navier-Stokes model
155 template<class TypeTag>
156 struct ModelTraits<TypeTag, TTag::NavierStokesMassOnePNC>
157 { using type = GetPropType<TypeTag, Properties::BaseModelTraits>; };
158
159 /*!
160 * \brief The fluid state which is used by the volume variables to
161 * store the thermodynamic state. This should be chosen
162 * appropriately for the model ((non-)isothermal, equilibrium, ...).
163 * This can be done in the problem.
164 */
165 template<class TypeTag>
166 struct FluidState<TypeTag, TTag::NavierStokesMassOnePNC>
167 {
168 private:
169 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
170 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
171 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
172 public:
173 using type = CompositionalFluidState<Scalar, FluidSystem>;
174 };
175
176 //! The local residual
177 template<class TypeTag>
178 struct LocalResidual<TypeTag, TTag::NavierStokesMassOnePNC>
179 { using type = NavierStokesMassOnePNCLocalResidual<TypeTag>; };
180
181 //! Set the volume variables property
182 template<class TypeTag>
183 struct VolumeVariables<TypeTag, TTag::NavierStokesMassOnePNC>
184 {
185 private:
186 using PV = GetPropType<TypeTag, Properties::PrimaryVariables>;
187 using FSY = GetPropType<TypeTag, Properties::FluidSystem>;
188 using FST = GetPropType<TypeTag, Properties::FluidState>;
189 using MT = GetPropType<TypeTag, Properties::ModelTraits>;
190
191 static_assert(FSY::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid system");
192 static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state");
193 // static_assert(!FSY::isMiscible(), "The Navier-Stokes model only works with immiscible fluid systems.");
194
195 using BaseTraits = NavierStokesMassOnePNCVolumeVariablesTraits<PV, FSY, FST, MT>;
196 using DT = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
197 using EDM = GetPropType<TypeTag, Properties::EffectiveDiffusivityModel>;
198
199 template<class BaseTraits, class DT, class EDM>
200 struct NCTraits : public BaseTraits
201 {
202 using DiffusionType = DT;
203 using EffectiveDiffusivityModel = EDM;
204 };
205
206 public:
207 using type = NavierStokesMassOnePNCVolumeVariables<NCTraits<BaseTraits, DT, EDM>>;
208 };
209
210 //! By default, we use fick's law for the diffusive fluxes
211 template<class TypeTag>
212 struct MolecularDiffusionType<TypeTag, TTag::NavierStokesMassOnePNC> { using type = FicksLaw<TypeTag>; };
213
214 //! Use the model after Millington (1961) for the effective diffusivity
215 template<class TypeTag>
216 struct EffectiveDiffusivityModel<TypeTag, TTag::NavierStokesMassOnePNC>
217 {
218 struct type
219 {
220 template<class VolumeVariables>
221 static auto effectiveDiffusionCoefficient(const VolumeVariables& volVars,
222 const int phaseIdx,
223 const int compIdxI,
224 const int compIdxJ)
225 {
226 return volVars.diffusionCoefficient(phaseIdx, compIdxI, compIdxJ);
227 }
228 };
229 };
230
231 //! The flux variables
232 template<class TypeTag>
233 struct FluxVariables<TypeTag, TTag::NavierStokesMassOnePNC>
234 {
235 using Problem = GetPropType<TypeTag, Properties::Problem>;
236 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
237
238 struct FluxTypes
239 {
240 using MolecularDiffusionType = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
241 };
242
243 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
244 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
245
246 using type = NavierStokesMassOnePNCFluxVariables<Problem, ModelTraits, FluxTypes, ElementVolumeVariables, ElementFluxVariablesCache>;
247 };
248
249 template<class TypeTag>
250 struct SolutionDependentMolecularDiffusion<TypeTag, TTag::NavierStokesMassOnePNC> { static constexpr bool value = true; };
251
252
253 template<class TypeTag>
254 struct FluxVariablesCache<TypeTag, TTag::NavierStokesMassOnePNC>
255 {
256 struct type : public GetPropType<TypeTag, Properties::MolecularDiffusionType>::Cache
257 {};
258 };
259
260 template<class TypeTag>
261 struct FluxVariablesCacheFiller<TypeTag, TTag::NavierStokesMassOnePNC>
262 {
263 using Problem = GetPropType<TypeTag, Properties::Problem>;
264 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
265 static constexpr bool diffusionIsSolDependent = getPropValue<TypeTag, Properties::SolutionDependentMolecularDiffusion>();
266 static constexpr bool heatConductionIsSolDependent = false; // no heat conduction
267
268 using type = FreeFlowScalarFluxVariablesCacheFiller<Problem, ModelTraits, diffusionIsSolDependent, heatConductionIsSolDependent>;
269 };
270
271 // ! The specific I/O fields
272 template<class TypeTag>
273 struct IOFields<TypeTag, TTag::NavierStokesMassOnePNC> { using type = NavierStokesMassOnePNCIOFields<NavierStokesIOFields>; };
274
275 template<class TypeTag>
276 struct CouplingManager<TypeTag, TTag::NavierStokesMassOnePNC>
277 {
278 private:
279 struct EmptyCouplingManager {};
280 public:
281 using type = EmptyCouplingManager;
282 };
283
284 // Set the default spatial parameters
285 template<class TypeTag>
286 struct SpatialParams<TypeTag, TTag::NavierStokesMassOnePNC>
287 {
288 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
289 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
290 using type = FreeFlowDefaultSpatialParams<GridGeometry, Scalar>;
291 };
292 ///////////////////////////////////////////////////////////////////////////
293 // Properties for the non-isothermal single phase model
294 ///////////////////////////////////////////////////////////////////////////
295
296 //! Add temperature to the output
297 template<class TypeTag>
298 struct IOFields<TypeTag, TTag::NavierStokesMassOnePNCNI> { using type = NavierStokesEnergyIOFields<NavierStokesMassOnePNCIOFields<NavierStokesIOFields>>; };
299
300 //! The model traits of the non-isothermal model
301 template<class TypeTag>
302 struct ModelTraits<TypeTag, TTag::NavierStokesMassOnePNCNI> { using type = NavierStokesEnergyModelTraits<GetPropType<TypeTag, Properties::BaseModelTraits>>; };
303
304 //! Set the volume variables property
305 template<class TypeTag>
306 struct VolumeVariables<TypeTag, TTag::NavierStokesMassOnePNCNI>
307 {
308 private:
309 using PV = GetPropType<TypeTag, Properties::PrimaryVariables>;
310 using FSY = GetPropType<TypeTag, Properties::FluidSystem>;
311 using FST = GetPropType<TypeTag, Properties::FluidState>;
312 using MT = GetPropType<TypeTag, Properties::ModelTraits>;
313
314 static_assert(FSY::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid system");
315 static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state");
316 static_assert(!FSY::isMiscible(), "The Navier-Stokes model only works with immiscible fluid systems.");
317
318 using BaseTraits = NavierStokesMassOnePNCVolumeVariablesTraits<PV, FSY, FST, MT>;
319
320 using DT = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
321 using EDM = GetPropType<TypeTag, Properties::EffectiveDiffusivityModel>;
322 using ETCM = GetPropType<TypeTag, Properties::ThermalConductivityModel>;
323 using HCT = GetPropType<TypeTag, Properties::HeatConductionType>;
324
325 struct NCNITraits : public BaseTraits
326 {
327 using DiffusionType = DT;
328 using EffectiveDiffusivityModel = EDM;
329 using EffectiveThermalConductivityModel = ETCM;
330 using HeatConductionType = HCT;
331 };
332
333 public:
334 using type = NavierStokesMassOnePNCVolumeVariables<NCNITraits>;
335 };
336
337 //! Use the average for effective conductivities
338 template<class TypeTag>
339 struct ThermalConductivityModel<TypeTag, TTag::NavierStokesMassOnePNCNI>
340 {
341 struct type
342 {
343 template<class VolVars>
344 static auto effectiveThermalConductivity(const VolVars& volVars)
345 {
346 4743315 return volVars.fluidThermalConductivity();
347 }
348 };
349 };
350
351 template<class TypeTag>
352 struct HeatConductionType<TypeTag, TTag::NavierStokesMassOnePNCNI>
353 { using type = FouriersLaw<TypeTag>; };
354
355 //! The flux variables
356 template<class TypeTag>
357 struct FluxVariables<TypeTag, TTag::NavierStokesMassOnePNCNI>
358 {
359 using Problem = GetPropType<TypeTag, Properties::Problem>;
360 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
361
362 struct FluxTypes
363 {
364 using MolecularDiffusionType = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
365 using HeatConductionType = GetPropType<TypeTag, Properties::HeatConductionType>;
366 };
367
368 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
369 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
370
371 using type = NavierStokesMassOnePNCFluxVariables<Problem, ModelTraits, FluxTypes, ElementVolumeVariables, ElementFluxVariablesCache>;
372 };
373
374 template<class TypeTag>
375 struct FluxVariablesCache<TypeTag, TTag::NavierStokesMassOnePNCNI>
376 {
377 struct type
378 : public GetPropType<TypeTag, Properties::MolecularDiffusionType>::Cache
379 , public GetPropType<TypeTag, Properties::HeatConductionType>::Cache
380 {};
381 };
382
383 template<class TypeTag>
384 struct FluxVariablesCacheFiller<TypeTag, TTag::NavierStokesMassOnePNCNI>
385 {
386 using Problem = GetPropType<TypeTag, Properties::Problem>;
387 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
388 static constexpr bool diffusionIsSolDependent = getPropValue<TypeTag, Properties::SolutionDependentMolecularDiffusion>();
389 static constexpr bool heatConductionIsSolDependent = getPropValue<TypeTag, Properties::SolutionDependentHeatConduction>();
390
391 using type = FreeFlowScalarFluxVariablesCacheFiller<Problem, ModelTraits, diffusionIsSolDependent, heatConductionIsSolDependent>;
392 };
393
394 template<class TypeTag>
395 struct SolutionDependentHeatConduction<TypeTag, TTag::NavierStokesMassOnePNCNI> { static constexpr bool value = true; };
396
397 } // end namespace Properties
398
399 } // end namespace Dumux
400
401 #endif // DUMUX_NAVIERSTOKES_MODEL_HH
402