version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
13#ifndef DUMUX_3P_VOLUME_VARIABLES_HH
14#define DUMUX_3P_VOLUME_VARIABLES_HH
15
21
22namespace Dumux {
23
28template <class Traits>
31, public EnergyVolumeVariables<Traits, ThreePVolumeVariables<Traits> >
32{
35
36 using Scalar = typename Traits::PrimaryVariables::value_type;
37 using PermeabilityType = typename Traits::PermeabilityType;
38 using Idx = typename Traits::ModelTraits::Indices;
39 using FS = typename Traits::FluidSystem;
40 static constexpr int numFluidComps = ParentType::numFluidComponents();
41
42 enum {
43 wPhaseIdx = FS::wPhaseIdx,
44 gPhaseIdx = FS::gPhaseIdx,
45 nPhaseIdx = FS::nPhaseIdx,
46
47 swIdx = Idx::swIdx,
48 snIdx = Idx::snIdx,
49 pressureIdx = Idx::pressureIdx
50 };
51
52public:
54 using FluidState = typename Traits::FluidState;
56 using FluidSystem = typename Traits::FluidSystem;
58 using Indices = Idx;
60 using SolidState = typename Traits::SolidState;
62 using SolidSystem = typename Traits::SolidSystem;
63
73 template<class ElemSol, class Problem, class Element, class Scv>
74 void update(const ElemSol &elemSol,
75 const Problem &problem,
76 const Element &element,
77 const Scv& scv)
78 {
79 ParentType::update(elemSol, problem, element, scv);
80 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
81
82 const auto sw = fluidState_.saturation(wPhaseIdx);
83 const auto sn = fluidState_.saturation(nPhaseIdx);
84
85 // mobilities
86 const auto fluidMatrixInteraction = problem.spatialParams().fluidMatrixInteraction(element, scv, elemSol);
87 for (int phaseIdx = 0; phaseIdx < ParentType::numFluidPhases(); ++phaseIdx)
88 {
89 mobility_[phaseIdx] = fluidMatrixInteraction.kr(phaseIdx, sw, sn)
90 / fluidState_.viscosity(phaseIdx);
91 }
92
93 // porosity
94 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
95 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
96 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
97 EnergyVolVars::updateEffectiveThermalConductivity();
98 }
99
113 template<class ElemSol, class Problem, class Element, class Scv>
114 void completeFluidState(const ElemSol& elemSol,
115 const Problem& problem,
116 const Element& element,
117 const Scv& scv,
120 {
121 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
122
123 const auto& priVars = elemSol[scv.localDofIndex()];
124
125 const auto fluidMatrixInteraction = problem.spatialParams().fluidMatrixInteraction(element, scv, elemSol);
126
127 const Scalar sw = priVars[swIdx];
128 const Scalar sn = priVars[snIdx];
129 const Scalar sg = 1.0 - sw - sn;
130
131 fluidState.setSaturation(wPhaseIdx, sw);
132 fluidState.setSaturation(gPhaseIdx, sg);
133 fluidState.setSaturation(nPhaseIdx, sn);
134
135 /* now the pressures */
136 const Scalar pg = priVars[pressureIdx];
137
138 // calculate capillary pressures
139 const Scalar pcgw = fluidMatrixInteraction.pcgw(sw, sn);
140 const Scalar pcnw = fluidMatrixInteraction.pcnw(sw, sn);
141 const Scalar pcgn = fluidMatrixInteraction.pcgn(sw, sn);
142
143 const Scalar pcAlpha = fluidMatrixInteraction.pcAlpha(sw, sn);
144 const Scalar pcNW1 = 0.0; // TODO: this should be possible to assign in the problem file
145
146 const Scalar pn = pg- pcAlpha * pcgn - (1.0 - pcAlpha)*(pcgw - pcNW1);
147 const Scalar pw = pn - pcAlpha * pcnw - (1.0 - pcAlpha)*pcNW1;
148
149 fluidState.setPressure(wPhaseIdx, pw);
150 fluidState.setPressure(gPhaseIdx, pg);
151 fluidState.setPressure(nPhaseIdx, pn);
152
153 typename FluidSystem::ParameterCache paramCache;
154 paramCache.updateAll(fluidState);
155
156 for (int phaseIdx = 0; phaseIdx < ParentType::numFluidPhases(); ++phaseIdx)
157 {
158 // compute and set the viscosity
159 const Scalar mu = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
160 fluidState.setViscosity(phaseIdx,mu);
161
162 // compute and set the density
163 const Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
164 fluidState.setDensity(phaseIdx, rho);
165
166 // compute and set the enthalpy
167 const Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, phaseIdx);
168 fluidState.setEnthalpy(phaseIdx, h);
169 }
170 }
171
175 const FluidState &fluidState() const
176 { return fluidState_; }
177
181 const SolidState &solidState() const
182 { return solidState_; }
183
190 Scalar saturation(const int phaseIdx) const
191 { return fluidState_.saturation(phaseIdx); }
192
199 Scalar density(const int phaseIdx) const
200 { return fluidState_.density(phaseIdx); }
201
208 Scalar pressure(const int phaseIdx) const
209 { return fluidState_.pressure(phaseIdx); }
210
218 Scalar temperature() const
219 { return fluidState_.temperature(/*phaseIdx=*/0); }
220
227 Scalar mobility(const int phaseIdx) const
228 {
229 return mobility_[phaseIdx];
230 }
231
235 Scalar capillaryPressure() const
236 { return fluidState_.capillaryPressure(); }
237
241 Scalar porosity() const
242 { return solidState_.porosity(); }
243
247 const PermeabilityType& permeability() const
248 { return permeability_; }
249
250protected:
253
254
255private:
256 PermeabilityType permeability_;
257 Scalar mobility_[ParentType::numFluidPhases()];
258};
259
260} // end namespace Dumux
261
262#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
static constexpr int numFluidPhases()
Return number of phases considered by the model.
Definition: porousmediumflow/volumevariables.hh:38
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 constant within a finite volume in the three-phase model.
Definition: porousmediumflow/3p/volumevariables.hh:32
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:181
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/3p/volumevariables.hh:247
Idx Indices
Export the indices.
Definition: porousmediumflow/3p/volumevariables.hh:58
Scalar saturation(const int phaseIdx) const
Returns the effective saturation of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:190
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:114
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/3p/volumevariables.hh:62
SolidState solidState_
Definition: porousmediumflow/3p/volumevariables.hh:252
typename Traits::FluidState FluidState
Export fluid state type.
Definition: porousmediumflow/3p/volumevariables.hh:54
Scalar porosity() const
Returns the average porosity within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:241
Scalar mobility(const int phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:227
typename Traits::FluidSystem FluidSystem
Export fluid system type.
Definition: porousmediumflow/3p/volumevariables.hh:56
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:74
const FluidState & fluidState() const
Returns the phase state for the control-volume.
Definition: porousmediumflow/3p/volumevariables.hh:175
FluidState fluidState_
Definition: porousmediumflow/3p/volumevariables.hh:251
Scalar temperature() const
Returns temperature inside the sub-control volume.
Definition: porousmediumflow/3p/volumevariables.hh:218
Scalar density(const int phaseIdx) const
Returns the mass density of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:199
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/3p/volumevariables.hh:60
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:235
Scalar pressure(const int phaseIdx) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/3p/volumevariables.hh:208
A central place for various physical constants occurring in some equations.
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
Represents all relevant thermodynamic quantities of a multi-phase fluid system assuming immiscibility...
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.