3.5-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 Idx = 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 = Idx::pressureIdx,
57 saturationIdx = Idx::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 Indices = typename ModelTraits::Indices;
73 using SolidState = typename Traits::SolidState;
75 using SolidSystem = typename Traits::SolidSystem;
76
86 template<class ElemSol, class Problem, class Element, class Scv>
87 void update(const ElemSol &elemSol,
88 const Problem &problem,
89 const Element &element,
90 const Scv& scv)
91 {
92 ParentType::update(elemSol, problem, element, scv);
93
94 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
95
96 const auto& spatialParams = problem.spatialParams();
97 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
98
99 const int wPhaseIdx = fluidState_.wettingPhase();
100 const int nPhaseIdx = 1 - wPhaseIdx;
101
102 mobility_[wPhaseIdx] =
103 fluidMatrixInteraction.krw(fluidState_.saturation(wPhaseIdx))
104 / fluidState_.viscosity(wPhaseIdx);
105
106 mobility_[nPhaseIdx] =
107 fluidMatrixInteraction.krn(fluidState_.saturation(wPhaseIdx))
108 / fluidState_.viscosity(nPhaseIdx);
109
110 // porosity calculation over inert volumefraction
111 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
112 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
113 permeability_ = spatialParams.permeability(element, scv, elemSol);
114 EnergyVolVars::updateEffectiveThermalConductivity();
115 }
116
129 template<class ElemSol, class Problem, class Element, class Scv>
130 void completeFluidState(const ElemSol& elemSol,
131 const Problem& problem,
132 const Element& element,
133 const Scv& scv,
136 {
137 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
138
139 const auto& spatialParams = problem.spatialParams();
140 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
141
142 const auto& priVars = elemSol[scv.localDofIndex()];
143
144 const auto wPhaseIdx = spatialParams.template wettingPhase<FluidSystem>(element, scv, elemSol);
145 fluidState.setWettingPhase(wPhaseIdx);
146 if (formulation == TwoPFormulation::p0s1)
147 {
148 fluidState.setPressure(phase0Idx, priVars[pressureIdx]);
149 if (fluidState.wettingPhase() == phase1Idx)
150 {
151 fluidState.setSaturation(phase1Idx, priVars[saturationIdx]);
152 fluidState.setSaturation(phase0Idx, 1 - priVars[saturationIdx]);
153 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
154 fluidState.setPressure(phase1Idx, priVars[pressureIdx] - pc_);
155 }
156 else
157 {
158 const auto Sn = Traits::SaturationReconstruction::reconstructSn(spatialParams, element,
159 scv, elemSol, priVars[saturationIdx]);
160 fluidState.setSaturation(phase1Idx, Sn);
161 fluidState.setSaturation(phase0Idx, 1 - Sn);
162 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
163 fluidState.setPressure(phase1Idx, priVars[pressureIdx] + pc_);
164 }
165 }
166 else if (formulation == TwoPFormulation::p1s0)
167 {
168 fluidState.setPressure(phase1Idx, priVars[pressureIdx]);
169 if (wPhaseIdx == phase1Idx)
170 {
171 const auto Sn = Traits::SaturationReconstruction::reconstructSn(spatialParams, element,
172 scv, elemSol, priVars[saturationIdx]);
173 fluidState.setSaturation(phase0Idx, Sn);
174 fluidState.setSaturation(phase1Idx, 1 - Sn);
175 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
176 fluidState.setPressure(phase0Idx, priVars[pressureIdx] + pc_);
177 }
178 else
179 {
180 fluidState.setSaturation(phase0Idx, priVars[saturationIdx]);
181 fluidState.setSaturation(phase1Idx, 1 - priVars[saturationIdx]);
182 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
183 fluidState.setPressure(phase0Idx, priVars[pressureIdx] - pc_);
184 }
185 }
186
187 typename FluidSystem::ParameterCache paramCache;
188 paramCache.updateAll(fluidState);
189
190 for (int phaseIdx = 0; phaseIdx < ModelTraits::numFluidPhases(); ++phaseIdx) {
191 // compute and set the viscosity
192 Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
193 fluidState.setViscosity(phaseIdx, mu);
194
195 // compute and set the density
196 Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
197 fluidState.setDensity(phaseIdx, rho);
198
199 // compute and set the enthalpy
200 Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
201 fluidState.setEnthalpy(phaseIdx, h);
202 }
203 }
204
208 const FluidState &fluidState() const
209 { return fluidState_; }
210
214 const SolidState &solidState() const
215 { return solidState_; }
216
223 Scalar saturation(int phaseIdx) const
224 { return fluidState_.saturation(phaseIdx); }
225
232 Scalar density(int phaseIdx) const
233 { return fluidState_.density(phaseIdx); }
234
241 Scalar pressure(int phaseIdx) const
242 { return fluidState_.pressure(phaseIdx); }
243
248 Scalar capillaryPressure() const
249 { return pc_; }
250
259 Scalar temperature() const
260 { return fluidState_.temperature(/*phaseIdx=*/0); }
261
268 Scalar viscosity(int phaseIdx) const
269 { return fluidState_.viscosity(phaseIdx); }
270
277 Scalar mobility(int phaseIdx) const
278 { return mobility_[phaseIdx]; }
279
283 Scalar porosity() const
284 { return solidState_.porosity(); }
285
289 const PermeabilityType& permeability() const
290 { return permeability_; }
291
295 int wettingPhase() const
296 { return fluidState_.wettingPhase(); }
297
298protected:
301
302private:
303 Scalar pc_;
304 Scalar porosity_;
305 PermeabilityType permeability_;
306 Scalar mobility_[ModelTraits::numFluidPhases()];
307};
308
309} // end namespace Dumux
310
311#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
typename ModelTraits::Indices Indices
Export the indices.
Definition: porousmediumflow/2p/volumevariables.hh:71
Scalar mobility(int phaseIdx) const
Returns the effective mobility of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:277
Scalar density(int phaseIdx) const
Returns the mass density of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:232
int wettingPhase() const
Returns the wetting phase index.
Definition: porousmediumflow/2p/volumevariables.hh:295
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:87
Scalar capillaryPressure() const
Returns the capillary pressure within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:248
Scalar viscosity(int phaseIdx) const
Returns the dynamic viscosity of the fluid within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:268
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:130
FluidState fluidState_
Definition: porousmediumflow/2p/volumevariables.hh:299
Scalar porosity() const
Returns the average porosity within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:283
SolidState solidState_
Definition: porousmediumflow/2p/volumevariables.hh:300
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/2p/volumevariables.hh:73
Scalar pressure(int phaseIdx) const
Returns the effective pressure of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:241
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:289
Scalar saturation(int phaseIdx) const
Returns the saturation of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:223
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/2p/volumevariables.hh:214
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/2p/volumevariables.hh:75
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:208
Scalar temperature() const
Returns temperature inside the sub-control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:259
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.