version 3.10-dev
freeflow/navierstokes/mass/1pnc/volumevariables.hh
Go to the documentation of this file.
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//
13#ifndef DUMUX_NAVIERSTOKES_MASS_1PNC_VOLUME_VARIABLES_HH
14#define DUMUX_NAVIERSTOKES_MASS_1PNC_VOLUME_VARIABLES_HH
15
18
19namespace Dumux {
20
25template <class Traits>
28, public NavierStokesEnergyVolumeVariables<Traits, NavierStokesMassOnePNCVolumeVariables<Traits>>
29{
32
33 using Scalar = typename Traits::PrimaryVariables::value_type;
34
35 static constexpr bool useMoles = Traits::ModelTraits::useMoles();
36 using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
37
38
39public:
41 using FluidSystem = typename Traits::FluidSystem;
43 using FluidState = typename Traits::FluidState;
45 using MolecularDiffusionType = typename Traits::DiffusionType;
47 using Indices = typename Traits::ModelTraits::Indices;
48
58 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
59 void update(const ElementSolution &elemSol,
60 const Problem &problem,
61 const Element &element,
62 const SubControlVolume& scv)
63 {
64 ParentType::update(elemSol, problem, element, scv);
65
66 completeFluidState(elemSol, problem, element, scv, fluidState_);
67
68 typename FluidSystem::ParameterCache paramCache;
69 paramCache.updateAll(fluidState_);
70
71 auto getDiffusionCoefficient = [&](int phaseIdx, int compIIdx, int compJIdx)
72 {
73 return FluidSystem::binaryDiffusionCoefficient(this->fluidState_,
74 paramCache,
75 0,
76 compIIdx,
77 compJIdx);
78 };
79
80 diffCoefficient_.update(getDiffusionCoefficient);
82 }
83
87 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
88 void completeFluidState(const ElementSolution& elemSol,
89 const Problem& problem,
90 const Element& element,
91 const SubControlVolume& scv,
93 {
94 fluidState.setTemperature(0, EnergyVolumeVariables::getTemperature(elemSol, problem, element, scv));
95 fluidState.setPressure(0, elemSol[0][Indices::pressureIdx]);
96
97 // saturation in a single phase is always 1 and thus redundant
98 // to set. But since we use the fluid state shared by the
99 // immiscible multi-phase models, so we have to set it here...
100 fluidState.setSaturation(0, 1.0);
101
102 Scalar sumFracMinorComp = 0.0;
103
104 for(int compIdx = 1; compIdx < ParentType::numFluidComponents(); ++compIdx)
105 {
106 // temporary add 1.0 to remove spurious differences in mole fractions
107 // which are below the numerical accuracy
108 Scalar moleOrMassFraction = elemSol[0][Indices::conti0EqIdx+compIdx] + 1.0;
109 moleOrMassFraction = moleOrMassFraction - 1.0;
110 if(useMoles)
111 fluidState.setMoleFraction(0, compIdx, moleOrMassFraction);
112 else
113 fluidState.setMassFraction(0, compIdx, moleOrMassFraction);
114 sumFracMinorComp += moleOrMassFraction;
115 }
116 if(useMoles)
117 fluidState.setMoleFraction(0, 0, 1.0 - sumFracMinorComp);
118 else
119 fluidState.setMassFraction(0, 0, 1.0 - sumFracMinorComp);
120
121 typename FluidSystem::ParameterCache paramCache;
122 paramCache.updateAll(fluidState);
123
124 Scalar value = FluidSystem::density(fluidState, paramCache, 0);
125 fluidState.setDensity(0, value);
126
127 value = FluidSystem::molarDensity(fluidState, paramCache, 0);
128 fluidState.setMolarDensity(0, value);
129
130 value = FluidSystem::viscosity(fluidState, paramCache, 0);
131 fluidState.setViscosity(0, value);
132
133 // compute and set the enthalpy
134 const Scalar h = EnergyVolumeVariables::enthalpy(fluidState, paramCache);
135 fluidState.setEnthalpy(0, h);
136 }
137
142 Scalar pressure(int phaseIdx = 0) const
143 { return fluidState_.pressure(0); }
144
148 Scalar saturation(int phaseIdx = 0) const
149 { return 1.0; }
150
155 Scalar density(int phaseIdx = 0) const
156 { return fluidState_.density(0); }
157
162 Scalar temperature() const
163 { return fluidState_.temperature(); }
164
169 Scalar effectiveViscosity() const
170 { return viscosity(); }
171
176 Scalar viscosity(int phaseIdx = 0) const
177 { return fluidState_.viscosity(0); }
178
185 Scalar massFraction(int phaseIdx, int compIdx) const
186 {
187 return fluidState_.massFraction(0, compIdx);
188 }
189
195 Scalar massFraction(int compIdx) const
196 {
197 return fluidState_.massFraction(0, compIdx);
198 }
199
206 Scalar moleFraction(int phaseIdx, int compIdx) const
207 {
208 return fluidState_.moleFraction(0, compIdx);
209 }
210
216 Scalar moleFraction(int compIdx) const
217 {
218 return fluidState_.moleFraction(0, compIdx);
219 }
220
224 Scalar molarDensity(int phaseIdx = 0) const
225 {
226 return fluidState_.molarDensity(0);
227 }
228
234 Scalar molarMass(int compIdx) const
235 {
236 return FluidSystem::molarMass(compIdx);
237 }
238
244 Scalar averageMolarMass(const int phaseIdx = 0) const
245 { return fluidState_.averageMolarMass(phaseIdx); }
246
250 Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
251 { return diffCoefficient_(0, compIIdx, compJIdx); }
252
256 Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
257 { return diffusionCoefficient(0, compIIdx, compJIdx); }
258
262 const FluidState& fluidState() const
263 { return fluidState_; }
264
265protected:
267 // Binary diffusion coefficient
268 DiffusionCoefficients diffCoefficient_;
269};
270
271} // end namespace Dumux
272
273#endif // DUMUX_NAVIERSTOKES_MOMENTUM_VOLUME_VARIABLES_HH
The isothermal base class.
Definition: freeflow/navierstokes/energy/volumevariables.hh:47
Scalar getTemperature(const ElementSolution &elemSol, const Problem &problem, const Element &element, const SubControlVolume &scv) const
Returns the temperature at a given sub-control volume.
Definition: freeflow/navierstokes/energy/volumevariables.hh:66
void updateEffectiveThermalConductivity()
The effective thermal conductivity is zero for isothermal models.
Definition: freeflow/navierstokes/energy/volumevariables.hh:79
Scalar enthalpy(const int phaseIdx=0) const
Returns the total enthalpy of a phase in the sub-control volume.
Definition: freeflow/navierstokes/energy/volumevariables.hh:105
Volume variables for the single-phase Navier-Stokes model.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:29
Scalar effectiveViscosity() const
Return the effective dynamic viscosity of the fluid within the control volume.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:169
DiffusionCoefficients diffCoefficient_
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:268
Scalar viscosity(int phaseIdx=0) const
Return the dynamic viscosity of the fluid within the control volume.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:176
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of a component in the phase .
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:185
typename Traits::DiffusionType MolecularDiffusionType
export the diffusion type
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:45
typename Traits::FluidState FluidState
export the fluid state type
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:43
Scalar moleFraction(int compIdx) const
Returns the mole fraction of a component in the phase .
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:216
void update(const ElementSolution &elemSol, const Problem &problem, const Element &element, const SubControlVolume &scv)
Update all quantities for a given control volume.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:59
const FluidState & fluidState() const
Return the fluid state of the control volume.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:262
FluidState fluidState_
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:266
typename Traits::ModelTraits::Indices Indices
export the indices type
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:47
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the mole fraction of a component in the phase .
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:206
Scalar molarMass(int compIdx) const
Returns the molar mass of a given component.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:234
Scalar pressure(int phaseIdx=0) const
Return the effective pressure of a given phase within the control volume.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:142
Scalar molarDensity(int phaseIdx=0) const
Returns the mass density of a given phase .
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:224
Scalar saturation(int phaseIdx=0) const
Returns the saturation.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:148
Scalar averageMolarMass(const int phaseIdx=0) const
Returns the average molar mass of the fluid phase.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:244
void completeFluidState(const ElementSolution &elemSol, const Problem &problem, const Element &element, const SubControlVolume &scv, FluidState &fluidState) const
Update the fluid state.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:88
Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the effective diffusion coefficients for a phase in .
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:256
Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:250
typename Traits::FluidSystem FluidSystem
export the underlying fluid system
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:41
Scalar temperature() const
Return temperature inside the sub-control volume.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:162
Scalar massFraction(int compIdx) const
Returns the mass fraction of a component in the phase .
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:195
Scalar density(int phaseIdx=0) const
Return the mass density of a given phase within the control volume.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:155
Volume variables for the single-phase Navier-Stokes model.
Definition: scalarvolumevariables.hh:24
static constexpr int numFluidComponents()
Return number of components considered by the model.
Definition: scalarvolumevariables.hh:40
void update(const ElementSolution &elemSol, const Problem &problem, const Element &element, const SubControlVolume &scv)
Update all quantities for a given control volume.
Definition: scalarvolumevariables.hh:52
Base class for the model specific class which provides access to all volume averaged quantities.
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:62
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:71
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Definition: adapt.hh:17