25#ifndef DUMUX_RICHARDSEXTENDED_PRIMARY_VARIABLE_SWITCH_HH
26#define DUMUX_RICHARDSEXTENDED_PRIMARY_VARIABLE_SWITCH_HH
46 using ParentType::ParentType;
51 template<
class VolumeVariables,
class GlobalPosition>
52 bool update_(
typename VolumeVariables::PrimaryVariables& priVars,
53 const VolumeVariables& volVars,
54 std::size_t dofIdxGlobal,
55 const GlobalPosition& globalPos)
57 using Scalar =
typename VolumeVariables::PrimaryVariables::value_type;
58 using Indices =
typename VolumeVariables::Indices;
59 using FluidSystem =
typename VolumeVariables::FluidSystem;
61 static const bool usePriVarSwitch = getParam<bool>(
"Problem.UsePrimaryVariableSwitch");
65 static constexpr int liquidCompIdx = FluidSystem::liquidPhaseIdx;
68 bool wouldSwitch =
false;
77 Scalar xnw = volVars.moleFraction(FluidSystem::gasPhaseIdx, liquidCompIdx);
78 Scalar xnwPredicted = FluidSystem::H2O::vaporPressure(volVars.temperature())
79 / volVars.pressure(FluidSystem::gasPhaseIdx);
82 if (xnw / xnwPredicted > xwMax)
89 if (xnw / xnwPredicted > xwMax)
93 std::cout <<
"Liquid phase appears at dof " << dofIdxGlobal
94 <<
", coordinates: " << globalPos <<
", xnw / xnwPredicted * 100: "
95 << xnw / xnwPredicted * 100 <<
"%"
96 <<
", at x_n^w: " << priVars[Indices::switchIdx] << std::endl;
97 newPhasePresence = Indices::bothPhases;
98 priVars[Indices::switchIdx] = 0.0;
107 if (volVars.saturation(FluidSystem::liquidPhaseIdx) <= Smin)
111 newPhasePresence = Indices::gasPhaseOnly;
112 priVars[Indices::switchIdx] = volVars.moleFraction(FluidSystem::gasPhaseIdx, liquidCompIdx);
115 std::cout <<
"Liquid phase disappears at dof " << dofIdxGlobal
116 <<
", coordinates: " << globalPos <<
", sw: "
117 << volVars.saturation(FluidSystem::liquidPhaseIdx)
118 <<
", x_n^w: " << priVars[Indices::switchIdx] << std::endl;
123 DUNE_THROW(Dune::NotImplemented,
"Water phase only phase presence!");
126 priVars.setState(newPhasePresence);
Some exceptions thrown in DuMux
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
A central place for various physical constants occurring in some equations.
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
std::string phasePresence() noexcept
I/O name of phase presence.
Definition: name.hh:147
The primary variable switch controlling the phase presence state variable.
Definition: compositional/primaryvariableswitch.hh:61
std::vector< bool > wasSwitched_
Definition: compositional/primaryvariableswitch.hh:445
int verbosity() const
The verbosity level.
Definition: compositional/primaryvariableswitch.hh:283
The primary variable switch controlling the phase presence state variable.
Definition: richardsextended/primaryvariableswitch.hh:41
bool update_(typename VolumeVariables::PrimaryVariables &priVars, const VolumeVariables &volVars, std::size_t dofIdxGlobal, const GlobalPosition &globalPos)
Definition: richardsextended/primaryvariableswitch.hh:52
The primary variable switch base class for compositional models.