version 3.8
porousmediumflow/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//
14#ifndef DUMUX_1PNC_VOLUME_VARIABLES_HH
15#define DUMUX_1PNC_VOLUME_VARIABLES_HH
16
17#include <dune/common/fvector.hh>
18
22
23namespace Dumux {
24
34template <class Traits>
37, public EnergyVolumeVariables<Traits, OnePNCVolumeVariables<Traits> >
38{
41 using Scalar = typename Traits::PrimaryVariables::value_type;
42 using PermeabilityType = typename Traits::PermeabilityType;
43 using EffDiffModel = typename Traits::EffectiveDiffusivityModel;
44 using Idx = typename Traits::ModelTraits::Indices;
45 static constexpr int numFluidComps = ParentType::numFluidComponents();
46 using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
47
48 enum
49 {
50 // pressure primary variable index
51 pressureIdx = Idx::pressureIdx
52 };
53
54public:
56 using FluidState = typename Traits::FluidState;
58 using FluidSystem = typename Traits::FluidSystem;
60 using Indices = typename Traits::ModelTraits::Indices;
62 using SolidState = typename Traits::SolidState;
64 using SolidSystem = typename Traits::SolidSystem;
65
67 static constexpr bool useMoles() { return Traits::ModelTraits::useMoles(); }
68
78 template<class ElemSol, class Problem, class Element, class Scv>
79 void update(const ElemSol &elemSol,
80 const Problem &problem,
81 const Element &element,
82 const Scv &scv)
83 {
84 ParentType::update(elemSol, problem, element, scv);
85
86 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
87
88 // calculate the remaining quantities
89 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
90 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
91 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
92 EnergyVolVars::updateEffectiveThermalConductivity();
93
94 auto getEffectiveDiffusionCoefficient = [&](int phaseIdx, int compIIdx, int compJIdx)
95 {
96 return EffDiffModel::effectiveDiffusionCoefficient(*this, phaseIdx, compIIdx, compJIdx);
97 };
98
99 effectiveDiffCoeff_.update(getEffectiveDiffusionCoefficient);
100 }
101
113 template<class ElemSol, class Problem, class Element, class Scv>
114 void completeFluidState(const ElemSol &elemSol,
115 const Problem& problem,
116 const Element& element,
117 const Scv &scv,
120 {
121 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
122 fluidState.setSaturation(0, 1.0);
123
124 const auto& priVars = elemSol[scv.localDofIndex()];
125 fluidState.setPressure(0, priVars[pressureIdx]);
126
127 // Set fluid state mole fractions
128 if (useMoles())
129 {
130 Scalar sumMoleFracNotMainComp = 0;
131 for (int compIdx = 1; compIdx < numFluidComps; ++compIdx)
132 {
133 fluidState.setMoleFraction(0, compIdx, priVars[compIdx]);
134 sumMoleFracNotMainComp += priVars[compIdx];
135 }
136 fluidState.setMoleFraction(0, 0, 1.0 - sumMoleFracNotMainComp);
137 }
138 else
139 {
140 // for mass fractions we only have to set numComponents-1 mass fractions
141 // the fluid state will internally compute the remaining mass fraction
142 for (int compIdx = 1; compIdx < numFluidComps; ++compIdx)
143 fluidState.setMassFraction(0, compIdx, priVars[compIdx]);
144 }
145
146 typename FluidSystem::ParameterCache paramCache;
147 paramCache.updateAll(fluidState);
148
149 Scalar rho = FluidSystem::density(fluidState, paramCache, 0);
150 Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, 0);
151 Scalar mu = FluidSystem::viscosity(fluidState, paramCache, 0);
152
153 fluidState.setDensity(0, rho);
154 fluidState.setMolarDensity(0, rhoMolar);
155 fluidState.setViscosity(0, mu);
156
157 // compute and set the enthalpy
158 Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, 0);
159 fluidState.setEnthalpy(0, h);
160 }
161
166 const FluidState &fluidState() const
167 { return fluidState_; }
168
172 const SolidState &solidState() const
173 { return solidState_; }
174
180 Scalar averageMolarMass(int phaseIdx = 0) const
181 { return fluidState_.averageMolarMass(0); }
182
189 Scalar density(int phaseIdx = 0) const
190 {
191 return fluidState_.density(0);
192 }
193
200 Scalar molarDensity(int phaseIdx = 0) const
201 {
202 return fluidState_.molarDensity(0);
203 }
204
211 Scalar saturation(int phaseIdx = 0) const
212 { return 1.0; }
213
223 Scalar moleFraction(int phaseIdx, int compIdx) const
224 {
225 // make sure this is only called with admissible indices
226 assert(compIdx < numFluidComps);
227 return fluidState_.moleFraction(0, compIdx);
228 }
229
239 Scalar massFraction(int phaseIdx, int compIdx) const
240 {
241 // make sure this is only called with admissible indices
242 assert(compIdx < numFluidComps);
243 return fluidState_.massFraction(0, compIdx);
244 }
245
255 Scalar pressure(int phaseIdx = 0) const
256 {
257 return fluidState_.pressure(0);
258 }
259
267 Scalar temperature() const
268 { return fluidState_.temperature(); }
269
279 Scalar mobility(int phaseIdx = 0) const
280 {
281 return 1.0/fluidState_.viscosity(0);
282 }
283
291 Scalar viscosity(int phaseIdx = 0) const
292 {
293 return fluidState_.viscosity(0);
294 }
295
299 Scalar porosity() const
300 { return solidState_.porosity(); }
301
305 Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
306 {
307 typename FluidSystem::ParameterCache paramCache;
308 paramCache.updatePhase(fluidState_, phaseIdx);
309 return FluidSystem::binaryDiffusionCoefficient(fluidState_, paramCache, phaseIdx, compIIdx, compJIdx);
310 }
311
315 Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
316 { return effectiveDiffCoeff_(phaseIdx, compIIdx, compJIdx); }
317
323 Scalar molarity(int compIdx) const // [moles/m^3]
324 {
325 assert(compIdx < numFluidComps);
326 return fluidState_.molarity(0, compIdx);
327 }
328
334 Scalar massFraction(int compIdx) const
335 {
336 assert(compIdx < numFluidComps);
337 return fluidState_.massFraction(0, compIdx);
338 }
339
343 const PermeabilityType& permeability() const
344 { return permeability_; }
345
346protected:
349
350private:
351 PermeabilityType permeability_;
352
353 // Effective diffusion coefficients for the phases
354 DiffusionCoefficients effectiveDiffCoeff_;
355};
356
357} // end namespace Dumux
358
359#endif
Definition: porousmediumflow/nonisothermal/volumevariables.hh:63
Contains the quantities which are are constant within a finite volume in the one-phase,...
Definition: porousmediumflow/1pnc/volumevariables.hh:38
Scalar saturation(int phaseIdx=0) const
Returns the saturation.
Definition: porousmediumflow/1pnc/volumevariables.hh:211
FluidState fluidState_
Definition: porousmediumflow/1pnc/volumevariables.hh:347
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:239
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:79
Scalar viscosity(int phaseIdx=0) const
Returns the dynamic viscosity of the fluid within the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:291
SolidState solidState_
Definition: porousmediumflow/1pnc/volumevariables.hh:348
static constexpr bool useMoles()
Returns whether moles or masses are balanced.
Definition: porousmediumflow/1pnc/volumevariables.hh:67
Scalar density(int phaseIdx=0) const
Returns density the of the fluid phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:189
Scalar mobility(int phaseIdx=0) const
Returns the mobility .
Definition: porousmediumflow/1pnc/volumevariables.hh:279
Scalar massFraction(int compIdx) const
Returns the mass fraction of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:334
typename Traits::ModelTraits::Indices Indices
Export indices.
Definition: porousmediumflow/1pnc/volumevariables.hh:60
Scalar molarDensity(int phaseIdx=0) const
Returns molar density the of the fluid phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:200
Scalar porosity() const
Returns the average porosity within the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:299
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/1pnc/volumevariables.hh:64
Scalar pressure(int phaseIdx=0) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:255
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/1pnc/volumevariables.hh:343
Scalar molarity(int compIdx) const
Returns the molarity of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:323
Scalar averageMolarMass(int phaseIdx=0) const
Returns the average molar mass of the fluid phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:180
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the mole fraction of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:223
typename Traits::FluidState FluidState
Export fluid state type.
Definition: porousmediumflow/1pnc/volumevariables.hh:56
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:172
typename Traits::FluidSystem FluidSystem
Export fluid system type.
Definition: porousmediumflow/1pnc/volumevariables.hh:58
const FluidState & fluidState() const
Returns the fluid configuration at the given primary variables.
Definition: porousmediumflow/1pnc/volumevariables.hh:166
Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the effective diffusion coefficients for a phase in .
Definition: porousmediumflow/1pnc/volumevariables.hh:315
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/1pnc/volumevariables.hh:62
Scalar temperature() const
Returns the temperature inside the sub-control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:267
void completeFluidState(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
Sets complete fluid state.
Definition: porousmediumflow/1pnc/volumevariables.hh:114
Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition: porousmediumflow/1pnc/volumevariables.hh:305
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:28
static constexpr int numFluidComponents()
Return number of components considered by the model.
Definition: porousmediumflow/volumevariables.hh:40
const PrimaryVariables & priVars() const
Returns the vector of primary variables.
Definition: porousmediumflow/volumevariables.hh:64
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/volumevariables.hh:52
void updateSolidVolumeFractions(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState, const int solidVolFracOffset)
update the solid volume fractions (inert and reacitve) and set them in the solidstate
Definition: updatesolidvolumefractions.hh:24
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
Base class for the model specific class which provides access to all volume averaged quantities.
Base class for the model specific class which provides access to all volume averaged quantities.
Update the solid volume fractions (inert and reacitve) and set them in the solidstate.