3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/3p/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 *****************************************************************************/
25#ifndef DUMUX_3P_VOLUME_VARIABLES_HH
26#define DUMUX_3P_VOLUME_VARIABLES_HH
27
34
35namespace Dumux {
36
41template <class Traits>
44, public EnergyVolumeVariables<Traits, ThreePVolumeVariables<Traits> >
45{
48
49 using Scalar = typename Traits::PrimaryVariables::value_type;
50 using PermeabilityType = typename Traits::PermeabilityType;
51 using Indices = typename Traits::ModelTraits::Indices;
52 using FS = typename Traits::FluidSystem;
53 static constexpr int numFluidComps = ParentType::numFluidComponents();
54
55 enum {
56 wPhaseIdx = FS::wPhaseIdx,
57 gPhaseIdx = FS::gPhaseIdx,
58 nPhaseIdx = FS::nPhaseIdx,
59
60 swIdx = Indices::swIdx,
61 snIdx = Indices::snIdx,
62 pressureIdx = Indices::pressureIdx
63 };
64
65public:
67 using FluidState = typename Traits::FluidState;
69 using FluidSystem = typename Traits::FluidSystem;
71 using SolidState = typename Traits::SolidState;
73 using SolidSystem = typename Traits::SolidSystem;
74
84 template<class ElemSol, class Problem, class Element, class Scv>
85 void update(const ElemSol &elemSol,
86 const Problem &problem,
87 const Element &element,
88 const Scv& scv)
89 {
90 ParentType::update(elemSol, problem, element, scv);
91
92 // capillary pressure parameters
93 using MaterialLaw = typename Problem::SpatialParams::MaterialLaw;
94 const auto& materialParams = problem.spatialParams().materialLawParams(element, scv, elemSol);
95
96 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
97
98 // mobilities
99 for (int phaseIdx = 0; phaseIdx < ParentType::numFluidPhases(); ++phaseIdx)
100 {
101 mobility_[phaseIdx] = MaterialLaw::kr(materialParams, phaseIdx,
102 fluidState_.saturation(wPhaseIdx),
103 fluidState_.saturation(nPhaseIdx),
104 fluidState_.saturation(gPhaseIdx))
105 / fluidState_.viscosity(phaseIdx);
106 Valgrind::CheckDefined(mobility_[phaseIdx]);
107 }
108
109 // porosity
110 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
111 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
112 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
113
114 Valgrind::CheckDefined(permeability_);
115 }
116
130 template<class ElemSol, class Problem, class Element, class Scv>
131 void completeFluidState(const ElemSol& elemSol,
132 const Problem& problem,
133 const Element& element,
134 const Scv& scv,
137 {
138 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
139
140 const auto& materialParams = problem.spatialParams().materialLawParams(element, scv, elemSol);
141 const auto& priVars = elemSol[scv.localDofIndex()];
142
143 const Scalar sw = priVars[swIdx];
144 const Scalar sn = priVars[snIdx];
145 const Scalar sg = 1.0 - sw - sn;
146
148
149 fluidState.setSaturation(wPhaseIdx, sw);
150 fluidState.setSaturation(gPhaseIdx, sg);
151 fluidState.setSaturation(nPhaseIdx, sn);
152
153 /* now the pressures */
154 const Scalar pg = priVars[pressureIdx];
155
156 // calculate capillary pressures
157 using MaterialLaw = typename Problem::SpatialParams::MaterialLaw;
158 const Scalar pcgw = MaterialLaw::pcgw(materialParams, sw);
159 const Scalar pcnw = MaterialLaw::pcnw(materialParams, sw);
160 const Scalar pcgn = MaterialLaw::pcgn(materialParams, sw + sn);
161
162 const Scalar pcAlpha = MaterialLaw::pcAlpha(materialParams, sn);
163 const Scalar pcNW1 = 0.0; // TODO: this should be possible to assign in the problem file
164
165 const Scalar pn = pg- pcAlpha * pcgn - (1.0 - pcAlpha)*(pcgw - pcNW1);
166 const Scalar pw = pn - pcAlpha * pcnw - (1.0 - pcAlpha)*pcNW1;
167
168 fluidState.setPressure(wPhaseIdx, pw);
169 fluidState.setPressure(gPhaseIdx, pg);
170 fluidState.setPressure(nPhaseIdx, pn);
171
172 typename FluidSystem::ParameterCache paramCache;
173 paramCache.updateAll(fluidState);
174
175 for (int phaseIdx = 0; phaseIdx < ParentType::numFluidPhases(); ++phaseIdx)
176 {
177 // compute and set the viscosity
178 const Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
179 fluidState.setViscosity(phaseIdx,mu);
180
181 // compute and set the density
182 const Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
183 fluidState.setDensity(phaseIdx, rho);
184
185 // compute and set the enthalpy
186 const Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
187 fluidState.setEnthalpy(phaseIdx, h);
188 }
189 }
190
194 const FluidState &fluidState() const
195 { return fluidState_; }
196
200 const SolidState &solidState() const
201 { return solidState_; }
202
209 Scalar saturation(const int phaseIdx) const
210 { return fluidState_.saturation(phaseIdx); }
211
218 Scalar density(const int phaseIdx) const
219 { return fluidState_.density(phaseIdx); }
220
227 Scalar pressure(const int phaseIdx) const
228 { return fluidState_.pressure(phaseIdx); }
229
237 Scalar temperature() const
238 { return fluidState_.temperature(/*phaseIdx=*/0); }
239
246 Scalar mobility(const int phaseIdx) const
247 {
248 return mobility_[phaseIdx];
249 }
250
254 Scalar capillaryPressure() const
255 { return fluidState_.capillaryPressure(); }
256
260 Scalar porosity() const
261 { return solidState_.porosity(); }
262
266 const PermeabilityType& permeability() const
267 { return permeability_; }
268
269protected:
272
273
274private:
275 PermeabilityType permeability_;
276 Scalar mobility_[ParentType::numFluidPhases()];
277};
278
279} // end namespace Dumux
280
281#endif
Some templates to wrap the valgrind macros.
Represents all relevant thermodynamic quantities of a multi-phase fluid system assuming immiscibility...
Update the solid volume fractions (inert and reacitve) and set them in the solidstate.
A central place for various physical constants occuring in some equations.
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
bool CheckDefined(const T &value)
Make valgrind complain if the object occupied by an object is undefined.
Definition: valgrind.hh:72
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Contains the quantities which are constant within a finite volume in the three-phase model.
Definition: porousmediumflow/3p/volumevariables.hh:45
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:200
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/3p/volumevariables.hh:266
Scalar saturation(const int phaseIdx) const
Returns the effective saturation of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:209
void completeFluidState(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
Sets complete fluid state.
Definition: porousmediumflow/3p/volumevariables.hh:131
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/3p/volumevariables.hh:73
SolidState solidState_
Definition: porousmediumflow/3p/volumevariables.hh:271
typename Traits::FluidState FluidState
Export fluid state type.
Definition: porousmediumflow/3p/volumevariables.hh:67
Scalar porosity() const
Returns the average porosity within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:260
Scalar mobility(const int phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:246
typename Traits::FluidSystem FluidSystem
Export fluid system type.
Definition: porousmediumflow/3p/volumevariables.hh:69
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/3p/volumevariables.hh:85
const FluidState & fluidState() const
Returns the phase state for the control-volume.
Definition: porousmediumflow/3p/volumevariables.hh:194
FluidState fluidState_
Definition: porousmediumflow/3p/volumevariables.hh:270
Scalar temperature() const
Returns temperature inside the sub-control volume.
Definition: porousmediumflow/3p/volumevariables.hh:237
Scalar density(const int phaseIdx) const
Returns the mass density of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:218
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/3p/volumevariables.hh:71
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:254
Scalar pressure(const int phaseIdx) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:227
Definition: porousmediumflow/nonisothermal/volumevariables.hh:75
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:40
static constexpr int numFluidComponents()
Return number of components considered by the model.
Definition: porousmediumflow/volumevariables.hh:52
const PrimaryVariables & priVars() const
Returns the vector of primary variables.
Definition: porousmediumflow/volumevariables.hh:76
static constexpr int numFluidPhases()
Return number of phases considered by the model.
Definition: porousmediumflow/volumevariables.hh:50
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:64
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.