27 #ifndef EWOMS_ISTL_FIXPOINT_CRITERION_HH 28 #define EWOMS_ISTL_FIXPOINT_CRITERION_HH 55 template <
class Vector,
class CollectiveCommunication>
58 using Scalar =
typename Vector::field_type;
59 using BlockType =
typename Vector::block_type;
66 const Vector& weightVec, Scalar reduction)
67 : comm_(comm), weightVec_(weightVec), tolerance_(reduction)
87 { weightVec_ = weightVec; }
105 Scalar
weight(
int outerIdx,
int innerIdx)
const 106 {
return (weightVec_.size() == 0) ? 1.0 : weightVec_[outerIdx][innerIdx]; }
117 { tolerance_ = tol; }
124 {
return tolerance_; }
129 void setInitial(
const Vector& curSol,
const Vector&)
override 132 delta_ = 1000 * tolerance_;
140 const Vector&)
override 142 assert(curSol.size() == lastSol_.size());
145 for (
size_t i = 0; i < curSol.size(); ++i) {
146 for (
size_t j = 0; j < BlockType::dimension; ++j) {
148 std::max(delta_,
weight(i, j)*std::abs(curSol[i][j] - lastSol_[i][j]));
152 delta_ = comm_.max(delta_);
169 const CollectiveCommunication& comm_;
void setWeight(const Vector &weightVec)
Sets the relative weight of a primary variable.
Definition: fixpointcriterion.hh:86
Base class for all convergence criteria which only defines an virtual API.
Definition: convergencecriterion.hh:55
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
void setTolerance(Scalar tol)
Set the maximum allowed weighted maximum difference between two iterations.
Definition: fixpointcriterion.hh:116
Scalar weight(int outerIdx, int innerIdx) const
Return the relative weight of a primary variable.
Definition: fixpointcriterion.hh:105
void setInitial(const Vector &curSol, const Vector &) override
Set the initial solution of the linear system of equations.
Definition: fixpointcriterion.hh:129
bool converged() const override
Returns true if and only if the convergence criterion is met.
Definition: fixpointcriterion.hh:159
Provides a convergence criterion for the linear solvers which looks at the weighted maximum of the di...
Definition: fixpointcriterion.hh:56
Scalar accuracy() const
Returns the accuracy of the solution at the last update.
Definition: fixpointcriterion.hh:165
Scalar tolerance() const
Return the maximum allowed weighted difference between two iterations for the solution considered to ...
Definition: fixpointcriterion.hh:123
void update(const Vector &curSol, const Vector &, const Vector &) override
Update the internal members of the convergence criterion with the current solution.
Definition: fixpointcriterion.hh:138