suanPan
Step.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (C) 2017-2022 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  ******************************************************************************/
28 #ifndef STEP_H
29 #define STEP_H
30 
31 #include <Domain/Factory.hpp>
32 #include <Domain/Tag.h>
33 
34 class DomainBase;
35 class Solver;
36 class Converger;
37 class Integrator;
38 
39 class Step : public Tag {
40  double time_period = 1.0; // time period
41 
42  double time_left = time_period;
43 
44  double max_step_size = time_period; // maximum step size
45  double min_step_size = 1E-8; // minimum step size
46  double ini_step_size = time_period; // initial step size
47 
48  double tolerance = 1E-12;
49 
50  unsigned max_substep = 1000; // maximum increment number
51  unsigned refinement = 10;
52 
53  bool fixed_step_size = false; // auto-stepping
54 
55  unsigned solver_tag = 0;
56  unsigned converger_tag = 0;
57  unsigned integrator_tag = 0;
58 
59 protected:
60  const bool symm_mat = false;
61  const bool band_mat = true;
62  const bool sparse_mat = false;
63 
66 
67  weak_ptr<DomainBase> database;
68  shared_ptr<Factory<double>> factory;
69  shared_ptr<Solver> solver;
70  shared_ptr<Converger> tester;
71  shared_ptr<Integrator> modifier;
72 
73  void configure_storage_scheme() const;
74 
75 public:
76  explicit Step(unsigned = 0, double = 1.);
77  Step(const Step&) = delete;
78  Step(Step&&) noexcept = delete;
79  Step& operator=(const Step&) = delete;
80  Step& operator=(Step&&) noexcept = delete;
81  ~Step() override;
82 
83  virtual int initialize();
84 
85  virtual int analyze() = 0;
86 
87  void set_domain(const weak_ptr<DomainBase>&);
88  [[nodiscard]] const weak_ptr<DomainBase>& get_domain() const;
89 
90  void set_factory(const shared_ptr<Factory<double>>&);
91  [[nodiscard]] const shared_ptr<Factory<double>>& get_factory() const;
92 
93  void set_solver_tag(unsigned);
94  void set_solver(const shared_ptr<Solver>&);
95  [[nodiscard]] const shared_ptr<Solver>& get_solver() const;
96 
97  void set_converger_tag(unsigned);
98  void set_converger(const shared_ptr<Converger>&);
99  [[nodiscard]] const shared_ptr<Converger>& get_converger() const;
100 
101  void set_integrator_tag(unsigned);
102  void set_integrator(const shared_ptr<Integrator>&);
103  [[nodiscard]] const shared_ptr<Integrator>& get_integrator() const;
104 
105  void set_time_period(double);
106  void set_time_left(double);
107  [[nodiscard]] double get_time_period() const;
108  [[nodiscard]] double get_time_left() const;
109 
110  void set_ini_step_size(double);
111  void set_min_step_size(double);
112  void set_max_step_size(double);
113  void set_max_substep(unsigned);
115  void set_precision(Precision);
116  void set_tolerance(double);
117  void set_refinement(unsigned);
118 
119  [[nodiscard]] double get_ini_step_size() const;
120  [[nodiscard]] double get_min_step_size() const;
121  [[nodiscard]] double get_max_step_size() const;
122  [[nodiscard]] unsigned get_max_substep() const;
123  [[nodiscard]] SolverType get_system_solver() const;
124  [[nodiscard]] Precision get_precision() const;
125  [[nodiscard]] double get_tolerance() const;
126 
127  [[nodiscard]] bool is_fixed_step_size() const;
128  void set_fixed_step_size(bool);
129 
130  [[nodiscard]] bool is_symm() const;
131  [[nodiscard]] bool is_band() const;
132  [[nodiscard]] bool is_sparse() const;
133  void set_symm(bool) const;
134  void set_band(bool) const;
135  void set_sparse(bool) const;
136 };
137 
138 #endif
139 
const bool sparse_mat
Definition: Step.h:62
void set_refinement(unsigned)
Definition: Step.cpp:139
void set_domain(const weak_ptr< DomainBase > &)
Definition: Step.cpp:76
void set_band(bool) const
Definition: Step.cpp:167
void set_time_period(double)
Definition: Step.cpp:102
The DomainBase class is a template.
Definition: DomainBase.h:90
void set_converger(const shared_ptr< Converger > &)
Definition: Step.cpp:92
void set_tolerance(double)
Definition: Step.cpp:137
A Factory class.
Definition: DomainBase.h:44
double get_ini_step_size() const
Definition: Step.cpp:141
double get_time_left() const
Definition: Step.cpp:119
shared_ptr< Factory< double > > factory
Definition: Step.h:68
double get_max_step_size() const
Definition: Step.cpp:145
const bool symm_mat
Definition: Step.h:60
weak_ptr< DomainBase > database
Definition: Step.h:67
void set_precision(Precision)
Definition: Step.cpp:135
void set_solver(const shared_ptr< Solver > &)
Definition: Step.cpp:86
void set_factory(const shared_ptr< Factory< double >> &)
Definition: Step.cpp:80
const shared_ptr< Integrator > & get_integrator() const
Definition: Step.cpp:100
void set_integrator(const shared_ptr< Integrator > &)
Definition: Step.cpp:98
void set_max_substep(unsigned)
Definition: Step.cpp:131
double get_time_period() const
Definition: Step.cpp:117
bool is_fixed_step_size() const
Definition: Step.cpp:155
shared_ptr< Solver > solver
Definition: Step.h:69
const bool band_mat
Definition: Step.h:61
SolverType system_solver
Definition: Step.h:64
const shared_ptr< Factory< double > > & get_factory() const
Definition: Step.cpp:82
void set_min_step_size(double)
Definition: Step.cpp:127
const weak_ptr< DomainBase > & get_domain() const
Definition: Step.cpp:78
A Solver class defines solvers used in analysis.
Definition: Solver.h:38
void set_fixed_step_size(bool)
Definition: Step.cpp:157
double get_tolerance() const
Definition: Step.cpp:153
SolverType
Definition: Factory.hpp:57
bool is_symm() const
Definition: Step.cpp:159
void set_max_step_size(double)
Definition: Step.cpp:129
void set_integrator_tag(unsigned)
Definition: Step.cpp:96
The Integrator class is basically a wrapper of the DomainBase class with regard to some status changi...
Definition: Integrator.h:46
Step(unsigned=0, double=1.)
Definition: Step.cpp:33
virtual int initialize()
Definition: Step.cpp:39
The Converger class handles converger test to indicate if the iteration converges according to variou...
Definition: Converger.h:44
A base Tag class.
Definition: Tag.h:38
SolverType get_system_solver() const
Definition: Step.cpp:149
Precision get_precision() const
Definition: Step.cpp:151
void set_sparse(bool) const
Definition: Step.cpp:169
virtual int analyze()=0
void set_symm(bool) const
Definition: Step.cpp:165
void set_converger_tag(unsigned)
Definition: Step.cpp:90
bool is_band() const
Definition: Step.cpp:161
double get_min_step_size() const
Definition: Step.cpp:143
A Step class.
Definition: Step.h:39
void set_time_left(double)
Definition: Step.cpp:115
bool is_sparse() const
Definition: Step.cpp:163
void set_ini_step_size(double)
Definition: Step.cpp:121
void set_system_solver(SolverType)
Definition: Step.cpp:133
void set_solver_tag(unsigned)
Definition: Step.cpp:84
shared_ptr< Converger > tester
Definition: Step.h:70
void configure_storage_scheme() const
Definition: Step.cpp:25
unsigned get_max_substep() const
Definition: Step.cpp:147
shared_ptr< Integrator > modifier
Definition: Step.h:71
Precision precision
Definition: Step.h:65
const shared_ptr< Converger > & get_converger() const
Definition: Step.cpp:94
const shared_ptr< Solver > & get_solver() const
Definition: Step.cpp:88
Precision
Definition: MetaMat.hpp:34