27 #ifndef EWOMS_ISTL_FIXPOINT_CRITERION_HH
28 #define EWOMS_ISTL_FIXPOINT_CRITERION_HH
32 #include <opm/common/Unused.hpp>
57 template <
class Vector,
class CollectiveCommunication>
60 typedef typename Vector::field_type Scalar;
61 typedef typename Vector::block_type BlockType;
68 const Vector& weightVec, Scalar reduction)
69 : comm_(comm), weightVec_(weightVec), tolerance_(reduction)
89 { weightVec_ = weightVec; }
107 Scalar
weight(
int outerIdx,
int innerIdx)
const
108 {
return (weightVec_.size() == 0) ? 1.0 : weightVec_[outerIdx][innerIdx]; }
119 { tolerance_ = tol; }
126 {
return tolerance_; }
131 void setInitial(
const Vector& curSol,
const Vector& curResid OPM_UNUSED)
134 delta_ = 1000 * tolerance_;
141 const Vector& changeIndicator OPM_UNUSED,
142 const Vector& curResid OPM_UNUSED)
144 assert(curSol.size() == lastSol_.size());
147 for (
size_t i = 0; i < curSol.size(); ++i) {
148 for (
size_t j = 0; j < BlockType::dimension; ++j) {
150 std::max(delta_,
weight(i, j)*std::abs(curSol[i][j] - lastSol_[i][j]));
154 delta_ = comm_.max(delta_);
171 const CollectiveCommunication& comm_;
Base class for all convergence criteria which only defines an virtual API.
Definition: convergencecriterion.hh:57
bool converged() const
Returns true if and only if the convergence criterion is met.
Definition: fixpointcriterion.hh:161
Scalar tolerance() const
Return the maximum allowed weighted difference between two iterations for the solution considered to ...
Definition: fixpointcriterion.hh:125
void update(const Vector &curSol, const Vector &changeIndicator OPM_UNUSED, const Vector &curResid OPM_UNUSED)
Update the internal members of the convergence criterion with the current solution.
Definition: fixpointcriterion.hh:140
Scalar weight(int outerIdx, int innerIdx) const
Return the relative weight of a primary variable.
Definition: fixpointcriterion.hh:107
void setWeight(const Vector &weightVec)
Sets the relative weight of a primary variable.
Definition: fixpointcriterion.hh:88
Provides a convergence criterion for the linear solvers which looks at the weighted maximum of the di...
Definition: fixpointcriterion.hh:58
Scalar accuracy() const
Returns the accuracy of the solution at the last update.
Definition: fixpointcriterion.hh:167
void setInitial(const Vector &curSol, const Vector &curResid OPM_UNUSED)
Set the initial solution of the linear system of equations.
Definition: fixpointcriterion.hh:131
void setTolerance(Scalar tol)
Set the maximum allowed weighted maximum difference between two iterations.
Definition: fixpointcriterion.hh:118