3.5-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
33
34namespace Dumux {
35
40template <class Traits>
43, public EnergyVolumeVariables<Traits, ThreePVolumeVariables<Traits> >
44{
47
48 using Scalar = typename Traits::PrimaryVariables::value_type;
49 using PermeabilityType = typename Traits::PermeabilityType;
50 using Idx = typename Traits::ModelTraits::Indices;
51 using FS = typename Traits::FluidSystem;
52 static constexpr int numFluidComps = ParentType::numFluidComponents();
53
54 enum {
55 wPhaseIdx = FS::wPhaseIdx,
56 gPhaseIdx = FS::gPhaseIdx,
57 nPhaseIdx = FS::nPhaseIdx,
58
59 swIdx = Idx::swIdx,
60 snIdx = Idx::snIdx,
61 pressureIdx = Idx::pressureIdx
62 };
63
64public:
66 using FluidState = typename Traits::FluidState;
68 using FluidSystem = typename Traits::FluidSystem;
70 using Indices = Idx;
72 using SolidState = typename Traits::SolidState;
74 using SolidSystem = typename Traits::SolidSystem;
75
85 template<class ElemSol, class Problem, class Element, class Scv>
86 void update(const ElemSol &elemSol,
87 const Problem &problem,
88 const Element &element,
89 const Scv& scv)
90 {
91 ParentType::update(elemSol, problem, element, scv);
92 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
93
94 const auto sw = fluidState_.saturation(wPhaseIdx);
95 const auto sn = fluidState_.saturation(nPhaseIdx);
96
97 // mobilities
98 const auto fluidMatrixInteraction = problem.spatialParams().fluidMatrixInteraction(element, scv, elemSol);
99 for (int phaseIdx = 0; phaseIdx < ParentType::numFluidPhases(); ++phaseIdx)
100 {
101 mobility_[phaseIdx] = fluidMatrixInteraction.kr(phaseIdx, sw, sn)
102 / fluidState_.viscosity(phaseIdx);
103 }
104
105 // porosity
106 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
107 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
108 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
109 EnergyVolVars::updateEffectiveThermalConductivity();
110 }
111
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
135 const auto& priVars = elemSol[scv.localDofIndex()];
136
137 const auto fluidMatrixInteraction = problem.spatialParams().fluidMatrixInteraction(element, scv, elemSol);
138
139 const Scalar sw = priVars[swIdx];
140 const Scalar sn = priVars[snIdx];
141 const Scalar sg = 1.0 - sw - sn;
142
143 fluidState.setSaturation(wPhaseIdx, sw);
144 fluidState.setSaturation(gPhaseIdx, sg);
145 fluidState.setSaturation(nPhaseIdx, sn);
146
147 /* now the pressures */
148 const Scalar pg = priVars[pressureIdx];
149
150 // calculate capillary pressures
151 const Scalar pcgw = fluidMatrixInteraction.pcgw(sw, sn);
152 const Scalar pcnw = fluidMatrixInteraction.pcnw(sw, sn);
153 const Scalar pcgn = fluidMatrixInteraction.pcgn(sw, sn);
154
155 const Scalar pcAlpha = fluidMatrixInteraction.pcAlpha(sw, sn);
156 const Scalar pcNW1 = 0.0; // TODO: this should be possible to assign in the problem file
157
158 const Scalar pn = pg- pcAlpha * pcgn - (1.0 - pcAlpha)*(pcgw - pcNW1);
159 const Scalar pw = pn - pcAlpha * pcnw - (1.0 - pcAlpha)*pcNW1;
160
161 fluidState.setPressure(wPhaseIdx, pw);
162 fluidState.setPressure(gPhaseIdx, pg);
163 fluidState.setPressure(nPhaseIdx, pn);
164
165 typename FluidSystem::ParameterCache paramCache;
166 paramCache.updateAll(fluidState);
167
168 for (int phaseIdx = 0; phaseIdx < ParentType::numFluidPhases(); ++phaseIdx)
169 {
170 // compute and set the viscosity
171 const Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
172 fluidState.setViscosity(phaseIdx,mu);
173
174 // compute and set the density
175 const Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
176 fluidState.setDensity(phaseIdx, rho);
177
178 // compute and set the enthalpy
179 const Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
180 fluidState.setEnthalpy(phaseIdx, h);
181 }
182 }
183
187 const FluidState &fluidState() const
188 { return fluidState_; }
189
193 const SolidState &solidState() const
194 { return solidState_; }
195
202 Scalar saturation(const int phaseIdx) const
203 { return fluidState_.saturation(phaseIdx); }
204
211 Scalar density(const int phaseIdx) const
212 { return fluidState_.density(phaseIdx); }
213
220 Scalar pressure(const int phaseIdx) const
221 { return fluidState_.pressure(phaseIdx); }
222
230 Scalar temperature() const
231 { return fluidState_.temperature(/*phaseIdx=*/0); }
232
239 Scalar mobility(const int phaseIdx) const
240 {
241 return mobility_[phaseIdx];
242 }
243
247 Scalar capillaryPressure() const
248 { return fluidState_.capillaryPressure(); }
249
253 Scalar porosity() const
254 { return solidState_.porosity(); }
255
259 const PermeabilityType& permeability() const
260 { return permeability_; }
261
262protected:
265
266
267private:
268 PermeabilityType permeability_;
269 Scalar mobility_[ParentType::numFluidPhases()];
270};
271
272} // end namespace Dumux
273
274#endif
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
Definition: adapt.hh:29
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:44
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:193
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/3p/volumevariables.hh:259
Idx Indices
Export the indices.
Definition: porousmediumflow/3p/volumevariables.hh:70
Scalar saturation(const int phaseIdx) const
Returns the effective saturation of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:202
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:126
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/3p/volumevariables.hh:74
SolidState solidState_
Definition: porousmediumflow/3p/volumevariables.hh:264
typename Traits::FluidState FluidState
Export fluid state type.
Definition: porousmediumflow/3p/volumevariables.hh:66
Scalar porosity() const
Returns the average porosity within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:253
Scalar mobility(const int phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:239
typename Traits::FluidSystem FluidSystem
Export fluid system type.
Definition: porousmediumflow/3p/volumevariables.hh:68
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:86
const FluidState & fluidState() const
Returns the phase state for the control-volume.
Definition: porousmediumflow/3p/volumevariables.hh:187
FluidState fluidState_
Definition: porousmediumflow/3p/volumevariables.hh:263
Scalar temperature() const
Returns temperature inside the sub-control volume.
Definition: porousmediumflow/3p/volumevariables.hh:230
Scalar density(const int phaseIdx) const
Returns the mass density of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:211
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/3p/volumevariables.hh:72
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:247
Scalar pressure(const int phaseIdx) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:220
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
static constexpr int numFluidPhases()
Return number of phases considered by the model.
Definition: porousmediumflow/volumevariables.hh:52
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.