suanPan
🧮 An Open Source, Parallel and Heterogeneous Finite Element Analysis Framework
Loading...
Searching...
No Matches
Converger.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (C) 2017-2026 Theodore Chang
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
37#ifndef CONVERGER_H
38#define CONVERGER_H
39
40#include <Domain/Tag.h>
41
42class DomainBase;
43
44class Converger : public CopyableTag {
45 std::weak_ptr<DomainBase> database;
47 double tolerance;
49 unsigned max_iteration;
51 const bool print_flag;
53 double error = 0.;
55 bool conv_flag = false;
57protected:
58 [[nodiscard]] vec get_residual() const;
59
60 [[nodiscard]] bool is_print() const;
61
62public:
63 explicit Converger(unsigned = 0, double = 1E-8, unsigned = 10, bool = false);
64
65 virtual int initialize();
66
67 virtual unique_ptr<Converger> unique_copy() = 0;
68
69 void set_tolerance(double);
70 [[nodiscard]] double get_tolerance() const;
71
72 void set_max_iteration(unsigned);
73 [[nodiscard]] unsigned get_max_iteration() const;
74
75 void set_domain(const std::weak_ptr<DomainBase>&);
76 [[nodiscard]] const std::weak_ptr<DomainBase>& get_domain() const;
77
78 virtual void set_error(double);
79 [[nodiscard]] double get_error() const;
80
81 virtual void set_conv_flag(bool);
82 [[nodiscard]] bool get_conv_flag() const;
83
84 virtual bool is_converged(unsigned) = 0;
85};
86
87#endif
88
The Converger class handles converger test to indicate if the iteration converges according to variou...
Definition Converger.h:44
bool is_print() const
method to return print_flag.
Definition Converger.cpp:115
void set_domain(const std::weak_ptr< DomainBase > &)
method to set DomainBase.
Definition Converger.cpp:65
double get_tolerance() const
method to return tolerance.
Definition Converger.cpp:55
virtual unique_ptr< Converger > unique_copy()=0
virtual bool is_converged(unsigned)=0
bool get_conv_flag() const
method to return conv_flag.
Definition Converger.cpp:97
virtual int initialize()
Definition Converger.cpp:36
void set_tolerance(double)
method to set tolerance.
Definition Converger.cpp:49
const std::weak_ptr< DomainBase > & get_domain() const
method to return DomainBase.
Definition Converger.cpp:73
vec get_residual() const
Definition Converger.cpp:99
virtual void set_error(double)
method to set error.
Definition Converger.cpp:79
double get_error() const
method to return error.
Definition Converger.cpp:85
virtual void set_conv_flag(bool)
method to set conv_flag.
Definition Converger.cpp:91
unsigned get_max_iteration() const
Definition Converger.cpp:59
void set_max_iteration(unsigned)
Definition Converger.cpp:57
Label objects that can be copied.
Definition Tag.h:73
The DomainBase class is a template.
Definition DomainBase.h:94