25 std::vector<double>&& absolute_tolerances,
26 std::vector<double>&& relative_tolerances,
27 std::vector<double>&& damping_alpha,
28 bool damping_alpha_switch,
31 _abstols(std::move(absolute_tolerances)),
32 _reltols(std::move(relative_tolerances)),
33 _damping_alpha(std::move(damping_alpha)),
34 _damping_alpha_switch(damping_alpha_switch)
39 "The number of absolute and relative tolerances given must be the "
45 OGS_FATAL(
"The given tolerances vector is empty.");
54 OGS_FATAL(
"D.o.f. table has not been set.");
57 for (
unsigned global_component = 0; global_component <
_abstols.size();
66 "Convergence criterion, component {:d}: |dx|={:.4e}, |x|={:.4e}, "
68 global_component, error_dx, norm_x,
69 (norm_x == 0. ? std::numeric_limits<double>::quiet_NaN()
70 : (error_dx / norm_x)));
72 bool const satisfied_abs = error_dx <
_abstols[global_component];
74 _reltols[global_component], error_dx, norm_x);
86 OGS_FATAL(
"D.o.f. table has not been set.");
90 double damping_final = 1;
91 for (
unsigned global_component = 0;
97 DBUG(
"Non-negative damping for component: {:d} alpha: {:g}",
103 damping_final = std::min(
105 damping_orig / std::max(1.0, (minus_delta_x.
get(index) *
110 DBUG(
"Final damping value due to non-negative damping: {:g}",
112 return damping_final;
125 "The number of components in the DOF table and the number of "
126 "tolerances given do not match.");
130std::unique_ptr<ConvergenceCriterionPerComponentDeltaX>
145 auto const norm_type_str =
149 bool damping_alpha_switch =
true;
150 if ((!abstols) && (!reltols))
153 "At least one of absolute or relative tolerance has to be "
158 abstols = std::vector<double>(reltols->size());
162 reltols = std::vector<double>(abstols->size());
166 damping_alpha = std::vector<double>(abstols->size(), 0.0);
167 damping_alpha_switch =
false;
174 OGS_FATAL(
"Unknown vector norm type `{:s}'.", norm_type_str);
177 return std::make_unique<ConvergenceCriterionPerComponentDeltaX>(
178 std::move(*abstols), std::move(*reltols), std::move(*damping_alpha),
179 damping_alpha_switch, norm_type);
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(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.
double get(IndexType rowId) const
get entry
std::size_t getID() const
Get id of the mesh.
LocalToGlobalIndexMap const * _dof_table
ConvergenceCriterionPerComponentDeltaX(std::vector< double > &&absolute_tolerances, std::vector< double > &&relative_tolerances, std::vector< double > &&damping_alpha, bool daming_alpha_switch, const MathLib::VecNormType norm_type)
double getDampingFactor(const GlobalVector &minus_delta_x, GlobalVector const &x, double damping_orig) override
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.
const std::vector< double > _reltols
const std::vector< double > _damping_alpha
MeshLib::Mesh const * _mesh
const std::vector< double > _abstols
const MathLib::VecNormType _norm_type
GlobalIndexType getGlobalIndex(MeshLib::Location const &l, int const variable_id, int const component_id) const
MeshLib::MeshSubset const & getMeshSubset(int const variable_id, int const component_id) const
int getNumberOfGlobalComponents() const
void setLocalAccessibleVector(PETScVector const &x)
VecNormType convertStringToVecNormType(const std::string &str)
convert string to VecNormType
auto meshLocations(Mesh const &mesh, MeshItemType const item_type)
bool checkRelativeTolerance(const double reltol, const double numerator, const double denominator)
std::unique_ptr< ConvergenceCriterionPerComponentDeltaX > createConvergenceCriterionPerComponentDeltaX(const BaseLib::ConfigTree &config)
double norm(GlobalVector const &x, unsigned const global_component, MathLib::VecNormType norm_type, LocalToGlobalIndexMap const &dof_table)