3.3.0
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
35
36namespace Dumux {
37
43template <class Traits>
46, public EnergyVolumeVariables<Traits, TwoPVolumeVariables<Traits> >
47{
50 using PermeabilityType = typename Traits::PermeabilityType;
51 using ModelTraits = typename Traits::ModelTraits;
52 using Idx = typename ModelTraits::Indices;
53 using Scalar = typename Traits::PrimaryVariables::value_type;
54 using FS = typename Traits::FluidSystem;
55 static constexpr int numFluidComps = ParentType::numFluidComponents();
56 enum
57 {
58 pressureIdx = Idx::pressureIdx,
59 saturationIdx = Idx::saturationIdx,
60
61 phase0Idx = FS::phase0Idx,
62 phase1Idx = FS::phase1Idx
63 };
64
65 static constexpr auto formulation = ModelTraits::priVarFormulation();
66
67public:
69 using FluidSystem = typename Traits::FluidSystem;
71 using FluidState = typename Traits::FluidState;
73 using Indices = typename ModelTraits::Indices;
75 using SolidState = typename Traits::SolidState;
77 using SolidSystem = typename Traits::SolidSystem;
78
88 template<class ElemSol, class Problem, class Element, class Scv>
89 void update(const ElemSol &elemSol,
90 const Problem &problem,
91 const Element &element,
92 const Scv& scv)
93 {
94 ParentType::update(elemSol, problem, element, scv);
95
96 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
97
98 // old material law interface is deprecated: Replace this by
99 // const auto& fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
100 // after the release of 3.3, when the deprecated interface is no longer supported
101 const auto fluidMatrixInteraction = Deprecated::makePcKrSw(Scalar{}, problem.spatialParams(), element, scv, elemSol);
102
103 const int wPhaseIdx = fluidState_.wettingPhase();
104 const int nPhaseIdx = 1 - wPhaseIdx;
105
106 mobility_[wPhaseIdx] =
107 fluidMatrixInteraction.krw(fluidState_.saturation(wPhaseIdx))
108 / fluidState_.viscosity(wPhaseIdx);
109
110 mobility_[nPhaseIdx] =
111 fluidMatrixInteraction.krn(fluidState_.saturation(wPhaseIdx))
112 / fluidState_.viscosity(nPhaseIdx);
113
114 // porosity calculation over inert volumefraction
115 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
116 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
117 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
118 EnergyVolVars::updateEffectiveThermalConductivity();
119 }
120
133 template<class ElemSol, class Problem, class Element, class Scv>
134 void completeFluidState(const ElemSol& elemSol,
135 const Problem& problem,
136 const Element& element,
137 const Scv& scv,
140 {
141 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
142
143 // old material law interface is deprecated: Replace this by
144 // const auto& fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
145 // after the release of 3.3, when the deprecated interface is no longer supported
146 const auto fluidMatrixInteraction = Deprecated::makePcKrSw(Scalar{}, problem.spatialParams(), element, scv, elemSol);
147
148 const auto& priVars = elemSol[scv.localDofIndex()];
149
150 const auto wPhaseIdx = problem.spatialParams().template wettingPhase<FluidSystem>(element, scv, elemSol);
151 fluidState.setWettingPhase(wPhaseIdx);
152 if (formulation == TwoPFormulation::p0s1)
153 {
154 fluidState.setPressure(phase0Idx, priVars[pressureIdx]);
155 if (fluidState.wettingPhase() == phase1Idx)
156 {
157 fluidState.setSaturation(phase1Idx, priVars[saturationIdx]);
158 fluidState.setSaturation(phase0Idx, 1 - priVars[saturationIdx]);
159 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
160 fluidState.setPressure(phase1Idx, priVars[pressureIdx] - pc_);
161 }
162 else
163 {
164 const auto Sn = Traits::SaturationReconstruction::reconstructSn(problem.spatialParams(), element,
165 scv, elemSol, priVars[saturationIdx]);
166 fluidState.setSaturation(phase1Idx, Sn);
167 fluidState.setSaturation(phase0Idx, 1 - Sn);
168 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
169 fluidState.setPressure(phase1Idx, priVars[pressureIdx] + pc_);
170 }
171 }
172 else if (formulation == TwoPFormulation::p1s0)
173 {
174 fluidState.setPressure(phase1Idx, priVars[pressureIdx]);
175 if (wPhaseIdx == phase1Idx)
176 {
177 const auto Sn = Traits::SaturationReconstruction::reconstructSn(problem.spatialParams(), element,
178 scv, elemSol, priVars[saturationIdx]);
179 fluidState.setSaturation(phase0Idx, Sn);
180 fluidState.setSaturation(phase1Idx, 1 - Sn);
181 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
182 fluidState.setPressure(phase0Idx, priVars[pressureIdx] + pc_);
183 }
184 else
185 {
186 fluidState.setSaturation(phase0Idx, priVars[saturationIdx]);
187 fluidState.setSaturation(phase1Idx, 1 - priVars[saturationIdx]);
188 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
189 fluidState.setPressure(phase0Idx, priVars[pressureIdx] - pc_);
190 }
191 }
192
193 typename FluidSystem::ParameterCache paramCache;
194 paramCache.updateAll(fluidState);
195
196 for (int phaseIdx = 0; phaseIdx < ModelTraits::numFluidPhases(); ++phaseIdx) {
197 // compute and set the viscosity
198 Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
199 fluidState.setViscosity(phaseIdx, mu);
200
201 // compute and set the density
202 Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
203 fluidState.setDensity(phaseIdx, rho);
204
205 // compute and set the enthalpy
206 Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
207 fluidState.setEnthalpy(phaseIdx, h);
208 }
209 }
210
214 const FluidState &fluidState() const
215 { return fluidState_; }
216
220 const SolidState &solidState() const
221 { return solidState_; }
222
229 Scalar saturation(int phaseIdx) const
230 { return fluidState_.saturation(phaseIdx); }
231
238 Scalar density(int phaseIdx) const
239 { return fluidState_.density(phaseIdx); }
240
247 Scalar pressure(int phaseIdx) const
248 { return fluidState_.pressure(phaseIdx); }
249
254 Scalar capillaryPressure() const
255 { return pc_; }
256
265 Scalar temperature() const
266 { return fluidState_.temperature(/*phaseIdx=*/0); }
267
274 Scalar viscosity(int phaseIdx) const
275 { return fluidState_.viscosity(phaseIdx); }
276
283 Scalar mobility(int phaseIdx) const
284 { return mobility_[phaseIdx]; }
285
289 Scalar porosity() const
290 { return solidState_.porosity(); }
291
295 const PermeabilityType& permeability() const
296 { return permeability_; }
297
301 int wettingPhase() const
302 { return fluidState_.wettingPhase(); }
303
304protected:
307
308private:
309 Scalar pc_;
310 Scalar porosity_;
311 PermeabilityType permeability_;
312 Scalar mobility_[ModelTraits::numFluidPhases()];
313};
314
315} // end namespace Dumux
316
317#endif
Helpers for deprecation.
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:47
typename ModelTraits::Indices Indices
Export the indices.
Definition: porousmediumflow/2p/volumevariables.hh:73
Scalar mobility(int phaseIdx) const
Returns the effective mobility of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:283
Scalar density(int phaseIdx) const
Returns the mass density of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:238
int wettingPhase() const
Returns the wetting phase index.
Definition: porousmediumflow/2p/volumevariables.hh:301
typename Traits::FluidSystem FluidSystem
Export type of fluid system.
Definition: porousmediumflow/2p/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/2p/volumevariables.hh:89
Scalar capillaryPressure() const
Returns the capillary pressure within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:254
Scalar viscosity(int phaseIdx) const
Returns the dynamic viscosity of the fluid within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:274
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:134
FluidState fluidState_
Definition: porousmediumflow/2p/volumevariables.hh:305
Scalar porosity() const
Returns the average porosity within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:289
SolidState solidState_
Definition: porousmediumflow/2p/volumevariables.hh:306
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/2p/volumevariables.hh:75
Scalar pressure(int phaseIdx) const
Returns the effective pressure of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:247
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:295
Scalar saturation(int phaseIdx) const
Returns the saturation of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:229
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/2p/volumevariables.hh:220
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/2p/volumevariables.hh:77
typename Traits::FluidState FluidState
Export type of fluid state.
Definition: porousmediumflow/2p/volumevariables.hh:71
const FluidState & fluidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/2p/volumevariables.hh:214
Scalar temperature() const
Returns temperature inside the sub-control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:265
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.