28 #ifndef EWOMS_PVS_NEWTON_METHOD_HH 29 #define EWOMS_PVS_NEWTON_METHOD_HH 41 template <
class TypeTag>
44 typedef typename GET_PROP_TYPE(TypeTag, DiscNewtonMethod) ParentType;
46 typedef typename GET_PROP_TYPE(TypeTag, SolutionVector) SolutionVector;
47 typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
48 typedef typename GET_PROP_TYPE(TypeTag, EqVector) EqVector;
49 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
50 typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
51 typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
53 enum { numPhases = FluidSystem::numPhases };
56 enum { pressure0Idx = Indices::pressure0Idx };
57 enum { switch0Idx = Indices::switch0Idx };
71 PrimaryVariables& nextValue,
72 const PrimaryVariables& currentValue,
73 const EqVector& update,
74 const EqVector& currentResidual OPM_UNUSED)
77 nextValue = currentValue;
84 Scalar sumSatDelta = 0.0;
85 Scalar maxSatDelta = 0.0;
86 for (
unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx) {
87 if (!currentValue.phaseIsPresent(phaseIdx))
90 maxSatDelta = std::max(std::abs(update[switch0Idx + phaseIdx]),
92 sumSatDelta += update[switch0Idx + phaseIdx];
94 maxSatDelta = std::max(std::abs(- sumSatDelta), maxSatDelta);
96 if (maxSatDelta > 0.2) {
97 Scalar alpha = 0.2/maxSatDelta;
98 for (
unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx) {
99 if (!currentValue.phaseIsPresent(phaseIdx))
102 nextValue[switch0Idx + phaseIdx] =
103 currentValue[switch0Idx + phaseIdx]
104 - alpha*update[switch0Idx + phaseIdx];
109 clampValue_(nextValue[pressure0Idx],
110 currentValue[pressure0Idx]*0.8,
111 currentValue[pressure0Idx]*1.2);
118 const SolutionVector& uLastIter)
120 ParentType::endIteration_(uCurrentIter, uLastIter);
121 this->problem().model().switchPrimaryVars_();
124 void clampValue_(Scalar& val, Scalar minVal, Scalar maxVal)
const 125 { val = std::max(minVal, std::min(val, maxVal)); }
void updatePrimaryVariables_(unsigned globalDofIdx OPM_UNUSED, PrimaryVariables &nextValue, const PrimaryVariables ¤tValue, const EqVector &update, const EqVector ¤tResidual OPM_UNUSED)
Update a single primary variables object.
Definition: pvsnewtonmethod.hh:70
Definition: baseauxiliarymodule.hh:37
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
The multi-dimensional Newton method.
Definition: newtonmethod.hh:56
void endIteration_(SolutionVector &uCurrentIter, const SolutionVector &uLastIter)
Indicates that one Newton iteration was finished.
Definition: pvsnewtonmethod.hh:117
A newton solver which is specific to the compositional multi-phase PVS model.
Definition: pvsnewtonmethod.hh:42
Declares the properties required for the compositional multi-phase primary variable switching model...
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75