version 3.8
porousmediumflow/richards/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_RICHARDS_VOLUME_VARIABLES_HH
14#define DUMUX_RICHARDS_VOLUME_VARIABLES_HH
15
16#include <cassert>
17
18#include <dune/common/exceptions.hh>
19
21
26
27namespace Dumux {
28
36template <class Traits>
39, public EnergyVolumeVariables<Traits, RichardsVolumeVariables<Traits> >
40{
43 using Scalar = typename Traits::PrimaryVariables::value_type;
44 using PermeabilityType = typename Traits::PermeabilityType;
45 using ModelTraits = typename Traits::ModelTraits;
46
47 static constexpr int numFluidComps = ParentType::numFluidComponents();
48 static constexpr int numPhases = ParentType::numFluidPhases();
49
50 // checks if the fluid system uses the Richards model index convention
51 static constexpr auto fsCheck = ModelTraits::checkFluidSystem(typename Traits::FluidSystem{});
52
53public:
55 using FluidSystem = typename Traits::FluidSystem;
57 using FluidState = typename Traits::FluidState;
60 using SolidState = typename Traits::SolidState;
62 using SolidSystem = typename Traits::SolidSystem;
63 using Indices = typename Traits::ModelTraits::Indices;
64
66 static constexpr auto liquidPhaseIdx = Traits::FluidSystem::phase0Idx;
67 static constexpr auto gasPhaseIdx = Traits::FluidSystem::phase1Idx;
68
78 template<class ElemSol, class Problem, class Element, class Scv>
79 void update(const ElemSol &elemSol,
80 const Problem &problem,
81 const Element &element,
82 const Scv& scv)
83 {
84 ParentType::update(elemSol, problem, element, scv);
85
86 const auto fluidMatrixInteraction = problem.spatialParams().fluidMatrixInteraction(element, scv, elemSol);
87
88 // precompute the minimum capillary pressure (entry pressure)
89 // needed to make sure we don't compute unphysical capillary pressures and thus saturations
90 minPc_ = fluidMatrixInteraction.endPointPc();
91
92 //update porosity before calculating the effective properties depending on it
93 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
94 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
95
97 // specify the other parameters
99 relativePermeabilityWetting_ = fluidMatrixInteraction.krw(fluidState_.saturation(liquidPhaseIdx));
100 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
101 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
102 EnergyVolVars::updateEffectiveThermalConductivity();
103 }
104
119 template<class ElemSol, class Problem, class Element, class Scv>
120 void completeFluidState(const ElemSol& elemSol,
121 const Problem& problem,
122 const Element& element,
123 const Scv& scv,
126 {
127 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
128
129 const auto fluidMatrixInteraction = problem.spatialParams().fluidMatrixInteraction(element, scv, elemSol);
130
131 const auto& priVars = elemSol[scv.localDofIndex()];
132
133 // set the wetting pressure
134 using std::max;
135 fluidState.setPressure(liquidPhaseIdx, priVars[Indices::pressureIdx]);
136 fluidState.setPressure(gasPhaseIdx, max(problem.nonwettingReferencePressure(), fluidState.pressure(liquidPhaseIdx) + minPc_));
137
138 // compute the capillary pressure to compute the saturation
139 // make sure that we the capillary pressure is not smaller than the minimum pc
140 // this would possibly return unphysical values from regularized material laws
141 using std::max;
142 const Scalar pc = max(minPc_, problem.nonwettingReferencePressure() - fluidState.pressure(liquidPhaseIdx));
143 const Scalar sw = fluidMatrixInteraction.sw(pc);
144 fluidState.setSaturation(liquidPhaseIdx, sw);
145 fluidState.setSaturation(gasPhaseIdx, 1.0-sw);
146
147 // density and viscosity
148 typename FluidSystem::ParameterCache paramCache;
149 paramCache.updateAll(fluidState);
150 fluidState.setDensity(liquidPhaseIdx,
152 fluidState.setDensity(gasPhaseIdx,
154
155 fluidState.setViscosity(liquidPhaseIdx,
157
158 // compute and set the enthalpy
159 fluidState.setEnthalpy(liquidPhaseIdx, EnergyVolVars::enthalpy(fluidState, paramCache, liquidPhaseIdx));
160 fluidState.setEnthalpy(gasPhaseIdx, EnergyVolVars::enthalpy(fluidState, paramCache, gasPhaseIdx));
161 }
162
167 const FluidState &fluidState() const
168 { return fluidState_; }
169
173 const SolidState &solidState() const
174 { return solidState_; }
175
179 Scalar temperature() const
180 { return fluidState_.temperature(); }
181
188 Scalar porosity() const
189 { return solidState_.porosity(); }
190
194 const PermeabilityType& permeability() const
195 { return permeability_; }
196
207 Scalar saturation(const int phaseIdx = liquidPhaseIdx) const
208 { return fluidState_.saturation(phaseIdx); }
209
216 Scalar density(const int phaseIdx = liquidPhaseIdx) const
217 { return fluidState_.density(phaseIdx); }
218
230 Scalar pressure(const int phaseIdx = liquidPhaseIdx) const
231 { return fluidState_.pressure(phaseIdx); }
232
244 Scalar mobility(const int phaseIdx = liquidPhaseIdx) const
245 { return relativePermeability(phaseIdx)/fluidState_.viscosity(phaseIdx); }
246
254 Scalar viscosity(const int phaseIdx = liquidPhaseIdx) const
255 { return phaseIdx == liquidPhaseIdx ? fluidState_.viscosity(liquidPhaseIdx) : 0.0; }
256
263 Scalar relativePermeability(const int phaseIdx = liquidPhaseIdx) const
264 { return phaseIdx == liquidPhaseIdx ? relativePermeabilityWetting_ : 1.0; }
265
277 Scalar capillaryPressure() const
278 {
279 using std::max;
281 }
282
297 Scalar pressureHead(const int phaseIdx = liquidPhaseIdx) const
298 { return 100.0 *(pressure(phaseIdx) - pressure(gasPhaseIdx))/density(phaseIdx)/9.81; }
299
310 Scalar waterContent(const int phaseIdx = liquidPhaseIdx) const
311 { return saturation(phaseIdx) * solidState_.porosity(); }
312
313protected:
317 PermeabilityType permeability_;
318 Scalar minPc_;
319
320 // Effective diffusion coefficients for the phases
322
323};
324} // end namespace Dumux
325
326#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
Volume averaged quantities required by the Richards model.
Definition: porousmediumflow/richards/volumevariables.hh:40
Scalar saturation(const int phaseIdx=liquidPhaseIdx) const
Returns the average absolute saturation [] of a given fluid phase within the finite volume.
Definition: porousmediumflow/richards/volumevariables.hh:207
FluidState fluidState_
the fluid state
Definition: porousmediumflow/richards/volumevariables.hh:314
Scalar relativePermeabilityWetting_
the relative permeability of the wetting phase
Definition: porousmediumflow/richards/volumevariables.hh:316
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/richards/volumevariables.hh:194
Scalar waterContent(const int phaseIdx=liquidPhaseIdx) const
Returns the water content of a fluid phase within the finite volume.
Definition: porousmediumflow/richards/volumevariables.hh:310
Scalar porosity() const
Returns the average porosity [] within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:188
SolidState solidState_
Definition: porousmediumflow/richards/volumevariables.hh:315
const FluidState & fluidState() const
Returns the fluid configuration at the given primary variables.
Definition: porousmediumflow/richards/volumevariables.hh:167
Scalar viscosity(const int phaseIdx=liquidPhaseIdx) const
Returns the dynamic viscosity of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:254
static constexpr auto liquidPhaseIdx
Export phase indices.
Definition: porousmediumflow/richards/volumevariables.hh:66
static constexpr auto gasPhaseIdx
Definition: porousmediumflow/richards/volumevariables.hh:67
Scalar pressureHead(const int phaseIdx=liquidPhaseIdx) const
Returns the pressureHead of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:297
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/richards/volumevariables.hh:79
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:277
PermeabilityType permeability_
the intrinsic permeability
Definition: porousmediumflow/richards/volumevariables.hh:317
Scalar density(const int phaseIdx=liquidPhaseIdx) const
Returns the average mass density of a given fluid phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:216
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/richards/volumevariables.hh:62
typename Traits::ModelTraits::Indices Indices
Definition: porousmediumflow/richards/volumevariables.hh:63
Scalar relativePermeability(const int phaseIdx=liquidPhaseIdx) const
Returns relative permeability [-] of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:263
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:173
typename Traits::SolidState SolidState
Definition: porousmediumflow/richards/volumevariables.hh:60
Scalar effectiveDiffCoeff_
Definition: porousmediumflow/richards/volumevariables.hh:321
void completeFluidState(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
Fills the fluid state according to the primary variables.
Definition: porousmediumflow/richards/volumevariables.hh:120
Scalar mobility(const int phaseIdx=liquidPhaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:244
Scalar pressure(const int phaseIdx=liquidPhaseIdx) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/richards/volumevariables.hh:230
typename Traits::FluidSystem FluidSystem
Export type of the fluid system.
Definition: porousmediumflow/richards/volumevariables.hh:55
typename Traits::FluidState FluidState
Export type of the fluid state.
Definition: porousmediumflow/richards/volumevariables.hh:57
Scalar temperature() const
Returns the temperature.
Definition: porousmediumflow/richards/volumevariables.hh:179
Scalar minPc_
the minimum capillary pressure (entry pressure)
Definition: porousmediumflow/richards/volumevariables.hh:318
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
Relations valid for an ideal gas.
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.
Type traits to be used with matrix types.
Update the solid volume fractions (inert and reacitve) and set them in the solidstate.