suanPan
Loading...
Searching...
No Matches
Step.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (C) 2017-2023 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
34class DomainBase;
35class Solver;
36class Converger;
37class Integrator;
38
39class 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 unsigned max_substep = 1000; // maximum increment number
49
50 bool fixed_step_size = false; // auto-stepping
51
52 unsigned solver_tag = 0;
53 unsigned converger_tag = 0;
54 unsigned integrator_tag = 0;
55
56protected:
57 const bool symm_mat = false;
58 const bool band_mat = true;
59 const bool sparse_mat = false;
60
61 SolverType system_solver = SolverType::LAPACK;
63
64 weak_ptr<DomainBase> database;
65 shared_ptr<Factory<double>> factory;
66 shared_ptr<Solver> solver;
67 shared_ptr<Converger> tester;
68 shared_ptr<Integrator> modifier;
69
70 void configure_storage_scheme() const;
71
72public:
73 explicit Step(unsigned = 0, double = 1.);
74 Step(const Step&) = delete;
75 Step(Step&&) noexcept = delete;
76 Step& operator=(const Step&) = delete;
77 Step& operator=(Step&&) noexcept = delete;
78 ~Step() override = default;
79
80 virtual int initialize();
81
82 virtual int analyze() = 0;
83
84 void set_domain(const weak_ptr<DomainBase>&);
85 [[nodiscard]] const weak_ptr<DomainBase>& get_domain() const;
86
87 void set_factory(const shared_ptr<Factory<double>>&);
88 [[nodiscard]] const shared_ptr<Factory<double>>& get_factory() const;
89
90 void set_solver_tag(unsigned);
91 void set_solver(const shared_ptr<Solver>&);
92 [[nodiscard]] const shared_ptr<Solver>& get_solver() const;
93
94 void set_converger_tag(unsigned);
95 void set_converger(const shared_ptr<Converger>&);
96 [[nodiscard]] const shared_ptr<Converger>& get_converger() const;
97
98 void set_integrator_tag(unsigned);
99 void set_integrator(const shared_ptr<Integrator>&);
100 [[nodiscard]] const shared_ptr<Integrator>& get_integrator() const;
101
102 void set_time_period(double);
103 void set_time_left(double);
104 [[nodiscard]] double get_time_period() const;
105 [[nodiscard]] double get_time_left() const;
106
107 void set_ini_step_size(double);
108 void set_min_step_size(double);
109 void set_max_step_size(double);
110 void set_max_substep(unsigned);
115 void set_tolerance(double);
116 void set_refinement(unsigned);
117
118 [[nodiscard]] double get_ini_step_size() const;
119 [[nodiscard]] double get_min_step_size() const;
120 [[nodiscard]] double get_max_step_size() const;
121 [[nodiscard]] unsigned get_max_substep() const;
122
123 [[nodiscard]] bool is_fixed_step_size() const;
124 void set_fixed_step_size(bool);
125
126 [[nodiscard]] bool is_symm() const;
127 [[nodiscard]] bool is_band() const;
128 [[nodiscard]] bool is_sparse() const;
129 void set_symm(bool) const;
130 void set_band(bool) const;
131 void set_sparse(bool) const;
132};
133
134#endif
135
PreconditionerType
Definition: SolverSetting.hpp:34
Precision
Definition: SolverSetting.hpp:23
IterativeSolver
Definition: SolverSetting.hpp:28
The Converger class handles converger test to indicate if the iteration converges according to variou...
Definition: Converger.h:44
The DomainBase class is a template.
Definition: DomainBase.h:96
A Factory class.
Definition: Factory.hpp:67
The Integrator class is basically a wrapper of the DomainBase class with regard to some status changi...
Definition: Integrator.h:51
A Solver class defines solvers used in analysis.
Definition: Solver.h:38
A Step class.
Definition: Step.h:39
Step(const Step &)=delete
const bool sparse_mat
Definition: Step.h:59
void set_precision(Precision)
Definition: Step.cpp:138
const weak_ptr< DomainBase > & get_domain() const
Definition: Step.cpp:74
void set_integrator_tag(unsigned)
Definition: Step.cpp:92
void set_sparse(bool) const
Definition: Step.cpp:166
const shared_ptr< Solver > & get_solver() const
Definition: Step.cpp:84
void set_converger_tag(unsigned)
Definition: Step.cpp:86
void set_integrator(const shared_ptr< Integrator > &)
Definition: Step.cpp:94
void set_band(bool) const
Definition: Step.cpp:164
void set_preconditioner(PreconditionerType)
Definition: Step.cpp:136
void set_factory(const shared_ptr< Factory< double > > &)
Definition: Step.cpp:76
void set_refinement(unsigned)
Definition: Step.cpp:142
bool is_band() const
Definition: Step.cpp:158
void set_system_solver(SolverType)
Definition: Step.cpp:129
void set_max_substep(unsigned)
Definition: Step.cpp:127
bool is_symm() const
Definition: Step.cpp:156
double get_time_period() const
Definition: Step.cpp:113
weak_ptr< DomainBase > database
Definition: Step.h:64
virtual int initialize()
Definition: Step.cpp:37
unsigned get_max_substep() const
Definition: Step.cpp:150
double get_ini_step_size() const
Definition: Step.cpp:144
void set_max_step_size(double)
Definition: Step.cpp:125
const shared_ptr< Factory< double > > & get_factory() const
Definition: Step.cpp:78
void set_solver(const shared_ptr< Solver > &)
Definition: Step.cpp:82
const bool band_mat
Definition: Step.h:58
const shared_ptr< Converger > & get_converger() const
Definition: Step.cpp:90
double get_max_step_size() const
Definition: Step.cpp:148
SolverSetting< double > setting
Definition: Step.h:62
virtual int analyze()=0
SolverType system_solver
Definition: Step.h:61
void set_symm(bool) const
Definition: Step.cpp:162
const bool symm_mat
Definition: Step.h:57
void set_fixed_step_size(bool)
Definition: Step.cpp:154
void set_solver_tag(unsigned)
Definition: Step.cpp:80
void set_tolerance(double)
Definition: Step.cpp:140
void configure_storage_scheme() const
Definition: Step.cpp:25
bool is_sparse() const
Definition: Step.cpp:160
shared_ptr< Integrator > modifier
Definition: Step.h:68
shared_ptr< Solver > solver
Definition: Step.h:66
bool is_fixed_step_size() const
Definition: Step.cpp:152
void set_time_period(double)
Definition: Step.cpp:98
double get_time_left() const
Definition: Step.cpp:115
Step(Step &&) noexcept=delete
void set_converger(const shared_ptr< Converger > &)
Definition: Step.cpp:88
void set_ini_step_size(double)
Definition: Step.cpp:117
void set_min_step_size(double)
Definition: Step.cpp:123
void set_domain(const weak_ptr< DomainBase > &)
Definition: Step.cpp:72
double get_min_step_size() const
Definition: Step.cpp:146
const shared_ptr< Integrator > & get_integrator() const
Definition: Step.cpp:96
shared_ptr< Converger > tester
Definition: Step.h:67
void set_time_left(double)
Definition: Step.cpp:111
shared_ptr< Factory< double > > factory
Definition: Step.h:65
A base Tag class.
Definition: Tag.h:38
SolverType
Definition: Factory.hpp:57
Definition: SolverSetting.hpp:40