version 3.10-dev
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
14#ifndef DUMUX_2P_VOLUME_VARIABLES_HH
15#define DUMUX_2P_VOLUME_VARIABLES_HH
16
21
22namespace Dumux {
23
29template <class Traits>
32, public EnergyVolumeVariables<Traits, TwoPVolumeVariables<Traits> >
33{
36 using PermeabilityType = typename Traits::PermeabilityType;
37 using ModelTraits = typename Traits::ModelTraits;
38 using Idx = typename ModelTraits::Indices;
39 using Scalar = typename Traits::PrimaryVariables::value_type;
40 using FS = typename Traits::FluidSystem;
41 static constexpr int numFluidComps = ParentType::numFluidComponents();
42 enum
43 {
44 pressureIdx = Idx::pressureIdx,
45 saturationIdx = Idx::saturationIdx,
46
47 phase0Idx = FS::phase0Idx,
48 phase1Idx = FS::phase1Idx
49 };
50
51 static constexpr auto formulation = ModelTraits::priVarFormulation();
52
53public:
55 using FluidSystem = typename Traits::FluidSystem;
57 using FluidState = typename Traits::FluidState;
59 using Indices = typename ModelTraits::Indices;
61 using SolidState = typename Traits::SolidState;
63 using SolidSystem = typename Traits::SolidSystem;
64
74 template<class ElemSol, class Problem, class Element, class Scv>
75 void update(const ElemSol &elemSol,
76 const Problem &problem,
77 const Element &element,
78 const Scv& scv)
79 {
80 ParentType::update(elemSol, problem, element, scv);
81
82 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
83
84 const auto& spatialParams = problem.spatialParams();
85 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
86
87 const int wPhaseIdx = fluidState_.wettingPhase();
88 const int nPhaseIdx = 1 - wPhaseIdx;
89
90 mobility_[wPhaseIdx] =
91 fluidMatrixInteraction.krw(fluidState_.saturation(wPhaseIdx))
92 / fluidState_.viscosity(wPhaseIdx);
93
94 mobility_[nPhaseIdx] =
95 fluidMatrixInteraction.krn(fluidState_.saturation(wPhaseIdx))
96 / fluidState_.viscosity(nPhaseIdx);
97
98 // porosity calculation over inert volumefraction
99 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
100 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
101 permeability_ = spatialParams.permeability(element, scv, elemSol);
102 EnergyVolVars::updateEffectiveThermalConductivity();
103 }
104
117 template<class ElemSol, class Problem, class Element, class Scv>
118 void completeFluidState(const ElemSol& elemSol,
119 const Problem& problem,
120 const Element& element,
121 const Scv& scv,
124 {
125 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
126
127 const auto& spatialParams = problem.spatialParams();
128 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
129
130 const auto& priVars = elemSol[scv.localDofIndex()];
131
132 const auto wPhaseIdx = spatialParams.template wettingPhase<FluidSystem>(element, scv, elemSol);
133 fluidState.setWettingPhase(wPhaseIdx);
134 if (formulation == TwoPFormulation::p0s1)
135 {
136 fluidState.setPressure(phase0Idx, priVars[pressureIdx]);
137 if (fluidState.wettingPhase() == phase1Idx)
138 {
139 fluidState.setSaturation(phase1Idx, priVars[saturationIdx]);
140 fluidState.setSaturation(phase0Idx, 1 - priVars[saturationIdx]);
141 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
142 fluidState.setPressure(phase1Idx, priVars[pressureIdx] - pc_);
143 }
144 else
145 {
146 const auto Sn = Traits::SaturationReconstruction::reconstructSn(spatialParams, element,
147 scv, elemSol, priVars[saturationIdx]);
148 fluidState.setSaturation(phase1Idx, Sn);
149 fluidState.setSaturation(phase0Idx, 1 - Sn);
150 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
151 fluidState.setPressure(phase1Idx, priVars[pressureIdx] + pc_);
152 }
153 }
154 else if (formulation == TwoPFormulation::p1s0)
155 {
156 fluidState.setPressure(phase1Idx, priVars[pressureIdx]);
157 if (wPhaseIdx == phase1Idx)
158 {
159 const auto Sn = Traits::SaturationReconstruction::reconstructSn(spatialParams, element,
160 scv, elemSol, priVars[saturationIdx]);
161 fluidState.setSaturation(phase0Idx, Sn);
162 fluidState.setSaturation(phase1Idx, 1 - Sn);
163 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
164 fluidState.setPressure(phase0Idx, priVars[pressureIdx] + pc_);
165 }
166 else
167 {
168 fluidState.setSaturation(phase0Idx, priVars[saturationIdx]);
169 fluidState.setSaturation(phase1Idx, 1 - priVars[saturationIdx]);
170 pc_ = fluidMatrixInteraction.pc(fluidState.saturation(wPhaseIdx));
171 fluidState.setPressure(phase0Idx, priVars[pressureIdx] - pc_);
172 }
173 }
174
175 typename FluidSystem::ParameterCache paramCache;
176 paramCache.updateAll(fluidState);
177
178 for (int phaseIdx = 0; phaseIdx < ModelTraits::numFluidPhases(); ++phaseIdx) {
179 // compute and set the viscosity
180 Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
181 fluidState.setViscosity(phaseIdx, mu);
182
183 // compute and set the density
184 Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
185 fluidState.setDensity(phaseIdx, rho);
186
187 // compute and set the enthalpy
188 Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
189 fluidState.setEnthalpy(phaseIdx, h);
190 }
191 }
192
196 const FluidState &fluidState() const
197 { return fluidState_; }
198
202 const SolidState &solidState() const
203 { return solidState_; }
204
211 Scalar saturation(int phaseIdx) const
212 { return fluidState_.saturation(phaseIdx); }
213
220 Scalar density(int phaseIdx) const
221 { return fluidState_.density(phaseIdx); }
222
229 Scalar pressure(int phaseIdx) const
230 { return fluidState_.pressure(phaseIdx); }
231
236 Scalar capillaryPressure() const
237 { return pc_; }
238
247 Scalar temperature() const
248 { return fluidState_.temperature(/*phaseIdx=*/0); }
249
256 Scalar viscosity(int phaseIdx) const
257 { return fluidState_.viscosity(phaseIdx); }
258
265 Scalar mobility(int phaseIdx) const
266 { return mobility_[phaseIdx]; }
267
271 Scalar porosity() const
272 { return solidState_.porosity(); }
273
277 const PermeabilityType& permeability() const
278 { return permeability_; }
279
283 int wettingPhase() const
284 { return fluidState_.wettingPhase(); }
285
286protected:
289
290private:
291 Scalar pc_;
292 Scalar porosity_;
293 PermeabilityType permeability_;
294 Scalar mobility_[ModelTraits::numFluidPhases()];
295};
296
297} // end namespace Dumux
298
299#endif
Definition: porousmediumflow/nonisothermal/volumevariables.hh:63
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:28
static constexpr int numFluidComponents()
Return number of components considered by the model.
Definition: porousmediumflow/volumevariables.hh:40
const PrimaryVariables & priVars() const
Returns the vector of primary variables.
Definition: porousmediumflow/volumevariables.hh:64
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:52
Contains the quantities which are are constant within a finite volume in the two-phase model.
Definition: porousmediumflow/2p/volumevariables.hh:33
typename ModelTraits::Indices Indices
Export the indices.
Definition: porousmediumflow/2p/volumevariables.hh:59
Scalar mobility(int phaseIdx) const
Returns the effective mobility of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:265
Scalar density(int phaseIdx) const
Returns the mass density of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:220
int wettingPhase() const
Returns the wetting phase index.
Definition: porousmediumflow/2p/volumevariables.hh:283
typename Traits::FluidSystem FluidSystem
Export type of fluid system.
Definition: porousmediumflow/2p/volumevariables.hh:55
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:75
Scalar capillaryPressure() const
Returns the capillary pressure within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:236
Scalar viscosity(int phaseIdx) const
Returns the dynamic viscosity of the fluid within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:256
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:118
FluidState fluidState_
Definition: porousmediumflow/2p/volumevariables.hh:287
Scalar porosity() const
Returns the average porosity within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:271
SolidState solidState_
Definition: porousmediumflow/2p/volumevariables.hh:288
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/2p/volumevariables.hh:61
Scalar pressure(int phaseIdx) const
Returns the effective pressure of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:229
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:277
Scalar saturation(int phaseIdx) const
Returns the saturation of a given phase within the control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:211
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/2p/volumevariables.hh:202
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/2p/volumevariables.hh:63
typename Traits::FluidState FluidState
Export type of fluid state.
Definition: porousmediumflow/2p/volumevariables.hh:57
const FluidState & fluidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/2p/volumevariables.hh:196
Scalar temperature() const
Returns temperature inside the sub-control volume in .
Definition: porousmediumflow/2p/volumevariables.hh:247
Defines an enumeration for the formulations accepted by the two-phase model.
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:24
@ p1s0
first phase saturation and second phase pressure as primary variables
@ p0s1
first phase pressure and second phase saturation as primary variables
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:62
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Definition: adapt.hh:17
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.
Update the solid volume fractions (inert and reacitve) and set them in the solidstate.