3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/2p/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_2P_VOLUME_VARIABLES_HH
27#define DUMUX_2P_VOLUME_VARIABLES_HH
28
33
34namespace Dumux {
35
41template <class Traits>
44, public EnergyVolumeVariables<Traits, TwoPVolumeVariables<Traits> >
45{
48 using PermeabilityType = typename Traits::PermeabilityType;
49 using ModelTraits = typename Traits::ModelTraits;
50 using Indices = typename ModelTraits::Indices;
51 using Scalar = typename Traits::PrimaryVariables::value_type;
52 using FS = typename Traits::FluidSystem;
53 static constexpr int numFluidComps = ParentType::numFluidComponents();
54 enum
55 {
56 pressureIdx = Indices::pressureIdx,
57 saturationIdx = Indices::saturationIdx,
58
59 phase0Idx = FS::phase0Idx,
60 phase1Idx = FS::phase1Idx
61 };
62
63 static constexpr auto formulation = ModelTraits::priVarFormulation();
64
65public:
67 using FluidSystem = typename Traits::FluidSystem;
69 using FluidState = typename Traits::FluidState;
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 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
93
94 using MaterialLaw = typename Problem::SpatialParams::MaterialLaw;
95 const auto& materialParams = problem.spatialParams().materialLawParams(element, scv, elemSol);
96
97 const int wPhaseIdx = fluidState_.wettingPhase();
98 const int nPhaseIdx = 1 - wPhaseIdx;
99
100 mobility_[wPhaseIdx] =
101 MaterialLaw::krw(materialParams, fluidState_.saturation(wPhaseIdx))
102 / fluidState_.viscosity(wPhaseIdx);
103
104 mobility_[nPhaseIdx] =
105 MaterialLaw::krn(materialParams, fluidState_.saturation(wPhaseIdx))
106 / fluidState_.viscosity(nPhaseIdx);
107
108 // porosity calculation over inert volumefraction
109 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
110 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
111 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
112 EnergyVolVars::updateEffectiveThermalConductivity();
113 }
114
127 template<class ElemSol, class Problem, class Element, class Scv>
128 void completeFluidState(const ElemSol& elemSol,
129 const Problem& problem,
130 const Element& element,
131 const Scv& scv,
134 {
135 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
136
137 using MaterialLaw = typename Problem::SpatialParams::MaterialLaw;
138 const auto& materialParams = problem.spatialParams().materialLawParams(element, scv, elemSol);
139 const auto& priVars = elemSol[scv.localDofIndex()];
140
141 const auto wPhaseIdx = problem.spatialParams().template wettingPhase<FluidSystem>(element, scv, elemSol);
142 fluidState.setWettingPhase(wPhaseIdx);
143 if (formulation == TwoPFormulation::p0s1)
144 {
145 fluidState.setPressure(phase0Idx, priVars[pressureIdx]);
146 if (fluidState.wettingPhase() == phase1Idx)
147 {
148 fluidState.setSaturation(phase1Idx, priVars[saturationIdx]);
149 fluidState.setSaturation(phase0Idx, 1 - priVars[saturationIdx]);
150 pc_ = MaterialLaw::pc(materialParams, fluidState.saturation(wPhaseIdx));
151 fluidState.setPressure(phase1Idx, priVars[pressureIdx] - pc_);
152 }
153 else
154 {
155 const auto Sn = Traits::SaturationReconstruction::reconstructSn(problem.spatialParams(), element,
156 scv, elemSol, priVars[saturationIdx]);
157 fluidState.setSaturation(phase1Idx, Sn);
158 fluidState.setSaturation(phase0Idx, 1 - Sn);
159 pc_ = MaterialLaw::pc(materialParams, fluidState.saturation(wPhaseIdx));
160 fluidState.setPressure(phase1Idx, priVars[pressureIdx] + pc_);
161 }
162 }
163 else if (formulation == TwoPFormulation::p1s0)
164 {
165 fluidState.setPressure(phase1Idx, priVars[pressureIdx]);
166 if (wPhaseIdx == phase1Idx)
167 {
168 const auto Sn = Traits::SaturationReconstruction::reconstructSn(problem.spatialParams(), element,
169 scv, elemSol, priVars[saturationIdx]);
170 fluidState.setSaturation(phase0Idx, Sn);
171 fluidState.setSaturation(phase1Idx, 1 - Sn);
172 pc_ = MaterialLaw::pc(materialParams, fluidState.saturation(wPhaseIdx));
173 fluidState.setPressure(phase0Idx, priVars[pressureIdx] + pc_);
174 }
175 else
176 {
177 fluidState.setSaturation(phase0Idx, priVars[saturationIdx]);
178 fluidState.setSaturation(phase1Idx, 1 - priVars[saturationIdx]);
179 pc_ = MaterialLaw::pc(materialParams, fluidState.saturation(wPhaseIdx));
180 fluidState.setPressure(phase0Idx, priVars[pressureIdx] - pc_);
181 }
182 }
183
184 typename FluidSystem::ParameterCache paramCache;
185 paramCache.updateAll(fluidState);
186
187 for (int phaseIdx = 0; phaseIdx < ModelTraits::numFluidPhases(); ++phaseIdx) {
188 // compute and set the viscosity
189 Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
190 fluidState.setViscosity(phaseIdx, mu);
191
192 // compute and set the density
193 Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
194 fluidState.setDensity(phaseIdx, rho);
195
196 // compute and set the enthalpy
197 Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
198 fluidState.setEnthalpy(phaseIdx, h);
199 }
200 }
201
205 const FluidState &fluidState() const
206 { return fluidState_; }
207
211 const SolidState &solidState() const
212 { return solidState_; }
213
220 Scalar saturation(int phaseIdx) const
221 { return fluidState_.saturation(phaseIdx); }
222
229 Scalar density(int phaseIdx) const
230 { return fluidState_.density(phaseIdx); }
231
238 Scalar pressure(int phaseIdx) const
239 { return fluidState_.pressure(phaseIdx); }
240
245 Scalar capillaryPressure() const
246 { return pc_; }
247
256 Scalar temperature() const
257 { return fluidState_.temperature(/*phaseIdx=*/0); }
258
265 Scalar viscosity(int phaseIdx) const
266 { return fluidState_.viscosity(phaseIdx); }
267
274 Scalar mobility(int phaseIdx) const
275 { return mobility_[phaseIdx]; }
276
280 Scalar porosity() const
281 { return solidState_.porosity(); }
282
286 const PermeabilityType& permeability() const
287 { return permeability_; }
288
292 int wettingPhase() const
293 { return fluidState_.wettingPhase(); }
294
295protected:
298
299private:
300 Scalar pc_;
301 Scalar porosity_;
302 PermeabilityType permeability_;
303 Scalar mobility_[ModelTraits::numFluidPhases()];
304};
305
306} // end namespace Dumux
307
308#endif
Update the solid volume fractions (inert and reacitve) and set them in the solidstate.
Defines an enumeration for the formulations accepted by the two-phase model.
@ p1s0
first phase saturation and second phase pressure as primary variables
@ p0s1
first phase pressure and second phase saturation as primary variables
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 are constant within a finite volume in the two-phase model.
Definition: porousmediumflow/2p/volumevariables.hh:45
Scalar mobility(int phaseIdx) const
Returns the effective mobility of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:274
Scalar density(int phaseIdx) const
Returns the mass density of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:229
int wettingPhase() const
Returns the wetting phase index.
Definition: porousmediumflow/2p/volumevariables.hh:292
typename Traits::FluidSystem FluidSystem
Export type of fluid system.
Definition: porousmediumflow/2p/volumevariables.hh:67
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/2p/volumevariables.hh:85
Scalar capillaryPressure() const
Returns the capillary pressure within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:245
Scalar viscosity(int phaseIdx) const
Returns the dynamic viscosity of the fluid within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:265
void completeFluidState(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
Sets complete fluid state.
Definition: porousmediumflow/2p/volumevariables.hh:128
FluidState fluidState_
Definition: porousmediumflow/2p/volumevariables.hh:296
Scalar porosity() const
Returns the average porosity within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:280
SolidState solidState_
Definition: porousmediumflow/2p/volumevariables.hh:297
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/2p/volumevariables.hh:71
Scalar pressure(int phaseIdx) const
Returns the effective pressure of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:238
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:286
Scalar saturation(int phaseIdx) const
Returns the saturation of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:220
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/2p/volumevariables.hh:211
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/2p/volumevariables.hh:73
typename Traits::FluidState FluidState
Export type of fluid state.
Definition: porousmediumflow/2p/volumevariables.hh:69
const FluidState & fluidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/2p/volumevariables.hh:205
Scalar temperature() const
Returns temperature inside the sub-control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:256
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
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.