OGS  v6.4.0
NumLib::ConvergenceCriterion Class Referenceabstract

Detailed Description

Convergence criterion for iterative algorithms, like nonlinear solvers.

It is able to check the difference of the solution vector between iterations and the residual of the equation being solved (e.g. the nonlinear equation system).

Definition at line 29 of file ConvergenceCriterion.h.

#include <ConvergenceCriterion.h>

Inheritance diagram for NumLib::ConvergenceCriterion:

Public Member Functions

 ConvergenceCriterion (const MathLib::VecNormType norm_type)
 
virtual bool hasDeltaXCheck () const =0
 
virtual bool hasResidualCheck () const =0
 
virtual void checkDeltaX (GlobalVector const &minus_delta_x, GlobalVector const &x)=0
 
virtual void checkResidual (GlobalVector const &residual)=0
 Check if the residual satisfies the convergence criterion. More...
 
virtual void preFirstIteration ()
 
virtual void setNoFirstIteration ()
 
virtual void reset ()
 
virtual bool isSatisfied () const
 Tell if the convergence criterion is satisfied. More...
 
MathLib::VecNormType getVectorNormType () const
 
virtual ~ConvergenceCriterion ()=default
 

Protected Attributes

bool _satisfied = true
 
bool _is_first_iteration = true
 
const MathLib::VecNormType _norm_type
 

Constructor & Destructor Documentation

◆ ConvergenceCriterion()

NumLib::ConvergenceCriterion::ConvergenceCriterion ( const MathLib::VecNormType  norm_type)
inlineexplicit

Definition at line 32 of file ConvergenceCriterion.h.

33  : _norm_type(norm_type)
34  {
35  }
const MathLib::VecNormType _norm_type

◆ ~ConvergenceCriterion()

virtual NumLib::ConvergenceCriterion::~ConvergenceCriterion ( )
virtualdefault

Member Function Documentation

◆ checkDeltaX()

virtual void NumLib::ConvergenceCriterion::checkDeltaX ( GlobalVector const &  minus_delta_x,
GlobalVector const &  x 
)
pure virtual

Check if the change of the solution between iterations satisfies the convergence criterion.

Parameters
minus_delta_xthe current solution update
xthe new solution from the current iteration
Remarks
The Newton-Raphson solver computes minus_delta_x. x is needed for relative tolerances.

Implemented in NumLib::ConvergenceCriterionResidual, NumLib::ConvergenceCriterionPerComponentResidual, NumLib::ConvergenceCriterionPerComponentDeltaX, and NumLib::ConvergenceCriterionDeltaX.

◆ checkResidual()

virtual void NumLib::ConvergenceCriterion::checkResidual ( GlobalVector const &  residual)
pure virtual

◆ getVectorNormType()

MathLib::VecNormType NumLib::ConvergenceCriterion::getVectorNormType ( ) const
inline

Definition at line 86 of file ConvergenceCriterion.h.

86 { return _norm_type; }

References _norm_type.

◆ hasDeltaXCheck()

virtual bool NumLib::ConvergenceCriterion::hasDeltaXCheck ( ) const
pure virtual

Tells if the change of the solution between iterations is checked.

Remarks
This method allows to save some computations if no such check will be done.

Implemented in NumLib::ConvergenceCriterionResidual, NumLib::ConvergenceCriterionPerComponentResidual, NumLib::ConvergenceCriterionPerComponentDeltaX, and NumLib::ConvergenceCriterionDeltaX.

◆ hasResidualCheck()

virtual bool NumLib::ConvergenceCriterion::hasResidualCheck ( ) const
pure virtual

Tells if the residual is checked.

Remarks
This method allows to save some computations if no such check will be done.

Implemented in NumLib::ConvergenceCriterionResidual, NumLib::ConvergenceCriterionPerComponentResidual, NumLib::ConvergenceCriterionPerComponentDeltaX, and NumLib::ConvergenceCriterionDeltaX.

◆ isSatisfied()

virtual bool NumLib::ConvergenceCriterion::isSatisfied ( ) const
inlinevirtual

Tell if the convergence criterion is satisfied.

Definition at line 84 of file ConvergenceCriterion.h.

References _satisfied.

◆ preFirstIteration()

virtual void NumLib::ConvergenceCriterion::preFirstIteration ( )
inlinevirtual

Tell the ConvergenceCriterion that it is called for the first time now (while solving a specific nonlinear system).

Definition at line 68 of file ConvergenceCriterion.h.

References _is_first_iteration.

◆ reset()

virtual void NumLib::ConvergenceCriterion::reset ( )
inlinevirtual

Indicate that a new iteration now starts.

A concrete implementation of ConvergenceCriterion might want to check both delta x and the residual. I.e., in a new iteration both checks have to be done anew. This method will make the ConvergenceCriterion forget the result of all checks already done, s.t. all necessary checks will have to be repeated in order to satisfy the ConvergenceCriterion.

Reimplemented in NumLib::ConvergenceCriterionPerComponentDeltaX, and NumLib::ConvergenceCriterionDeltaX.

Definition at line 81 of file ConvergenceCriterion.h.

81 { _satisfied = true; _is_first_iteration = false; };

References _is_first_iteration, and _satisfied.

◆ setNoFirstIteration()

virtual void NumLib::ConvergenceCriterion::setNoFirstIteration ( )
inlinevirtual

Tell the ConvergenceCriterion that it is not called for the first time (while solving a coupling system).

Definition at line 72 of file ConvergenceCriterion.h.

72 { _is_first_iteration = false; }

References _is_first_iteration.

Member Data Documentation

◆ _is_first_iteration

bool NumLib::ConvergenceCriterion::_is_first_iteration = true
protected

◆ _norm_type

◆ _satisfied


The documentation for this class was generated from the following file: