25#ifndef DUMUX_2P2C_CO2_PRIMARY_VARIABLE_SWITCH_HH
26#define DUMUX_2P2C_CO2_PRIMARY_VARIABLE_SWITCH_HH
50 using ParentType::ParentType;
54 template<
class VolumeVariables,
class IndexType,
class GlobalPosition>
55 bool update_(
typename VolumeVariables::PrimaryVariables& priVars,
56 const VolumeVariables& volVars,
57 IndexType dofIdxGlobal,
58 const GlobalPosition& globalPos)
60 using Scalar =
typename VolumeVariables::PrimaryVariables::value_type;
62 using FluidSystem =
typename VolumeVariables::FluidSystem;
63 static constexpr int phase0Idx = FluidSystem::phase0Idx;
64 static constexpr int phase1Idx = FluidSystem::phase1Idx;
65 static constexpr int comp0Idx = FluidSystem::comp0Idx;
66 static constexpr int comp1Idx = FluidSystem::comp1Idx;
68 static constexpr bool useMoles = VolumeVariables::useMoles();
69 static constexpr auto formulation = VolumeVariables::priVarFormulation();
71 "Chosen TwoPFormulation not supported!");
74 static constexpr int switchIdx = Indices::switchIdx;
77 bool wouldSwitch =
false;
82 typename FluidSystem::ParameterCache paramCache;
88 Scalar xnw = volVars.moleFraction(phase1Idx, comp0Idx);
89 Scalar xnwMax = FluidSystem::equilibriumMoleFraction(volVars.fluidState(), paramCache, phase1Idx);
103 std::cout <<
"First phase (" << FluidSystem::phaseName(phase0Idx) <<
") appears at dof " << dofIdxGlobal
104 <<
", coordinates: " << globalPos
105 <<
", x^" << FluidSystem::componentName(comp0Idx) <<
"_" << FluidSystem::phaseName(phase1Idx) <<
" > x_equilibrium: "
106 << xnw <<
" > " << xnwMax << std::endl;
107 newPhasePresence = Indices::bothPhases;
109 priVars[switchIdx] = 0.0;
111 priVars[switchIdx] = 1.0;
117 Scalar xwn = volVars.moleFraction(phase0Idx, comp1Idx);
118 Scalar xwnMax = FluidSystem::equilibriumMoleFraction(volVars.fluidState(), paramCache, phase0Idx);
132 std::cout <<
"Second phase (" << FluidSystem::phaseName(phase1Idx) <<
") appears at dof " << dofIdxGlobal
133 <<
", coordinates: " << globalPos
134 <<
", x^" << FluidSystem::componentName(comp1Idx) <<
"_" << FluidSystem::phaseName(phase0Idx) <<
" > x_equilibrium: "
135 << xwn <<
" > " << xwnMax << std::endl;
136 newPhasePresence = Indices::bothPhases;
138 priVars[switchIdx] = 0.999;
140 priVars[switchIdx] = 0.001;
150 if (volVars.saturation(phase1Idx) <= Smin)
155 std::cout <<
"Second phase (" << FluidSystem::phaseName(phase1Idx) <<
") disappears at dof " << dofIdxGlobal
156 <<
", coordinates: " << globalPos
157 <<
", S_" << FluidSystem::phaseName(phase1Idx) <<
": " << volVars.saturation(phase1Idx)
159 newPhasePresence = Indices::firstPhaseOnly;
162 priVars[switchIdx] = volVars.moleFraction(phase0Idx, comp1Idx);
164 priVars[switchIdx] = volVars.massFraction(phase0Idx, comp1Idx);
166 else if (volVars.saturation(phase0Idx) <= Smin)
171 std::cout <<
"First phase (" << FluidSystem::phaseName(phase0Idx) <<
") disappears at dof " << dofIdxGlobal
172 <<
", coordinates: " << globalPos
173 <<
", S_" << FluidSystem::phaseName(phase0Idx) <<
": " << volVars.saturation(phase0Idx)
175 newPhasePresence = Indices::secondPhaseOnly;
178 priVars[switchIdx] = volVars.moleFraction(phase1Idx, comp0Idx);
180 priVars[switchIdx] = volVars.massFraction(phase1Idx, comp0Idx);
184 priVars.setState(newPhasePresence);
Defines an enumeration for the formulations accepted by the two-phase model.
@ p1s0
first phase saturation and second phase pressure as primary variables
@ p0s1
first phase pressure and second phase saturation as primary variables
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
std::string phasePresence() noexcept
I/O name of phase presence.
Definition: name.hh:147
The primary variable switch for the 2p2c-CO2 model controlling the phase presence state variable.
Definition: co2/primaryvariableswitch.hh:45
bool update_(typename VolumeVariables::PrimaryVariables &priVars, const VolumeVariables &volVars, IndexType dofIdxGlobal, const GlobalPosition &globalPos)
Definition: co2/primaryvariableswitch.hh:55
The primary variable switch controlling the phase presence state variable.
Definition: compositional/primaryvariableswitch.hh:60
std::vector< bool > wasSwitched_
Definition: compositional/primaryvariableswitch.hh:337
int verbosity() const
The verbosity level.
Definition: compositional/primaryvariableswitch.hh:312
The primary variable switch base class for compositional models.