3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
26#ifndef DUMUX_1PNC_VOLUME_VARIABLES_HH
27#define DUMUX_1PNC_VOLUME_VARIABLES_HH
28
29#include <dune/common/fvector.hh>
30
34
35namespace Dumux {
36
46template <class Traits>
49, public EnergyVolumeVariables<Traits, OnePNCVolumeVariables<Traits> >
50{
53 using Scalar = typename Traits::PrimaryVariables::value_type;
54 using PermeabilityType = typename Traits::PermeabilityType;
55 using EffDiffModel = typename Traits::EffectiveDiffusivityModel;
56 using Idx = typename Traits::ModelTraits::Indices;
57 static constexpr int numFluidComps = ParentType::numFluidComponents();
58 using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
59
60 enum
61 {
62 // pressure primary variable index
63 pressureIdx = Idx::pressureIdx
64 };
65
66public:
68 using FluidState = typename Traits::FluidState;
70 using FluidSystem = typename Traits::FluidSystem;
72 using Indices = typename Traits::ModelTraits::Indices;
74 using SolidState = typename Traits::SolidState;
76 using SolidSystem = typename Traits::SolidSystem;
77
79 static constexpr bool useMoles() { return Traits::ModelTraits::useMoles(); }
80
90 template<class ElemSol, class Problem, class Element, class Scv>
91 void update(const ElemSol &elemSol,
92 const Problem &problem,
93 const Element &element,
94 const Scv &scv)
95 {
96 ParentType::update(elemSol, problem, element, scv);
97
98 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
99
100 // calculate the remaining quantities
101 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
102 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
103 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
104 EnergyVolVars::updateEffectiveThermalConductivity();
105
106 auto getEffectiveDiffusionCoefficient = [&](int phaseIdx, int compIIdx, int compJIdx)
107 {
108 return EffDiffModel::effectiveDiffusionCoefficient(*this, phaseIdx, compIIdx, compJIdx);
109 };
110
111 effectiveDiffCoeff_.update(getEffectiveDiffusionCoefficient);
112 }
113
125 template<class ElemSol, class Problem, class Element, class Scv>
126 void completeFluidState(const ElemSol &elemSol,
127 const Problem& problem,
128 const Element& element,
129 const Scv &scv,
132 {
133 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
134 fluidState.setSaturation(0, 1.0);
135
136 const auto& priVars = elemSol[scv.localDofIndex()];
137 fluidState.setPressure(0, priVars[pressureIdx]);
138
139 // Set fluid state mole fractions
140 if (useMoles())
141 {
142 Scalar sumMoleFracNotMainComp = 0;
143 for (int compIdx = 1; compIdx < numFluidComps; ++compIdx)
144 {
145 fluidState.setMoleFraction(0, compIdx, priVars[compIdx]);
146 sumMoleFracNotMainComp += priVars[compIdx];
147 }
148 fluidState.setMoleFraction(0, 0, 1.0 - sumMoleFracNotMainComp);
149 }
150 else
151 {
152 // for mass fractions we only have to set numComponents-1 mass fractions
153 // the fluid state will internally compute the remaining mass fraction
154 for (int compIdx = 1; compIdx < numFluidComps; ++compIdx)
155 fluidState.setMassFraction(0, compIdx, priVars[compIdx]);
156 }
157
158 typename FluidSystem::ParameterCache paramCache;
159 paramCache.updateAll(fluidState);
160
161 Scalar rho = FluidSystem::density(fluidState, paramCache, 0);
162 Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, 0);
163 Scalar mu = FluidSystem::viscosity(fluidState, paramCache, 0);
164
165 fluidState.setDensity(0, rho);
166 fluidState.setMolarDensity(0, rhoMolar);
167 fluidState.setViscosity(0, mu);
168
169 // compute and set the enthalpy
170 Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, 0);
171 fluidState.setEnthalpy(0, h);
172 }
173
178 const FluidState &fluidState() const
179 { return fluidState_; }
180
184 const SolidState &solidState() const
185 { return solidState_; }
186
192 Scalar averageMolarMass(int phaseIdx = 0) const
193 { return fluidState_.averageMolarMass(0); }
194
201 Scalar density(int phaseIdx = 0) const
202 {
203 return fluidState_.density(0);
204 }
205
212 Scalar molarDensity(int phaseIdx = 0) const
213 {
214 return fluidState_.molarDensity(0);
215 }
216
223 Scalar saturation(int phaseIdx = 0) const
224 { return 1.0; }
225
235 Scalar moleFraction(int phaseIdx, int compIdx) const
236 {
237 // make sure this is only called with admissible indices
238 assert(compIdx < numFluidComps);
239 return fluidState_.moleFraction(0, compIdx);
240 }
241
251 Scalar massFraction(int phaseIdx, int compIdx) const
252 {
253 // make sure this is only called with admissible indices
254 assert(compIdx < numFluidComps);
255 return fluidState_.massFraction(0, compIdx);
256 }
257
267 Scalar pressure(int phaseIdx = 0) const
268 {
269 return fluidState_.pressure(0);
270 }
271
279 Scalar temperature() const
280 { return fluidState_.temperature(); }
281
291 Scalar mobility(int phaseIdx = 0) const
292 {
293 return 1.0/fluidState_.viscosity(0);
294 }
295
303 Scalar viscosity(int phaseIdx = 0) const
304 {
305 return fluidState_.viscosity(0);
306 }
307
311 Scalar porosity() const
312 { return solidState_.porosity(); }
313
317 Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
318 {
319 typename FluidSystem::ParameterCache paramCache;
320 paramCache.updatePhase(fluidState_, phaseIdx);
321 return FluidSystem::binaryDiffusionCoefficient(fluidState_, paramCache, phaseIdx, compIIdx, compJIdx);
322 }
323
327 Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
328 { return effectiveDiffCoeff_(phaseIdx, compIIdx, compJIdx); }
329
335 Scalar molarity(int compIdx) const // [moles/m^3]
336 {
337 assert(compIdx < numFluidComps);
338 return fluidState_.molarity(0, compIdx);
339 }
340
346 Scalar massFraction(int compIdx) const
347 {
348 assert(compIdx < numFluidComps);
349 return fluidState_.massFraction(0, compIdx);
350 }
351
355 const PermeabilityType& permeability() const
356 { return permeability_; }
357
358protected:
361
362private:
363 PermeabilityType permeability_;
364
365 // Effective diffusion coefficients for the phases
366 DiffusionCoefficients effectiveDiffCoeff_;
367};
368
369} // end namespace Dumux
370
371#endif
Update the solid volume fractions (inert and reacitve) and set them in the solidstate.
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:36
Definition: adapt.hh:29
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:83
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Contains the quantities which are are constant within a finite volume in the one-phase,...
Definition: porousmediumflow/1pnc/volumevariables.hh:50
Scalar saturation(int phaseIdx=0) const
Returns the saturation.
Definition: porousmediumflow/1pnc/volumevariables.hh:223
FluidState fluidState_
Definition: porousmediumflow/1pnc/volumevariables.hh:359
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:251
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:91
Scalar viscosity(int phaseIdx=0) const
Returns the dynamic viscosity of the fluid within the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:303
SolidState solidState_
Definition: porousmediumflow/1pnc/volumevariables.hh:360
static constexpr bool useMoles()
Returns whether moles or masses are balanced.
Definition: porousmediumflow/1pnc/volumevariables.hh:79
Scalar density(int phaseIdx=0) const
Returns density the of the fluid phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:201
Scalar mobility(int phaseIdx=0) const
Returns the mobility .
Definition: porousmediumflow/1pnc/volumevariables.hh:291
Scalar massFraction(int compIdx) const
Returns the mass fraction of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:346
typename Traits::ModelTraits::Indices Indices
Export indices.
Definition: porousmediumflow/1pnc/volumevariables.hh:72
Scalar molarDensity(int phaseIdx=0) const
Returns molar density the of the fluid phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:212
Scalar porosity() const
Returns the average porosity within the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:311
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/1pnc/volumevariables.hh:76
Scalar pressure(int phaseIdx=0) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:267
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/1pnc/volumevariables.hh:355
Scalar molarity(int compIdx) const
Returns the molarity of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:335
Scalar averageMolarMass(int phaseIdx=0) const
Returns the average molar mass of the fluid phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:192
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the mole fraction of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:235
typename Traits::FluidState FluidState
Export fluid state type.
Definition: porousmediumflow/1pnc/volumevariables.hh:68
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:184
typename Traits::FluidSystem FluidSystem
Export fluid system type.
Definition: porousmediumflow/1pnc/volumevariables.hh:70
const FluidState & fluidState() const
Returns the fluid configuration at the given primary variables.
Definition: porousmediumflow/1pnc/volumevariables.hh:178
Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the effective diffusion coefficients for a phase in .
Definition: porousmediumflow/1pnc/volumevariables.hh:327
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/1pnc/volumevariables.hh:74
Scalar temperature() const
Returns the temperature inside the sub-control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:279
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:126
Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
Returns the binary diffusion coefficients for a phase in .
Definition: porousmediumflow/1pnc/volumevariables.hh:317
Definition: porousmediumflow/nonisothermal/volumevariables.hh:76
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:42
static constexpr int numFluidComponents()
Return number of components considered by the model.
Definition: porousmediumflow/volumevariables.hh:54
const PrimaryVariables & priVars() const
Returns the vector of primary variables.
Definition: porousmediumflow/volumevariables.hh:78
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:66
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.