23 std::vector<double>&& absolute_tolerances,
24 std::vector<double>&& relative_tolerances,
27 _abstols(std::move(absolute_tolerances)),
28 _reltols(std::move(relative_tolerances))
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)));
67 bool const satisfied_abs = error_dx <
_abstols[global_component];
69 _reltols[global_component], error_dx, norm_x);
85 "The number of components in the DOF table and the number of "
86 "tolerances given do not match.");
90std::unique_ptr<ConvergenceCriterionPerComponentDeltaX>
102 auto const norm_type_str =
106 if ((!abstols) && (!reltols))
109 "At least one of absolute or relative tolerance has to be "
114 abstols = std::vector<double>(reltols->size());
118 reltols = std::vector<double>(abstols->size());
125 OGS_FATAL(
"Unknown vector norm type `{:s}'.", norm_type_str);
128 return std::make_unique<ConvergenceCriterionPerComponentDeltaX>(
129 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.
LocalToGlobalIndexMap const * _dof_table
void checkDeltaX(const GlobalVector &minus_delta_x, GlobalVector const &x) override
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.
ConvergenceCriterionPerComponentDeltaX(std::vector< double > &&absolute_tolerances, std::vector< double > &&relative_tolerances, const MathLib::VecNormType norm_type)
const std::vector< double > _reltols
MeshLib::Mesh const * _mesh
const std::vector< double > _abstols
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< ConvergenceCriterionPerComponentDeltaX > createConvergenceCriterionPerComponentDeltaX(const BaseLib::ConfigTree &config)