25#ifndef DUMUX_2P1C_VOLUME_VARIABLES_HH
26#define DUMUX_2P1C_VOLUME_VARIABLES_HH
30#include <dune/common/exceptions.hh>
47template <
class Traits>
54 using Scalar =
typename Traits::PrimaryVariables::value_type;
55 using PermeabilityType =
typename Traits::PermeabilityType;
56 using FS =
typename Traits::FluidSystem;
57 using Idx =
typename Traits::ModelTraits::Indices;
63 numFluidPhases = Traits::ModelTraits::numFluidPhases(),
64 switchIdx = Idx::switchIdx,
65 pressureIdx = Idx::pressureIdx
71 comp0Idx = FS::comp0Idx,
72 liquidPhaseIdx = FS::liquidPhaseIdx,
73 gasPhaseIdx = FS::gasPhaseIdx
79 twoPhases = Idx::twoPhases,
80 liquidPhaseOnly = Idx::liquidPhaseOnly,
81 gasPhaseOnly = Idx::gasPhaseOnly,
85 static constexpr auto formulation = Traits::ModelTraits::priVarFormulation();
93 using Indices =
typename Traits::ModelTraits::Indices;
105 static_assert(Traits::ModelTraits::numFluidPhases() == 2,
"NumPhases set in the model is not two!");
106 static_assert(Traits::ModelTraits::numFluidComponents() == 1,
"NumComponents set in the model is not one!");
118 template<
class ElemSol,
class Problem,
class Element,
class Scv>
120 const Problem &problem,
121 const Element &element,
135 const auto fluidMatrixInteraction = Deprecated::makePcKrSw(Scalar{}, problem.spatialParams(), element, scv, elemSol);
140 typename FluidSystem::ParameterCache paramCache;
143 for (
int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
147 if (phaseIdx == wPhaseIdx)
148 kr = fluidMatrixInteraction.krw(
saturation(wPhaseIdx));
151 kr = fluidMatrixInteraction.krn(
saturation(wPhaseIdx));
152 relativePermeability_[phaseIdx] = kr;
158 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv,
solidState_);
159 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
160 EnergyVolVars::updateEffectiveThermalConductivity();
174 template<
class ElemSol,
class Problem,
class Element,
class Scv>
176 const Problem& problem,
177 const Element& element,
184 const auto wPhaseIdx = problem.spatialParams().template wettingPhase<FluidSystem>(element, scv, elemSol);
187 const auto&
priVars = elemSol[scv.localDofIndex()];
206 fluidState.setSaturation(liquidPhaseIdx, 1.0);
211 fluidState.setSaturation(liquidPhaseIdx, 0.0);
215 DUNE_THROW(Dune::InvalidStateException,
"phasePresence: " <<
phasePresence <<
" is invalid.");
221 const auto fluidMatrixInteraction = Deprecated::makePcKrSw(Scalar{}, problem.spatialParams(), element, scv, elemSol);
223 pc_ = fluidMatrixInteraction.pc(
fluidState.saturation(wPhaseIdx));
227 fluidState.setPressure(gasPhaseIdx, (wPhaseIdx == liquidPhaseIdx) ?
priVars[pressureIdx] + pc_
233 fluidState.setPressure(liquidPhaseIdx, (wPhaseIdx == liquidPhaseIdx) ?
priVars[pressureIdx] - pc_
241 for (
int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
247 fluidState.setMolarDensity(phaseIdx, rhoMolar);
251 for (
int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
261 for (
int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
263 const Scalar h = FluidSystem::enthalpy(
fluidState, phaseIdx);
270 template<
class ElemSol,
class Problem,
class Element,
class Scv>
272 const Problem& problem,
273 const Element& element,
278 const auto&
priVars = elemSol[scv.localDofIndex()];
288 DUNE_THROW(Dune::InvalidStateException,
"phasePresence: " <<
phasePresence <<
" is invalid.");
291 for (
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
295 if (Traits::ModelTraits::numEnergyEq() == 1)
299 const Scalar
solidTemperature = elemSol[scv.localDofIndex()][Traits::ModelTraits::numEq()-1];
378 return relativePermeability_[phaseIdx]/
fluidState_.viscosity(phaseIdx);
398 {
return permeability_; }
404 {
return FluidSystem::vaporTemperature(
fluidState_, liquidPhaseIdx);}
418 PermeabilityType permeability_;
421 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
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:51
Scalar saturation(const int phaseIdx) const
Returns the effective saturation of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:330
typename Traits::FluidSystem FluidSystem
The type of the fluid system.
Definition: porousmediumflow/2p1c/volumevariables.hh:91
const PermeabilityType & permeability() const
Returns the average permeability within the control volume in .
Definition: porousmediumflow/2p1c/volumevariables.hh:397
Scalar density(const int phaseIdx) const
Returns the mass density of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:339
Scalar temperature(const int phaseIdx=0) const
Returns temperature inside the sub-control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:367
typename Traits::FluidState FluidState
The type of the object returned by the fluidState() method.
Definition: porousmediumflow/2p1c/volumevariables.hh:89
const FluidState & fluidState() const
Returns the fluid state for the control-volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:307
Scalar averageMolarMass(int phaseIdx) const
Returns the average molar mass of the fluid phase.
Definition: porousmediumflow/2p1c/volumevariables.hh:321
Scalar vaporTemperature() const
Returns the vapor temperature of the fluid within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:403
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:175
Scalar molarDensity(const int phaseIdx) const
Returns the molar density of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:348
FluidState fluidState_
Definition: porousmediumflow/2p1c/volumevariables.hh:413
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/2p1c/volumevariables.hh:97
Scalar capillaryPressure() const
Returns the effective capillary pressure within the control volume in .
Definition: porousmediumflow/2p1c/volumevariables.hh:385
void updateTemperature(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
Definition: porousmediumflow/2p1c/volumevariables.hh:271
typename Traits::ModelTraits::Indices Indices
The type of the indices.
Definition: porousmediumflow/2p1c/volumevariables.hh:93
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:119
Scalar porosity() const
Returns the average porosity within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:391
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/2p1c/volumevariables.hh:95
Scalar mobility(const int phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:376
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:313
int wettingPhase() const
Returns the wetting phase index.
Definition: porousmediumflow/2p1c/volumevariables.hh:409
static constexpr TwoPFormulation priVarFormulation()
Return the two-phase formulation used here.
Definition: porousmediumflow/2p1c/volumevariables.hh:102
Scalar pressure(const int phaseIdx) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/2p1c/volumevariables.hh:357
SolidState solidState_
Definition: porousmediumflow/2p1c/volumevariables.hh:414
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.