28#ifndef EWOMS_NCP_NEWTON_METHOD_HH
29#define EWOMS_NCP_NEWTON_METHOD_HH
33#include <opm/common/Exceptions.hpp>
39namespace Opm::Properties {
41template <
class TypeTag,
class MyTypeTag>
42struct DiscNewtonMethod;
53template <
class TypeTag>
69 enum { fugacity0Idx = Indices::fugacity0Idx };
70 enum { saturation0Idx = Indices::saturation0Idx };
71 enum { pressure0Idx = Indices::pressure0Idx };
72 enum { ncp0EqIdx = Indices::ncp0EqIdx };
85 void preSolve_(
const SolutionVector&,
88 const auto& constraintsMap = this->model().linearizer().constraintsMap();
89 this->lastError_ = this->error_;
96 if (dofIdx >= this->model().numGridDof() || this->model().dofTotalVolume(dofIdx) <= 0.0)
100 if (this->enableConstraints_()) {
101 if (constraintsMap.count(dofIdx) > 0)
107 if (ncp0EqIdx <=
eqIdx &&
eqIdx < Indices::ncp0EqIdx + numPhases)
110 std::max(std::abs(
r[
eqIdx]*this->model().eqWeight(dofIdx,
eqIdx)),
116 this->error_ = this->comm_.max(this->error_);
120 if (this->error_ > Parameters::Get<Parameters::NewtonMaxError<Scalar>>())
122 +
" is larger than maximum allowed error of "
123 + std::to_string(Parameters::Get<Parameters::NewtonMaxError<Scalar>>()));
132 const EqVector& update,
158 - alpha*update[saturation0Idx +
phaseIdx];
174 Scalar
minPhi = this->problem().model().minActivityCoeff(globalDofIdx,
compIdx);
189 if (this->numIterations_ < 3) {
194 Scalar
minPhi = this->problem().model().minActivityCoeff(globalDofIdx,
compIdx);
A Newton solver specific to the NCP model.
Definition ncpnewtonmethod.hh:55
NcpNewtonMethod(Simulator &simulator)
Definition ncpnewtonmethod.hh:78
void updatePrimaryVariables_(unsigned globalDofIdx, PrimaryVariables &nextValue, const PrimaryVariables ¤tValue, const EqVector &update, const EqVector &)
Update a single primary variables object.
Definition ncpnewtonmethod.hh:129
The multi-dimensional Newton method.
Definition newtonmethod.hh:92
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
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:235
Declares the properties required for the NCP compositional multi-phase model.
The multi-dimensional Newton method.