version 3.8
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
165 Scalar temperature() const
166 { return fluidState_.temperature(); }
167
172 Scalar effectiveViscosity() const
173 { return viscosity(); }
174
179 Scalar viscosity(int phaseIdx = 0) const
180 { return fluidState_.viscosity(0); }
181
188 Scalar massFraction(int phaseIdx, int compIdx) const
189 {
190 return fluidState_.massFraction(0, compIdx);
191 }
192
198 Scalar massFraction(int compIdx) const
199 {
200 return fluidState_.massFraction(0, compIdx);
201 }
202
209 Scalar moleFraction(int phaseIdx, int compIdx) const
210 {
211 return fluidState_.moleFraction(0, compIdx);
212 }
213
219 Scalar moleFraction(int compIdx) const
220 {
221 return fluidState_.moleFraction(0, compIdx);
222 }
223
227 Scalar molarDensity(int phaseIdx = 0) const
228 {
229 return fluidState_.molarDensity(0);
230 }
231
237 Scalar molarMass(int compIdx) const
238 {
239 return FluidSystem::molarMass(compIdx);
240 }
241
247 Scalar averageMolarMass(const int phaseIdx = 0) const
248 { return fluidState_.averageMolarMass(phaseIdx); }
249
253 Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
254 { return diffCoefficient_(0, compIIdx, compJIdx); }
255
259 Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
260 { return diffusionCoefficient(0, compIIdx, compJIdx); }
261
265 const FluidState& fluidState() const
266 { return fluidState_; }
267
268protected:
270 // Binary diffusion coefficient
271 DiffusionCoefficients diffCoefficient_;
272};
273
274} // end namespace Dumux
275
276#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:172
DiffusionCoefficients diffCoefficient_
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:271
Scalar viscosity(int phaseIdx=0) const
Return the dynamic viscosity of the fluid within the control volume.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:179
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of a component in the phase .
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:188
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:219
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:265
FluidState fluidState_
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:269
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:209
Scalar molarMass(int compIdx) const
Returns the molar mass of a given component.
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:237
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:227
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:247
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:259
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:253
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:165
Scalar massFraction(int compIdx) const
Returns the mass fraction of a component in the phase .
Definition: freeflow/navierstokes/mass/1pnc/volumevariables.hh:198
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