25#ifndef DUMUX_2P1C_VOLUME_VARIABLES_HH
26#define DUMUX_2P1C_VOLUME_VARIABLES_HH
30#include <dune/common/exceptions.hh>
45template <
class Traits>
52 using Scalar =
typename Traits::PrimaryVariables::value_type;
53 using PermeabilityType =
typename Traits::PermeabilityType;
54 using FS =
typename Traits::FluidSystem;
55 using Idx =
typename Traits::ModelTraits::Indices;
61 numFluidPhases = Traits::ModelTraits::numFluidPhases(),
62 switchIdx = Idx::switchIdx,
63 pressureIdx = Idx::pressureIdx
69 comp0Idx = FS::comp0Idx,
70 liquidPhaseIdx = FS::liquidPhaseIdx,
71 gasPhaseIdx = FS::gasPhaseIdx
77 twoPhases = Idx::twoPhases,
78 liquidPhaseOnly = Idx::liquidPhaseOnly,
79 gasPhaseOnly = Idx::gasPhaseOnly,
83 static constexpr auto formulation = Traits::ModelTraits::priVarFormulation();
91 using Indices =
typename Traits::ModelTraits::Indices;
103 static_assert(Traits::ModelTraits::numFluidPhases() == 2,
"NumPhases set in the model is not two!");
104 static_assert(Traits::ModelTraits::numFluidComponents() == 1,
"NumComponents set in the model is not one!");
116 template<
class ElemSol,
class Problem,
class Element,
class Scv>
118 const Problem &problem,
119 const Element &element,
130 const auto& spatialParams = problem.spatialParams();
131 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
136 typename FluidSystem::ParameterCache paramCache;
139 for (
int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
143 if (phaseIdx == wPhaseIdx)
144 kr = fluidMatrixInteraction.krw(
saturation(wPhaseIdx));
147 kr = fluidMatrixInteraction.krn(
saturation(wPhaseIdx));
148 relativePermeability_[phaseIdx] = kr;
154 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv,
solidState_);
155 permeability_ = spatialParams.permeability(element, scv, elemSol);
156 EnergyVolVars::updateEffectiveThermalConductivity();
170 template<
class ElemSol,
class Problem,
class Element,
class Scv>
172 const Problem& problem,
173 const Element& element,
180 const auto& spatialParams = problem.spatialParams();
181 const auto wPhaseIdx = spatialParams.template wettingPhase<FluidSystem>(element, scv, elemSol);
184 const auto&
priVars = elemSol[scv.localDofIndex()];
203 fluidState.setSaturation(liquidPhaseIdx, 1.0);
208 fluidState.setSaturation(liquidPhaseIdx, 0.0);
212 DUNE_THROW(Dune::InvalidStateException,
"phasePresence: " <<
phasePresence <<
" is invalid.");
215 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
216 pc_ = fluidMatrixInteraction.pc(
fluidState.saturation(wPhaseIdx));
220 fluidState.setPressure(gasPhaseIdx, (wPhaseIdx == liquidPhaseIdx) ?
priVars[pressureIdx] + pc_
226 fluidState.setPressure(liquidPhaseIdx, (wPhaseIdx == liquidPhaseIdx) ?
priVars[pressureIdx] - pc_
234 for (
int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
240 fluidState.setMolarDensity(phaseIdx, rhoMolar);
244 for (
int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
254 for (
int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
256 const Scalar h = FluidSystem::enthalpy(
fluidState, phaseIdx);
263 template<
class ElemSol,
class Problem,
class Element,
class Scv>
265 const Problem& problem,
266 const Element& element,
271 const auto&
priVars = elemSol[scv.localDofIndex()];
281 DUNE_THROW(Dune::InvalidStateException,
"phasePresence: " <<
phasePresence <<
" is invalid.");
284 for (
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
288 if (Traits::ModelTraits::numEnergyEq() == 1)
292 const Scalar
solidTemperature = elemSol[scv.localDofIndex()][Traits::ModelTraits::numEq()-1];
371 return relativePermeability_[phaseIdx]/
fluidState_.viscosity(phaseIdx);
391 {
return permeability_; }
397 {
return FluidSystem::vaporTemperature(
fluidState_, liquidPhaseIdx);}
411 PermeabilityType permeability_;
414 std::array<Scalar, numFluidPhases> relativePermeability_;
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.
TwoPFormulation
Enumerates the formulations which the two-phase model accepts.
Definition: formulation.hh:35
@ 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
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
std::string solidTemperature() noexcept
I/O name of solid temperature for non-equilibrium models.
Definition: name.hh:60
std::string phasePresence() noexcept
I/O name of phase presence.
Definition: name.hh:147
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:83
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
std::string fluidTemperature(int phaseIdx) noexcept
I/O name of temperature for non-equilibrium models.
Definition: name.hh:56
The primary variable switch for the two-phase one-component model.
Definition: 2p1c/primaryvariableswitch.hh:41
The volume variables (i.e. secondary variables) for the two-phase one-component model.
Definition: porousmediumflow/2p1c/volumevariables.hh:49
Scalar saturation(const int phaseIdx) const
Returns the effective saturation of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:323
typename Traits::FluidSystem FluidSystem
The type of the fluid system.
Definition: porousmediumflow/2p1c/volumevariables.hh:89
const PermeabilityType & permeability() const
Returns the average permeability within the control volume in .
Definition: porousmediumflow/2p1c/volumevariables.hh:390
Scalar density(const int phaseIdx) const
Returns the mass density of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:332
Scalar temperature(const int phaseIdx=0) const
Returns temperature inside the sub-control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:360
typename Traits::FluidState FluidState
The type of the object returned by the fluidState() method.
Definition: porousmediumflow/2p1c/volumevariables.hh:87
const FluidState & fluidState() const
Returns the fluid state for the control-volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:300
Scalar averageMolarMass(int phaseIdx) const
Returns the average molar mass of the fluid phase.
Definition: porousmediumflow/2p1c/volumevariables.hh:314
Scalar vaporTemperature() const
Returns the vapor temperature of the fluid within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:396
void completeFluidState(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
Sets complete fluid state.
Definition: porousmediumflow/2p1c/volumevariables.hh:171
Scalar molarDensity(const int phaseIdx) const
Returns the molar density of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:341
FluidState fluidState_
Definition: porousmediumflow/2p1c/volumevariables.hh:406
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/2p1c/volumevariables.hh:95
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume in .
Definition: porousmediumflow/2p1c/volumevariables.hh:378
void updateTemperature(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
Definition: porousmediumflow/2p1c/volumevariables.hh:264
typename Traits::ModelTraits::Indices Indices
The type of the indices.
Definition: porousmediumflow/2p1c/volumevariables.hh:91
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:117
Scalar porosity() const
Returns the average porosity within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:384
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/2p1c/volumevariables.hh:93
Scalar mobility(const int phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:369
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:306
int wettingPhase() const
Returns the wetting phase index.
Definition: porousmediumflow/2p1c/volumevariables.hh:402
static constexpr TwoPFormulation priVarFormulation()
Return the two-phase formulation used here.
Definition: porousmediumflow/2p1c/volumevariables.hh:100
Scalar pressure(const int phaseIdx) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:350
SolidState solidState_
Definition: porousmediumflow/2p1c/volumevariables.hh:407
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.
The primary variable switch for the extended Richards model.