OGS
ConvergenceCriterion.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <memory>
14
15#include "MathLib/LinAlg/LinAlg.h" // For MathLib::VecNormType
17
18namespace BaseLib
19{
20class ConfigTree;
21} // namespace BaseLib
22
23namespace NumLib
24{
32{
33public:
35 : _norm_type(norm_type)
36 {
37 }
38
44 virtual bool hasDeltaXCheck() const = 0;
45
51 virtual bool hasResidualCheck() const = 0;
52
62 virtual void checkDeltaX(GlobalVector const& minus_delta_x,
63 GlobalVector const& x) = 0;
64
66 virtual void checkResidual(GlobalVector const& residual) = 0;
67
70 virtual void preFirstIteration() { _is_first_iteration = true; }
71
74 virtual void setNoFirstIteration() { _is_first_iteration = false; }
75
83 virtual void reset()
84 {
85 _satisfied = true;
86 _is_first_iteration = false;
87 };
88
90 virtual bool isSatisfied() const { return _satisfied; };
91
93
94 virtual ~ConvergenceCriterion() = default;
95
96protected:
97 bool _satisfied = true;
100};
101
103std::unique_ptr<ConvergenceCriterion> createConvergenceCriterion(
104 BaseLib::ConfigTree const& config);
105
109bool checkRelativeTolerance(double const reltol,
110 double const numerator,
111 double const denominator);
112
113} // namespace NumLib
Global vector based on Eigen vector.
Definition EigenVector.h:25
MathLib::VecNormType getVectorNormType() const
virtual void checkResidual(GlobalVector const &residual)=0
Check if the residual satisfies the convergence criterion.
virtual bool hasResidualCheck() const =0
virtual bool isSatisfied() const
Tell if the convergence criterion is satisfied.
ConvergenceCriterion(const MathLib::VecNormType norm_type)
virtual void checkDeltaX(GlobalVector const &minus_delta_x, GlobalVector const &x)=0
virtual bool hasDeltaXCheck() const =0
const MathLib::VecNormType _norm_type
virtual ~ConvergenceCriterion()=default
bool checkRelativeTolerance(const double reltol, const double numerator, const double denominator)
std::unique_ptr< ConvergenceCriterion > createConvergenceCriterion(const BaseLib::ConfigTree &config)
Creates a convergence criterion from the given configuration.