11 #include <logog/include/logog.hpp> 21 std::vector<double>&& absolute_tolerances,
22 std::vector<double>&& relative_tolerances,
25 _abstols(std::move(absolute_tolerances)),
26 _reltols(std::move(relative_tolerances))
30 "The number of absolute and relative tolerances given must be the " 34 OGS_FATAL(
"The given tolerances vector is empty.");
38 const GlobalVector& minus_delta_x, GlobalVector
const& x)
41 OGS_FATAL(
"D.o.f. table or mesh have not been set.");
43 bool satisfied_abs =
true;
44 bool satisfied_rel =
true;
46 for (
unsigned global_component = 0; global_component <
_abstols.size();
56 "Convergence criterion, component %u: |dx|=%.4e, |x|=%.4e, " 58 error_dx, global_component, norm_x,
59 (norm_x == 0. ? std::numeric_limits<double>::quiet_NaN()
60 : (error_dx / norm_x)));
62 satisfied_abs = satisfied_abs && error_dx <
_abstols[global_component];
80 "The number of components in the DOF table and the number of " 81 "tolerances given do not match.");
84 std::unique_ptr<ConvergenceCriterionPerComponentDeltaX>
96 auto const norm_type_str =
100 if ((!abstols) && (!reltols))
102 "At least one of absolute or relative tolerance has to be " 105 abstols = std::vector<double>(reltols->size());
106 }
else if (!reltols) {
107 reltols = std::vector<double>(abstols->size());
113 OGS_FATAL(
"Unknown vector norm type `%s'.", norm_type_str.c_str());
115 return std::make_unique<ConvergenceCriterionPerComponentDeltaX>(
116 std::move(*abstols), std::move(*reltols), norm_type);
const std::vector< double > _abstols
const std::vector< double > _reltols
VecNormType
Norm type. Not declared as class type in order to use the members as integers.
void checkDeltaX(const GlobalVector &minus_delta_x, GlobalVector const &x) override
T getConfigParameter(std::string const ¶m) const
int getNumberOfComponents() const
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.
LocalToGlobalIndexMap const * _dof_table
void checkConfigParameter(std::string const ¶m, T const &value) const
bool checkRelativeTolerance(const double reltol, const double numerator, const double denominator)
ConvergenceCriterionPerComponentDeltaX(std::vector< double > &&absolute_tolerances, std::vector< double > &&relative_tolerances, const MathLib::VecNormType norm_type)
std::unique_ptr< ConvergenceCriterionPerComponentDeltaX > createConvergenceCriterionPerComponentDeltaX(const BaseLib::ConfigTree &config)
MeshLib::Mesh const * _mesh
boost::optional< T > getConfigParameterOptional(std::string const ¶m) const
#define OGS_FATAL(fmt,...)
const MathLib::VecNormType _norm_type
double norm(GlobalVector const &x, unsigned const global_component, MathLib::VecNormType norm_type, LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
VecNormType convertStringToVecNormType(const std::string &str)
convert string to VecNormType