66 bool update_(
typename VolumeVariables::PrimaryVariables& priVars,
67 const VolumeVariables& volVars,
68 std::size_t dofIdxGlobal,
69 const GlobalPosition& globalPos)
71 using Scalar =
typename VolumeVariables::PrimaryVariables::value_type;
72 using Indices =
typename VolumeVariables::Indices;
73 using FluidSystem =
typename VolumeVariables::FluidSystem;
75 static const bool usePriVarSwitch =
getParam<bool>(
"Richards.UsePrimaryVariableSwitch");
79 static constexpr int liquidCompIdx = FluidSystem::liquidPhaseIdx;
82 bool wouldSwitch =
false;
83 int phasePresence = priVars.state();
84 int newPhasePresence = phasePresence;
87 if (phasePresence == Indices::gasPhaseOnly)
91 Scalar xnw = volVars.moleFraction(FluidSystem::gasPhaseIdx, liquidCompIdx);
93 / volVars.pressure(FluidSystem::gasPhaseIdx);
96 if (xnw / xnwPredicted > xwMax)
103 if (xnw / xnwPredicted > xwMax)
107 std::cout <<
"Liquid phase appears at dof " << dofIdxGlobal
108 <<
", coordinates: " << globalPos <<
", xnw / xnwPredicted * 100: "
109 << xnw / xnwPredicted * 100 <<
"%"
110 <<
", at x_n^w: " << priVars[Indices::switchIdx] << std::endl;
111 newPhasePresence = Indices::bothPhases;
112 priVars[Indices::switchIdx] = 0.0;
115 else if (phasePresence == Indices::bothPhases)
121 if (volVars.saturation(FluidSystem::liquidPhaseIdx) <= Smin)
125 newPhasePresence = Indices::gasPhaseOnly;
126 priVars[Indices::switchIdx] = volVars.moleFraction(FluidSystem::gasPhaseIdx, liquidCompIdx);
129 std::cout <<
"Liquid phase disappears at dof " << dofIdxGlobal
130 <<
", coordinates: " << globalPos <<
", sw: "
131 << volVars.saturation(FluidSystem::liquidPhaseIdx)
132 <<
", x_n^w: " << priVars[Indices::switchIdx] << std::endl;
135 else if (phasePresence == Indices::liquidPhaseOnly)
137 DUNE_THROW(Dune::NotImplemented,
"Water phase only phase presence!");
140 priVars.setState(newPhasePresence);
142 return phasePresence != newPhasePresence;