OGS
ConvergenceCriterionPerComponentResidual.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <vector>
7
9#include "DampingPolicy.h"
11
12namespace NumLib
13{
15
24 public DampingPolicy
25{
26public:
28 std::vector<double>&& absolute_tolerances,
29 std::vector<double>&& relative_tolerances,
30 std::vector<double>&& damping_alpha,
31 bool daming_alpha_switch,
32 const MathLib::VecNormType norm_type);
33
34 bool hasDeltaXCheck() const override { return true; }
35 bool hasResidualCheck() const override { return true; }
36 DampingPolicy const* dampingPolicy() const override
37 {
38 return _damping_alpha_switch ? this : nullptr;
39 }
40
43 void checkDeltaX(const GlobalVector& minus_delta_x,
44 GlobalVector const& x) override;
45 void checkResidual(const GlobalVector& residual) override;
46 double apply(GlobalVector const& minus_delta_x,
47 GlobalVector const& x,
48 double const base_damping) const override;
49
50 void setDOFTable(const LocalToGlobalIndexMap& dof_table,
51 MeshLib::Mesh const& mesh) override;
52
53private:
54 const std::vector<double> _abstols;
55 const std::vector<double> _reltols;
57 MeshLib::Mesh const* _mesh = nullptr;
58 std::vector<double> _residual_norms_0;
59 const std::vector<double> _damping_alpha;
61};
62
63std::unique_ptr<ConvergenceCriterionPerComponentResidual>
65 BaseLib::ConfigTree const& config);
66
67} // namespace NumLib
MathLib::EigenVector GlobalVector
double apply(GlobalVector const &minus_delta_x, GlobalVector const &x, double const base_damping) const override
ConvergenceCriterionPerComponentResidual(std::vector< double > &&absolute_tolerances, std::vector< double > &&relative_tolerances, std::vector< double > &&damping_alpha, bool daming_alpha_switch, const MathLib::VecNormType norm_type)
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.
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
ConvergenceCriterionPerComponent(const MathLib::VecNormType norm_type)
std::unique_ptr< ConvergenceCriterionPerComponentResidual > createConvergenceCriterionPerComponentResidual(const BaseLib::ConfigTree &config)