27 #ifndef EWOMS_ISTL_RESID_REDUCTION_CRITERION_HH 28 #define EWOMS_ISTL_RESID_REDUCTION_CRITERION_HH 32 #include <opm/common/Unused.hpp> 34 #include <dune/istl/scalarproducts.hh> 52 template <
class Vector>
55 typedef typename Vector::field_type Scalar;
60 : scalarProduct_(scalarProduct), tolerance_(
tolerance)
74 {
return tolerance_; }
79 void setInitial(
const Vector& curSol OPM_UNUSED,
const Vector& curResid)
81 static constexpr Scalar eps = std::numeric_limits<Scalar>::min()*1e10;
85 curDefect_ = scalarProduct_.norm(curResid);
86 lastDefect_ = curDefect_;
87 initialDefect_ = std::max(curDefect_, eps);
93 void update(
const Vector& curSol OPM_UNUSED,
94 const Vector& changeIndicator OPM_UNUSED,
95 const Vector& curResid)
97 lastDefect_ = curDefect_;
98 curDefect_ = scalarProduct_.norm(curResid);
111 {
return curDefect_/initialDefect_; }
118 os << std::setw(20) <<
"iteration ";
119 os << std::setw(20) <<
"residual ";
120 os << std::setw(20) <<
"accuracy ";
121 os << std::setw(20) <<
"rate ";
128 void print(Scalar iter, std::ostream& os=std::cout)
const 130 static constexpr Scalar eps = std::numeric_limits<Scalar>::min()*1e10;
132 os << std::setw(20) << iter <<
" ";
133 os << std::setw(20) << curDefect_ <<
" ";
134 os << std::setw(20) <<
accuracy() <<
" ";
135 os << std::setw(20) << (lastDefect_/std::max(eps, curDefect_)) <<
" ";
140 Dune::ScalarProduct<Vector>& scalarProduct_;
143 Scalar initialDefect_;
Base class for all convergence criteria which only defines an virtual API.
Definition: convergencecriterion.hh:57
Definition: baseauxiliarymodule.hh:37
Scalar accuracy() const
Returns the accuracy of the solution at the last update.
Definition: residreductioncriterion.hh:110
Provides a convergence criterion which looks at the reduction of the two-norm of the residual for the...
Definition: residreductioncriterion.hh:53
void printInitial(std::ostream &os=std::cout) const
Prints the initial information about the convergence behaviour.
Definition: residreductioncriterion.hh:116
void update(const Vector &curSol OPM_UNUSED, const Vector &changeIndicator OPM_UNUSED, const Vector &curResid)
Definition: residreductioncriterion.hh:93
Scalar tolerance() const
Return the maximum allowed weighted maximum of the reduction of the linear residual.
Definition: residreductioncriterion.hh:73
void setTolerance(Scalar tol)
Set the maximum allowed weighted maximum of the reduction of the linear residual. ...
Definition: residreductioncriterion.hh:67
void setInitial(const Vector &curSol OPM_UNUSED, const Vector &curResid)
Set the initial solution of the linear system of equations.
Definition: residreductioncriterion.hh:79
bool converged() const
Returns true if and only if the convergence criterion is met.
Definition: residreductioncriterion.hh:104
void print(Scalar iter, std::ostream &os=std::cout) const
Prints the information about the convergence behaviour for the current iteration. ...
Definition: residreductioncriterion.hh:128