suanPan
Integrator.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 ******************************************************************************/
39#ifndef INTEGRATOR_H
40#define INTEGRATOR_H
41
42#include <Domain/Tag.h>
43
44class DomainBase;
45
46enum class IntegratorType {
49};
50
51class Integrator : public Tag {
52 bool time_step_switch = true;
53 bool matrix_assembled_switch = false;
54
55 weak_ptr<DomainBase> database;
56
57public:
58 explicit Integrator(unsigned = 0);
59 Integrator(const Integrator&) = delete; // copy forbidden
60 Integrator(Integrator&&) = delete; // move forbidden
61 Integrator& operator=(const Integrator&) = delete; // assign forbidden
62 Integrator& operator=(Integrator&&) = delete; // assign forbidden
63 ~Integrator() override = default;
64
65 void set_domain(const weak_ptr<DomainBase>&);
66 [[nodiscard]] shared_ptr<DomainBase> get_domain() const;
67
68 virtual int initialize();
69
70 [[nodiscard]] virtual constexpr IntegratorType type() const { return IntegratorType::Implicit; }
71
72 // ! some multistep integrators may require fixed time step for some consecutive sub-steps
73 void set_time_step_switch(bool);
74 [[nodiscard]] bool allow_to_change_time_step() const;
75
76 // ! manually set switch after assembling global matrix
78 [[nodiscard]] bool matrix_is_assembled() const;
79
80 [[nodiscard]] virtual bool has_corrector() const;
81 [[nodiscard]] virtual bool time_independent_matrix() const;
82
83 [[nodiscard]] virtual int process_load();
84 [[nodiscard]] virtual int process_constraint();
85 [[nodiscard]] virtual int process_criterion();
86 [[nodiscard]] virtual int process_modifier();
87 [[nodiscard]] virtual int process_load_resistance();
88 [[nodiscard]] virtual int process_constraint_resistance();
89
90 void record() const;
91
92 virtual void assemble_resistance();
93 virtual void assemble_matrix();
94
95 virtual vec get_force_residual();
96 virtual vec get_displacement_residual();
97 virtual vec get_auxiliary_residual();
98 virtual sp_mat get_reference_load();
99
100 [[nodiscard]] virtual const vec& get_trial_displacement() const;
101
102 virtual void update_load();
103 virtual void update_constraint();
104
105 virtual void update_trial_load_factor(double);
106 virtual void update_trial_load_factor(const vec&);
107 virtual void update_from_ninja();
108
109 virtual void update_trial_time(double);
110 virtual void update_incre_time(double);
111
112 virtual int update_trial_status();
113 virtual int correct_trial_status();
114
115 virtual int sync_status(bool);
116
117 virtual int update_internal(const mat&);
118
119 mat solve(const mat&);
120 mat solve(const sp_mat&);
121 mat solve(mat&&);
122 mat solve(sp_mat&&);
123 virtual int solve(mat&, const mat&);
124 virtual int solve(mat&, const sp_mat&);
125 virtual int solve(mat&, mat&&);
126 virtual int solve(mat&, sp_mat&&);
127
128 virtual void erase_machine_error(vec&) const;
129
131
132 virtual void stage_status();
133 virtual void commit_status();
134 virtual void clear_status();
135 virtual void reset_status();
136
137 virtual void update_parameter(double);
138
139 virtual vec from_incre_velocity(const vec&, const uvec&); // obtain target displacement from increment of velocity
140 virtual vec from_incre_acceleration(const vec&, const uvec&); // obtain target displacement from increment of acceleration
141 virtual vec from_total_velocity(const vec&, const uvec&);
142 virtual vec from_total_acceleration(const vec&, const uvec&);
143 vec from_incre_velocity(double, const uvec&);
144 vec from_incre_acceleration(double, const uvec&);
145 vec from_total_velocity(double, const uvec&);
146 vec from_total_acceleration(double, const uvec&);
147};
148
150public:
152
153 [[nodiscard]] constexpr IntegratorType type() const override { return IntegratorType::Implicit; }
154
155 [[nodiscard]] bool time_independent_matrix() const override;
156};
157
159public:
161
162 [[nodiscard]] constexpr IntegratorType type() const override { return IntegratorType::Explicit; }
163
164 [[nodiscard]] const vec& get_trial_displacement() const override;
165
166 void update_from_ninja() override;
167
168 int solve(mat&, const mat&) override;
169 int solve(mat&, const sp_mat&) override;
170 int solve(mat&, mat&&) override;
171 int solve(mat&, sp_mat&&) override;
172
173 vec from_incre_velocity(const vec&, const uvec&) override;
174
175 vec from_incre_acceleration(const vec&, const uvec&) override; // obtain target acceleration from increment of acceleration
176 vec from_total_acceleration(const vec&, const uvec&) override;
177};
178
179#endif
180
The DomainBase class is a template.
Definition: DomainBase.h:104
Definition: Integrator.h:158
const vec & get_trial_displacement() const override
Definition: Integrator.cpp:359
void update_from_ninja() override
Definition: Integrator.cpp:361
vec from_total_acceleration(const vec &, const uvec &) override
Definition: Integrator.cpp:378
vec from_incre_acceleration(const vec &, const uvec &) override
Definition: Integrator.cpp:376
vec from_incre_velocity(const vec &, const uvec &) override
Definition: Integrator.cpp:374
constexpr IntegratorType type() const override
Definition: Integrator.h:162
int solve(mat &, const mat &) override
Definition: Integrator.cpp:366
Definition: Integrator.h:149
constexpr IntegratorType type() const override
Definition: Integrator.h:153
bool time_independent_matrix() const override
Definition: Integrator.cpp:357
The Integrator class is basically a wrapper of the DomainBase class with regard to some status changi...
Definition: Integrator.h:51
virtual void update_incre_time(double)
Definition: Integrator.cpp:184
virtual constexpr IntegratorType type() const
Definition: Integrator.h:70
void set_domain(const weak_ptr< DomainBase > &)
Definition: Integrator.cpp:25
Integrator & operator=(const Integrator &)=delete
virtual int update_trial_status()
Definition: Integrator.cpp:190
virtual int process_load_resistance()
Definition: Integrator.cpp:79
void set_matrix_assembled_switch(bool)
Definition: Integrator.cpp:45
virtual void update_trial_load_factor(double)
Definition: Integrator.cpp:166
virtual vec get_displacement_residual()
Definition: Integrator.cpp:138
virtual void update_load()
Definition: Integrator.cpp:162
virtual bool has_corrector() const
Definition: Integrator.cpp:49
virtual int process_constraint()
Definition: Integrator.cpp:61
virtual sp_mat get_reference_load()
Definition: Integrator.cpp:158
Integrator(const Integrator &)=delete
virtual int process_modifier()
Definition: Integrator.cpp:77
virtual vec from_incre_acceleration(const vec &, const uvec &)
Definition: Integrator.cpp:323
virtual int process_load()
Definition: Integrator.cpp:53
Integrator(unsigned=0)
Definition: Integrator.cpp:22
virtual void update_constraint()
Definition: Integrator.cpp:164
virtual int sync_status(bool)
Definition: Integrator.cpp:208
void set_time_step_switch(bool)
Definition: Integrator.cpp:36
virtual void stage_status()
Definition: Integrator.cpp:289
void record() const
Definition: Integrator.cpp:99
virtual void update_from_ninja()
Definition: Integrator.cpp:173
virtual void update_parameter(double)
Definition: Integrator.cpp:303
~Integrator() override=default
virtual bool time_independent_matrix() const
Definition: Integrator.cpp:51
virtual void commit_status()
Definition: Integrator.cpp:291
virtual const vec & get_trial_displacement() const
Definition: Integrator.cpp:160
virtual vec from_incre_velocity(const vec &, const uvec &)
Definition: Integrator.cpp:313
mat solve(const mat &)
Definition: Integrator.cpp:239
virtual int initialize()
Definition: Integrator.cpp:29
virtual vec get_auxiliary_residual()
Definition: Integrator.cpp:152
virtual int process_constraint_resistance()
Definition: Integrator.cpp:88
virtual vec from_total_acceleration(const vec &, const uvec &)
Definition: Integrator.cpp:333
virtual void assemble_resistance()
Definition: Integrator.cpp:101
shared_ptr< DomainBase > get_domain() const
Definition: Integrator.cpp:27
virtual int process_criterion()
Definition: Integrator.cpp:75
virtual void clear_status()
Definition: Integrator.cpp:293
virtual void assemble_matrix()
Definition: Integrator.cpp:112
Integrator(Integrator &&)=delete
Integrator & operator=(Integrator &&)=delete
virtual int update_internal(const mat &)
Definition: Integrator.cpp:237
virtual void erase_machine_error(vec &) const
Definition: Integrator.cpp:276
bool allow_to_change_time_step() const
Definition: Integrator.cpp:43
virtual void reset_status()
Definition: Integrator.cpp:298
virtual void update_trial_time(double)
Definition: Integrator.cpp:178
bool matrix_is_assembled() const
Definition: Integrator.cpp:47
virtual vec from_total_velocity(const vec &, const uvec &)
Definition: Integrator.cpp:325
virtual vec get_force_residual()
Definition: Integrator.cpp:123
virtual int correct_trial_status()
Definition: Integrator.cpp:197
void stage_and_commit_status()
Definition: Integrator.cpp:284
A base Tag class.
Definition: Tag.h:38
IntegratorType
Definition: Integrator.h:46