28 #ifndef EWOMS_BLACK_OIL_NEWTON_METHOD_HH 29 #define EWOMS_BLACK_OIL_NEWTON_METHOD_HH 35 #include <opm/common/Unused.hpp> 44 template <
class TypeTag>
47 typedef typename GET_PROP_TYPE(TypeTag, DiscNewtonMethod) ParentType;
49 typedef typename GET_PROP_TYPE(TypeTag, SolutionVector) SolutionVector;
50 typedef typename GET_PROP_TYPE(TypeTag, GlobalEqVector) GlobalEqVector;
51 typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
52 typedef typename GET_PROP_TYPE(TypeTag, EqVector) EqVector;
53 typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
54 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
55 typedef typename GET_PROP_TYPE(TypeTag, Linearizer) Linearizer;
68 ParentType::registerParameters();
76 {
return numPriVarsSwitched_; }
87 numPriVarsSwitched_ = 0;
88 ParentType::beginIteration_();
95 const SolutionVector& uLastIter)
100 int localSwitched = numPriVarsSwitched_;
101 MPI_Allreduce(&localSwitched,
102 &numPriVarsSwitched_,
109 this->simulator_.model().newtonMethod().endIterMsg()
110 <<
", num switched=" << numPriVarsSwitched_;
112 ParentType::endIteration_(uCurrentIter, uLastIter);
115 void update_(SolutionVector& nextSolution,
116 const SolutionVector& currentSolution,
117 const GlobalEqVector& solutionUpdate,
118 const GlobalEqVector& currentResidual)
120 const auto& comm = this->simulator_.gridView().comm();
124 ParentType::update_(nextSolution,
131 std::cout <<
"Newton update threw an exception on rank " 132 << comm.rank() <<
"\n";
135 succeeded = comm.min(succeeded);
138 OPM_THROW(Opm::NumericalProblem,
139 "A process did not succeed in adapting the primary variables");
141 numPriVarsSwitched_ = comm.sum(numPriVarsSwitched_);
148 PrimaryVariables& nextValue,
149 const PrimaryVariables& currentValue,
150 const EqVector& update,
151 const EqVector& currentResidual OPM_UNUSED)
153 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
158 Scalar delta = update[eqIdx];
161 if (eqIdx == Indices::waterSaturationIdx
162 && std::abs(delta) > 0.2)
166 else if (eqIdx == Indices::compositionSwitchIdx) {
171 if (currentValue.primaryVarsMeaning() == PrimaryVariables::Sw_po_Sg
172 && std::abs(delta) > 0.2)
179 nextValue[eqIdx] = currentValue[eqIdx] - delta;
183 if (nextValue.adaptPrimaryVariables(this->problem(), globalDofIdx))
184 ++ numPriVarsSwitched_;
188 int numPriVarsSwitched_;
Definition: baseauxiliarymodule.hh:37
int signum(Scalar val)
Template function which returns the sign of a floating point value.
Definition: signum.hh:40
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
void endIteration_(SolutionVector &uCurrentIter, const SolutionVector &uLastIter)
Indicates that one Newton iteration was finished.
Definition: blackoilnewtonmethod.hh:94
A newton solver which is specific to the black oil model.
Definition: blackoilnewtonmethod.hh:45
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
void updatePrimaryVariables_(unsigned globalDofIdx, PrimaryVariables &nextValue, const PrimaryVariables ¤tValue, const EqVector &update, const EqVector ¤tResidual OPM_UNUSED)
Update a single primary variables object.
Definition: blackoilnewtonmethod.hh:147
Declares the properties required by the black oil model.
unsigned numPriVarsSwitched() const
Returns the number of degrees of freedom for which the interpretation has changed for the most recent...
Definition: blackoilnewtonmethod.hh:75
The multi-dimensional Newton method.
Definition: newtonmethod.hh:56
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: blackoilnewtonmethod.hh:66
void beginIteration_()
Indicates the beginning of a Newton iteration.
Definition: blackoilnewtonmethod.hh:85
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75