13#ifndef DUMUX_RICHARDSEXTENDED_PRIMARY_VARIABLE_SWITCH_HH
14#define DUMUX_RICHARDSEXTENDED_PRIMARY_VARIABLE_SWITCH_HH
34 using ParentType::ParentType;
39 template<
class VolumeVariables,
class GlobalPosition>
40 bool update_(
typename VolumeVariables::PrimaryVariables& priVars,
41 const VolumeVariables& volVars,
42 std::size_t dofIdxGlobal,
43 const GlobalPosition& globalPos)
45 using Scalar =
typename VolumeVariables::PrimaryVariables::value_type;
46 using Indices =
typename VolumeVariables::Indices;
47 using FluidSystem =
typename VolumeVariables::FluidSystem;
49 static const bool usePriVarSwitch = getParam<bool>(
"Richards.UsePrimaryVariableSwitch");
53 static constexpr int liquidCompIdx = FluidSystem::liquidPhaseIdx;
56 bool wouldSwitch =
false;
65 Scalar xnw = volVars.moleFraction(FluidSystem::gasPhaseIdx, liquidCompIdx);
66 Scalar xnwPredicted = FluidSystem::H2O::vaporPressure(volVars.temperature())
67 / volVars.pressure(FluidSystem::gasPhaseIdx);
70 if (xnw / xnwPredicted > xwMax)
77 if (xnw / xnwPredicted > xwMax)
81 std::cout <<
"Liquid phase appears at dof " << dofIdxGlobal
82 <<
", coordinates: " << globalPos <<
", xnw / xnwPredicted * 100: "
83 << xnw / xnwPredicted * 100 <<
"%"
84 <<
", at x_n^w: " << priVars[Indices::switchIdx] << std::endl;
85 newPhasePresence = Indices::bothPhases;
86 priVars[Indices::switchIdx] = 0.0;
95 if (volVars.saturation(FluidSystem::liquidPhaseIdx) <= Smin)
99 newPhasePresence = Indices::gasPhaseOnly;
100 priVars[Indices::switchIdx] = volVars.moleFraction(FluidSystem::gasPhaseIdx, liquidCompIdx);
103 std::cout <<
"Liquid phase disappears at dof " << dofIdxGlobal
104 <<
", coordinates: " << globalPos <<
", sw: "
105 << volVars.saturation(FluidSystem::liquidPhaseIdx)
106 <<
", x_n^w: " << priVars[Indices::switchIdx] << std::endl;
111 DUNE_THROW(Dune::NotImplemented,
"Water phase only phase presence!");
114 priVars.setState(newPhasePresence);
The primary variable switch controlling the phase presence state variable.
Definition: richardsextended/primaryvariableswitch.hh:29
bool update_(typename VolumeVariables::PrimaryVariables &priVars, const VolumeVariables &volVars, std::size_t dofIdxGlobal, const GlobalPosition &globalPos)
Definition: richardsextended/primaryvariableswitch.hh:40
The primary variable switch controlling the phase presence state variable.
Definition: compositional/primaryvariableswitch.hh:49
std::vector< bool > wasSwitched_
Definition: compositional/primaryvariableswitch.hh:433
int verbosity() const
The verbosity level.
Definition: compositional/primaryvariableswitch.hh:271
The primary variable switch base class for compositional models.
A central place for various physical constants occurring in some equations.
Some exceptions thrown in DuMux
std::string phasePresence() noexcept
I/O name of phase presence.
Definition: name.hh:135
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.