22 std::vector<double>&& absolute_tolerances,
23 std::vector<double>&& relative_tolerances,
26 _abstols(std::move(absolute_tolerances)),
27 _reltols(std::move(relative_tolerances)),
28 _residual_norms_0(_abstols.size())
33 "The number of absolute and relative tolerances given must be the "
39 OGS_FATAL(
"The given tolerances vector is empty.");
48 OGS_FATAL(
"D.o.f. table or mesh have not been set.");
51 for (
unsigned global_component = 0; global_component <
_abstols.size();
61 "Convergence criterion, component {:d}: |dx|={:.4e}, |x|={:.4e}, "
63 global_component, error_dx, norm_x,
64 (norm_x == 0. ? std::numeric_limits<double>::quiet_NaN()
65 : (error_dx / norm_x)));
74 OGS_FATAL(
"D.o.f. table or mesh have not been set.");
77 for (
unsigned global_component = 0; global_component <
_abstols.size();
86 INFO(
"Convergence criterion, component {:d}: |r0|={:.4e}",
87 global_component, norm_res);
94 "Convergence criterion, component {:d}: |r|={:.4e}, "
95 "|r0|={:.4e}, |r|/|r0|={:.4e}",
96 global_component, norm_res, norm_res0,
97 (norm_res0 == 0. ? std::numeric_limits<double>::quiet_NaN()
98 : (norm_res / norm_res0)));
101 bool const satisfied_abs = norm_res <
_abstols[global_component];
104 bool const satisfied_rel =
122 "The number of components in the DOF table and the number of "
123 "tolerances given do not match.");
127std::unique_ptr<ConvergenceCriterionPerComponentResidual>
140 auto const norm_type_str =
144 if ((!abstols) && (!reltols))
147 "At least one of absolute or relative tolerance has to be "
152 abstols = std::vector<double>(reltols->size());
156 reltols = std::vector<double>(abstols->size());
163 OGS_FATAL(
"Unknown vector norm type `{:s}'.", norm_type_str);
166 return std::make_unique<ConvergenceCriterionPerComponentResidual>(
167 std::move(*abstols), std::move(*reltols), norm_type);
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
std::optional< T > getConfigParameterOptional(std::string const ¶m) const
T getConfigParameter(std::string const ¶m) const
void checkConfigParameter(std::string const ¶m, std::string_view const value) const
Global vector based on Eigen vector.
MeshLib::Mesh const * _mesh
void setDOFTable(const LocalToGlobalIndexMap &dof_table, MeshLib::Mesh const &mesh) override
Sets the d.o.f. table used to extract data for a specific component.
const std::vector< double > _abstols
LocalToGlobalIndexMap const * _dof_table
void checkResidual(const GlobalVector &residual) override
Check if the residual satisfies the convergence criterion.
void checkDeltaX(const GlobalVector &minus_delta_x, GlobalVector const &x) override
std::vector< double > _residual_norms_0
ConvergenceCriterionPerComponentResidual(std::vector< double > &&absolute_tolerances, std::vector< double > &&relative_tolerances, const MathLib::VecNormType norm_type)
const std::vector< double > _reltols
const MathLib::VecNormType _norm_type
int getNumberOfGlobalComponents() const
VecNormType convertStringToVecNormType(const std::string &str)
convert string to VecNormType
double norm(GlobalVector const &x, unsigned const global_component, MathLib::VecNormType norm_type, LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
bool checkRelativeTolerance(const double reltol, const double numerator, const double denominator)
std::unique_ptr< ConvergenceCriterionPerComponentResidual > createConvergenceCriterionPerComponentResidual(const BaseLib::ConfigTree &config)