3.3.0
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
35
36namespace Dumux {
37
42template <class Traits>
45, public EnergyVolumeVariables<Traits, ThreePVolumeVariables<Traits> >
46{
49
50 using Scalar = typename Traits::PrimaryVariables::value_type;
51 using PermeabilityType = typename Traits::PermeabilityType;
52 using Idx = typename Traits::ModelTraits::Indices;
53 using FS = typename Traits::FluidSystem;
54 static constexpr int numFluidComps = ParentType::numFluidComponents();
55
56 enum {
57 wPhaseIdx = FS::wPhaseIdx,
58 gPhaseIdx = FS::gPhaseIdx,
59 nPhaseIdx = FS::nPhaseIdx,
60
61 swIdx = Idx::swIdx,
62 snIdx = Idx::snIdx,
63 pressureIdx = Idx::pressureIdx
64 };
65
66public:
68 using FluidState = typename Traits::FluidState;
70 using FluidSystem = typename Traits::FluidSystem;
72 using Indices = Idx;
74 using SolidState = typename Traits::SolidState;
76 using SolidSystem = typename Traits::SolidSystem;
77
87 template<class ElemSol, class Problem, class Element, class Scv>
88 void update(const ElemSol &elemSol,
89 const Problem &problem,
90 const Element &element,
91 const Scv& scv)
92 {
93 ParentType::update(elemSol, problem, element, scv);
94 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
95
96 // old material law interface is deprecated: Replace this by
97 // const auto fluidMatrixInteraction = problem.spatialParams().fluidMatrixInteraction(element, scv, elemSol);
98 // after the release of 3.3, when the deprecated interface is no longer supported
99 const auto fluidMatrixInteraction = Deprecated::makePcKrSw<3>(Scalar{}, problem.spatialParams(), element, scv, elemSol);
100
101 const auto sw = fluidState_.saturation(wPhaseIdx);
102 const auto sn = fluidState_.saturation(nPhaseIdx);
103
104 // mobilities
105 for (int phaseIdx = 0; phaseIdx < ParentType::numFluidPhases(); ++phaseIdx)
106 {
107 mobility_[phaseIdx] = fluidMatrixInteraction.kr(phaseIdx, sw, sn)
108 / fluidState_.viscosity(phaseIdx);
109 }
110
111 // porosity
112 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
113 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
114 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
115 EnergyVolVars::updateEffectiveThermalConductivity();
116 }
117
131 template<class ElemSol, class Problem, class Element, class Scv>
132 void completeFluidState(const ElemSol& elemSol,
133 const Problem& problem,
134 const Element& element,
135 const Scv& scv,
138 {
139 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
140
141 const auto& priVars = elemSol[scv.localDofIndex()];
142
143 // old material law interface is deprecated: Replace this by
144 // const auto fluidMatrixInteraction = problem.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<3>(Scalar{}, problem.spatialParams(), element, scv, elemSol);
147
148 const Scalar sw = priVars[swIdx];
149 const Scalar sn = priVars[snIdx];
150 const Scalar sg = 1.0 - sw - sn;
151
152 fluidState.setSaturation(wPhaseIdx, sw);
153 fluidState.setSaturation(gPhaseIdx, sg);
154 fluidState.setSaturation(nPhaseIdx, sn);
155
156 /* now the pressures */
157 const Scalar pg = priVars[pressureIdx];
158
159 // calculate capillary pressures
160 const Scalar pcgw = fluidMatrixInteraction.pcgw(sw, sn);
161 const Scalar pcnw = fluidMatrixInteraction.pcnw(sw, sn);
162 const Scalar pcgn = fluidMatrixInteraction.pcgn(sw, sn);
163
164 const Scalar pcAlpha = fluidMatrixInteraction.pcAlpha(sw, sn);
165 const Scalar pcNW1 = 0.0; // TODO: this should be possible to assign in the problem file
166
167 const Scalar pn = pg- pcAlpha * pcgn - (1.0 - pcAlpha)*(pcgw - pcNW1);
168 const Scalar pw = pn - pcAlpha * pcnw - (1.0 - pcAlpha)*pcNW1;
169
170 fluidState.setPressure(wPhaseIdx, pw);
171 fluidState.setPressure(gPhaseIdx, pg);
172 fluidState.setPressure(nPhaseIdx, pn);
173
174 typename FluidSystem::ParameterCache paramCache;
175 paramCache.updateAll(fluidState);
176
177 for (int phaseIdx = 0; phaseIdx < ParentType::numFluidPhases(); ++phaseIdx)
178 {
179 // compute and set the viscosity
180 const Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
181 fluidState.setViscosity(phaseIdx,mu);
182
183 // compute and set the density
184 const Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
185 fluidState.setDensity(phaseIdx, rho);
186
187 // compute and set the enthalpy
188 const 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(const int phaseIdx) const
212 { return fluidState_.saturation(phaseIdx); }
213
220 Scalar density(const int phaseIdx) const
221 { return fluidState_.density(phaseIdx); }
222
229 Scalar pressure(const int phaseIdx) const
230 { return fluidState_.pressure(phaseIdx); }
231
239 Scalar temperature() const
240 { return fluidState_.temperature(/*phaseIdx=*/0); }
241
248 Scalar mobility(const int phaseIdx) const
249 {
250 return mobility_[phaseIdx];
251 }
252
256 Scalar capillaryPressure() const
257 { return fluidState_.capillaryPressure(); }
258
262 Scalar porosity() const
263 { return solidState_.porosity(); }
264
268 const PermeabilityType& permeability() const
269 { return permeability_; }
270
271protected:
274
275
276private:
277 PermeabilityType permeability_;
278 Scalar mobility_[ParentType::numFluidPhases()];
279};
280
281} // end namespace Dumux
282
283#endif
Helpers for deprecation.
A central place for various physical constants occuring in some equations.
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.
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:46
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:202
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/3p/volumevariables.hh:268
Idx Indices
Export the indices.
Definition: porousmediumflow/3p/volumevariables.hh:72
Scalar saturation(const int phaseIdx) const
Returns the effective saturation of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:211
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:132
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/3p/volumevariables.hh:76
SolidState solidState_
Definition: porousmediumflow/3p/volumevariables.hh:273
typename Traits::FluidState FluidState
Export fluid state type.
Definition: porousmediumflow/3p/volumevariables.hh:68
Scalar porosity() const
Returns the average porosity within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:262
Scalar mobility(const int phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:248
typename Traits::FluidSystem FluidSystem
Export fluid system type.
Definition: porousmediumflow/3p/volumevariables.hh:70
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:88
const FluidState & fluidState() const
Returns the phase state for the control-volume.
Definition: porousmediumflow/3p/volumevariables.hh:196
FluidState fluidState_
Definition: porousmediumflow/3p/volumevariables.hh:272
Scalar temperature() const
Returns temperature inside the sub-control volume.
Definition: porousmediumflow/3p/volumevariables.hh:239
Scalar density(const int phaseIdx) const
Returns the mass density of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:220
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/3p/volumevariables.hh:74
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:256
Scalar pressure(const int phaseIdx) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:229
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
static constexpr int numFluidPhases()
Return number of phases considered by the model.
Definition: porousmediumflow/volumevariables.hh:50
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.