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;
69 int phasePresence = priVars.state();
70 int newPhasePresence = phasePresence;
73 if (phasePresence == Indices::gasPhaseOnly)
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;
101 else if (phasePresence == Indices::bothPhases)
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;
121 else if (phasePresence == Indices::liquidPhaseOnly)
123 DUNE_THROW(Dune::NotImplemented,
"Water phase only phase presence!");
126 priVars.setState(newPhasePresence);
128 return phasePresence != newPhasePresence;