28#ifndef EWOMS_PVS_NEWTON_METHOD_HH
29#define EWOMS_PVS_NEWTON_METHOD_HH
39template <
class TypeTag,
class MyTypeTag>
40struct DiscNewtonMethod;
52template <
class TypeTag>
64 enum { numPhases = FluidSystem::numPhases };
67 enum { pressure0Idx = Indices::pressure0Idx };
68 enum { switch0Idx = Indices::switch0Idx };
82 PrimaryVariables& nextValue,
83 const PrimaryVariables& currentValue,
84 const EqVector& update,
88 nextValue = currentValue;
95 Scalar sumSatDelta = 0.0;
96 Scalar maxSatDelta = 0.0;
97 for (
unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx) {
98 if (!currentValue.phaseIsPresent(phaseIdx)) {
102 maxSatDelta = std::max(std::abs(update[switch0Idx + phaseIdx]),
104 sumSatDelta += update[switch0Idx + phaseIdx];
106 maxSatDelta = std::max(std::abs(-sumSatDelta), maxSatDelta);
108 if (maxSatDelta > 0.2) {
109 const Scalar alpha = 0.2 / maxSatDelta;
110 for (
unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx) {
111 if (!currentValue.phaseIsPresent(phaseIdx)) {
115 nextValue[switch0Idx + phaseIdx] =
116 currentValue[switch0Idx + phaseIdx] -
117 alpha * update[switch0Idx + phaseIdx];
122 nextValue[pressure0Idx] = std::clamp(nextValue[pressure0Idx],
123 currentValue[pressure0Idx] * 0.8,
124 currentValue[pressure0Idx] * 1.2);
131 const SolutionVector& uLastIter)
133 ParentType::endIteration_(uCurrentIter, uLastIter);
134 this->problem().model().switchPrimaryVars_();
The multi-dimensional Newton method.
Definition: newtonmethod.hh:100
A newton solver which is specific to the compositional multi-phase PVS model.
Definition: pvsnewtonmethod.hh:54
PvsNewtonMethod(Simulator &simulator)
Definition: pvsnewtonmethod.hh:71
void updatePrimaryVariables_(unsigned, PrimaryVariables &nextValue, const PrimaryVariables ¤tValue, const EqVector &update, const EqVector &)
Update a single primary variables object.
Definition: pvsnewtonmethod.hh:81
void endIteration_(SolutionVector &uCurrentIter, const SolutionVector &uLastIter)
Indicates that one Newton iteration was finished.
Definition: pvsnewtonmethod.hh:130
friend ParentType
Definition: pvsnewtonmethod.hh:76
Defines the common properties required by the porous medium multi-phase models.
Definition: blackoilmodel.hh:79
Definition: blackoilboundaryratevector.hh:39
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233