OGS
ConvergenceCriterion.cpp
Go to the documentation of this file.
1
12
13#include "BaseLib/ConfigTree.h"
14#include "BaseLib/Error.h"
19
20namespace NumLib
21{
22std::unique_ptr<ConvergenceCriterion> createConvergenceCriterion(
23 const BaseLib::ConfigTree& config)
24{
26 auto const type = config.peekConfigParameter<std::string>("type");
27
28 if (type == "DeltaX")
29 {
31 }
32 if (type == "Residual")
33 {
35 }
36 if (type == "PerComponentDeltaX")
37 {
39 }
40 if (type == "PerComponentResidual")
41 {
43 }
44
45 OGS_FATAL("There is no convergence criterion of type `{:s}'.", type);
46}
47
48bool checkRelativeTolerance(const double reltol, const double numerator,
49 const double denominator)
50{
51 auto const eps = std::numeric_limits<double>::epsilon();
52 return std::abs(numerator) <
53 std::abs(reltol) * (std::abs(denominator) + eps);
54}
55
56} // namespace NumLib
#define OGS_FATAL(...)
Definition Error.h:26
T peekConfigParameter(std::string const &param) const
bool checkRelativeTolerance(const double reltol, const double numerator, const double denominator)
std::unique_ptr< ConvergenceCriterionResidual > createConvergenceCriterionResidual(const BaseLib::ConfigTree &config)
std::unique_ptr< ConvergenceCriterionPerComponentDeltaX > createConvergenceCriterionPerComponentDeltaX(const BaseLib::ConfigTree &config)
std::unique_ptr< ConvergenceCriterion > createConvergenceCriterion(const BaseLib::ConfigTree &config)
Creates a convergence criterion from the given configuration.
std::unique_ptr< ConvergenceCriterionDeltaX > createConvergenceCriterionDeltaX(const BaseLib::ConfigTree &config)
std::unique_ptr< ConvergenceCriterionPerComponentResidual > createConvergenceCriterionPerComponentResidual(const BaseLib::ConfigTree &config)