suanPan
Step.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (C) 2017-2024 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 = time_period > 0. ? 1E-8 : 0.; // minimum step size
46 double ini_step_size = time_period > 0. ? time_period : 1.; // 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
63
65
66#ifdef SUANPAN_MAGMA
67 magma_dopts magma_setting{};
68#endif
69
70 weak_ptr<DomainBase> database;
71 shared_ptr<Factory<double>> factory;
72 shared_ptr<Solver> solver;
73 shared_ptr<Converger> tester;
74 shared_ptr<Integrator> modifier;
75
76 void configure_storage_scheme() const;
77
78public:
79 explicit Step(unsigned = 0, double = 1.);
80 Step(const Step&) = delete;
81 Step(Step&&) noexcept = delete;
82 Step& operator=(const Step&) = delete;
83 Step& operator=(Step&&) noexcept = delete;
84 ~Step() override = default;
85
86 virtual int initialize();
87
88 virtual int analyze() = 0;
89
90 void set_domain(const weak_ptr<DomainBase>&);
91 [[nodiscard]] const weak_ptr<DomainBase>& get_domain() const;
92
93 void set_factory(const shared_ptr<Factory<double>>&);
94 [[nodiscard]] const shared_ptr<Factory<double>>& get_factory() const;
95
96 void set_solver_tag(unsigned);
97 void set_solver(const shared_ptr<Solver>&);
98 [[nodiscard]] const shared_ptr<Solver>& get_solver() const;
99
100 void set_converger_tag(unsigned);
101 void set_converger(const shared_ptr<Converger>&);
102 [[nodiscard]] const shared_ptr<Converger>& get_converger() const;
103
104 void set_integrator_tag(unsigned);
105 void set_integrator(const shared_ptr<Integrator>&);
106 [[nodiscard]] const shared_ptr<Integrator>& get_integrator() const;
107
108 void set_time_period(double);
109 void set_time_left(double);
110 [[nodiscard]] double get_time_period() const;
111 [[nodiscard]] double get_time_left() const;
112
113 void set_ini_step_size(double);
114 void set_min_step_size(double);
115 void set_max_step_size(double);
116 void set_max_substep(unsigned);
122 void set_tolerance(double);
123 void set_refinement(unsigned);
124 void set_lis_option(std::string_view);
125#ifdef SUANPAN_MAGMA
126 void set_magma_option(const magma_dopts& magma_opt) { magma_setting = magma_opt; }
127#endif
128
129 [[nodiscard]] double get_ini_step_size() const;
130 [[nodiscard]] double get_min_step_size() const;
131 [[nodiscard]] double get_max_step_size() const;
132 [[nodiscard]] unsigned get_max_substep() const;
133
134 [[nodiscard]] bool is_fixed_step_size() const;
135 void set_fixed_step_size(bool);
136
137 [[nodiscard]] bool is_symm() const;
138 [[nodiscard]] bool is_band() const;
139 [[nodiscard]] bool is_sparse() const;
140 void set_symm(bool) const;
141 void set_band(bool) const;
142 void set_sparse(bool) const;
143};
144
145#endif
146
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:104
A Factory class.
Definition: Factory.hpp:73
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:147
const weak_ptr< DomainBase > & get_domain() const
Definition: Step.cpp:78
void set_integrator_tag(unsigned)
Definition: Step.cpp:96
void set_sparse(bool) const
Definition: Step.cpp:177
const shared_ptr< Solver > & get_solver() const
Definition: Step.cpp:88
void set_converger_tag(unsigned)
Definition: Step.cpp:90
void set_integrator(const shared_ptr< Integrator > &)
Definition: Step.cpp:98
void set_band(bool) const
Definition: Step.cpp:175
void set_preconditioner(PreconditionerType)
Definition: Step.cpp:145
void set_factory(const shared_ptr< Factory< double > > &)
Definition: Step.cpp:80
void set_refinement(unsigned)
Definition: Step.cpp:151
bool is_band() const
Definition: Step.cpp:169
void set_system_solver(SolverType)
Definition: Step.cpp:136
void set_max_substep(unsigned)
Definition: Step.cpp:134
bool is_symm() const
Definition: Step.cpp:167
double get_time_period() const
Definition: Step.cpp:116
SolverType sub_system_solver
Definition: Step.h:64
weak_ptr< DomainBase > database
Definition: Step.h:70
virtual int initialize()
Definition: Step.cpp:37
unsigned get_max_substep() const
Definition: Step.cpp:161
void set_sub_system_solver(SolverType)
Definition: Step.cpp:143
double get_ini_step_size() const
Definition: Step.cpp:155
void set_max_step_size(double)
Definition: Step.cpp:132
Step(unsigned=0, double=1.)
Definition: Step.cpp:33
const shared_ptr< Factory< double > > & get_factory() const
Definition: Step.cpp:82
void set_solver(const shared_ptr< Solver > &)
Definition: Step.cpp:86
const bool band_mat
Definition: Step.h:58
const shared_ptr< Converger > & get_converger() const
Definition: Step.cpp:94
void set_lis_option(std::string_view)
Definition: Step.cpp:153
double get_max_step_size() const
Definition: Step.cpp:159
SolverSetting< double > system_setting
Definition: Step.h:62
virtual int analyze()=0
SolverType system_solver
Definition: Step.h:61
void set_symm(bool) const
Definition: Step.cpp:173
const bool symm_mat
Definition: Step.h:57
void set_fixed_step_size(bool)
Definition: Step.cpp:165
void set_solver_tag(unsigned)
Definition: Step.cpp:84
void set_tolerance(double)
Definition: Step.cpp:149
void configure_storage_scheme() const
Definition: Step.cpp:25
bool is_sparse() const
Definition: Step.cpp:171
shared_ptr< Integrator > modifier
Definition: Step.h:74
shared_ptr< Solver > solver
Definition: Step.h:72
bool is_fixed_step_size() const
Definition: Step.cpp:163
void set_time_period(double)
Definition: Step.cpp:102
double get_time_left() const
Definition: Step.cpp:118
Step(Step &&) noexcept=delete
void set_converger(const shared_ptr< Converger > &)
Definition: Step.cpp:92
void set_ini_step_size(double)
Definition: Step.cpp:120
void set_min_step_size(double)
Definition: Step.cpp:130
void set_domain(const weak_ptr< DomainBase > &)
Definition: Step.cpp:76
double get_min_step_size() const
Definition: Step.cpp:157
const shared_ptr< Integrator > & get_integrator() const
Definition: Step.cpp:100
shared_ptr< Converger > tester
Definition: Step.h:73
void set_time_left(double)
Definition: Step.cpp:114
shared_ptr< Factory< double > > factory
Definition: Step.h:71
A base Tag class.
Definition: Tag.h:38
SolverType
Definition: Factory.hpp:61