suanPan
Element.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 ELEMENT_H
29#define ELEMENT_H
30
31#include <Element/ElementBase.h>
32
33enum class MaterialType : unsigned;
34enum class SectionType : unsigned;
35
36//struct StateElement {
37// mat mass{};
38// mat damping{};
39// mat stiffness{};
40// mat geometry{};
41//
42// vec resistance{};
43// vec damping_force{};
44// vec inertial_force{};
45//
46// vec body_force{};
47// vec traction{};
48//};
49
51 const uvec node_encoding; // node encoding
52 const uvec material_tag; // material tags
53 const uvec section_tag; // section tags
54
55 const bool nlgeom = false; // nonlinear geometry switch
56
57 bool update_mass = true; // flag to indicate if update matrix
58 bool update_viscous = true; // flag to indicate if update matrix
59 bool update_nonviscous = true; // flag to indicate if update matrix
60 bool update_stiffness = true; // flag to indicate if update matrix
61 bool update_geometry = true; // flag to indicate if update matrix
62
63 bool modify_mass = true; // flag to indicate if modify matrix
64 bool modify_viscous = true; // flag to indicate if modify matrix
65 bool modify_nonviscous = true; // flag to indicate if modify matrix
66
67 uvec dof_encoding{}; // DoF encoding vector
68
69 mat initial_mass{}; // mass matrix
70 mat initial_viscous{}; // viscous damping matrix
71 mat initial_nonviscous{}; // nonviscous damping matrix
72 mat initial_stiffness{}; // stiffness matrix
73 mat initial_geometry{}; // geometry matrix
74
75 mat trial_mass{}; // mass matrix
76 mat trial_viscous{}; // viscous damping matrix
77 mat trial_nonviscous{}; // nonviscous damping matrix
78 mat trial_stiffness{}; // stiffness matrix
79 mat trial_geometry{}; // geometry matrix
80
81 mat current_mass{}; // mass matrix
82 mat current_viscous{}; // viscous damping matrix
83 mat current_nonviscous{}; // nonviscous damping matrix
84 mat current_stiffness{}; // stiffness matrix
85 mat current_geometry{}; // geometry matrix
86
87 vec trial_resistance{}; // resistance vector
88 vec current_resistance{}; // resistance vector
89 vec trial_viscous_force{}; // viscous damping force
90 vec current_viscous_force{}; // viscous damping force
91 cx_mat trial_nonviscous_force{}; // nonviscous damping force
92 cx_mat current_nonviscous_force{}; // nonviscous damping force
93 vec trial_inertial_force{}; // inertial force
94 vec current_inertial_force{}; // inertial force
95
100
102 mat traction{};
103
104 mat stiffness_container{}; // universal container to accommodate matrix based on modified stiffness matrix
105 mat mass_container{}; // universal container to accommodate matrix based on modified mass matrix
106
107 double strain_energy = 0.;
108 double kinetic_energy = 0.;
109 double viscous_energy = 0.;
110 double nonviscous_energy = 0.;
112 vec momentum{};
113
114 const double characteristic_length = 1.;
115};
116
117class Element : protected DataElement, public ElementBase {
118 const unsigned num_node; // number of nodes
119 const unsigned num_dof; // number of DoFs
120 const unsigned num_size = num_dof * num_node; // number of size
121
122 const bool initialized = false;
123 const bool symmetric = false;
124 const bool use_group = false;
125 const unsigned use_other = 0;
126
127 const MaterialType material_type;
128 const SectionType section_type;
129
130 const std::vector<DOF> dof_identifier;
131
132 std::vector<MappingDOF> dof_mapping;
133
134 friend void ConstantMass(DataElement*);
135 friend void ConstantDamping(DataElement*);
136 friend void ConstantStiffness(DataElement*);
137 friend void ConstantGeometry(DataElement*);
138
139 void update_strain_energy() override;
140 void update_kinetic_energy() override;
141 void update_viscous_energy() override;
142 void update_nonviscous_energy() override;
143 void update_complementary_energy() override;
144 void update_momentum() override;
145
146protected:
147 std::vector<weak_ptr<Node>> node_ptr; // node pointers
148
149 [[nodiscard]] mat get_coordinate(unsigned) const override;
150
151 [[nodiscard]] vec get_node_incre_resistance() const override;
152 [[nodiscard]] vec get_node_trial_resistance() const override;
153 [[nodiscard]] vec get_node_current_resistance() const override;
154
155 [[nodiscard]] std::vector<shared_ptr<Material>> get_material(const shared_ptr<DomainBase>&) const override;
156 [[nodiscard]] std::vector<shared_ptr<Section>> get_section(const shared_ptr<DomainBase>&) const override;
157
158public:
159 Element(
160 unsigned, // tag
161 unsigned, // number of nodes
162 unsigned, // number of dofs
163 uvec&&, // node encoding
164 std::vector<DOF>&& // dof identifier
165 );
166 Element(
167 unsigned, // tag
168 unsigned, // number of nodes
169 unsigned, // number of dofs
170 uvec&&, // node encoding
171 uvec&&, // material tags
172 bool, // nonlinear geometry switch
173 MaterialType, // material type for internal check
174 std::vector<DOF>&& // dof identifier
175 );
176 Element(
177 unsigned, // tag
178 unsigned, // number of nodes
179 unsigned, // number of dofs
180 uvec&&, // node encoding
181 uvec&&, // section tags
182 bool, // nonlinear geometry switch
183 SectionType, // section type for internal check
184 std::vector<DOF>&& // dof identifier
185 );
186 Element(
187 unsigned, // tag
188 unsigned, // number of dofs
189 uvec&& // group encoding
190 );
191 Element(
192 unsigned, // tag
193 unsigned, // number of dofs
194 unsigned, // other element tag
195 unsigned // node tag
196 );
197 Element(const Element&) = delete; // copy forbidden
198 Element(Element&&) = delete; // move forbidden
199 Element& operator=(const Element&) = delete; // assign forbidden
200 Element& operator=(Element&&) = delete; // assign forbidden
201
202 ~Element() override = default;
203
204 int initialize_base(const shared_ptr<DomainBase>&) final;
205
206 void set_initialized(bool) const override;
207 void set_symmetric(bool) const override;
208 [[nodiscard]] bool is_initialized() const override;
209 [[nodiscard]] bool is_symmetric() const override;
210 [[nodiscard]] bool is_nlgeom() const override;
211
212 void update_dof_encoding() override;
213
214 [[nodiscard]] bool if_update_mass() const override;
215 [[nodiscard]] bool if_update_viscous() const override;
216 [[nodiscard]] bool if_update_nonviscous() const override;
217 [[nodiscard]] bool if_update_stiffness() const override;
218 [[nodiscard]] bool if_update_geometry() const override;
219
220 [[nodiscard]] bool allow_modify_mass() const override;
221 [[nodiscard]] bool allow_modify_viscous() const override;
222 [[nodiscard]] bool allow_modify_nonviscous() const override;
223
224 [[nodiscard]] const uvec& get_dof_encoding() const override;
225 [[nodiscard]] const uvec& get_node_encoding() const override;
226
227 [[nodiscard]] const std::vector<MappingDOF>& get_dof_mapping() const override;
228
229 [[nodiscard]] const uvec& get_material_tag() const override;
230 [[nodiscard]] const uvec& get_section_tag() const override;
231
232 [[nodiscard]] unsigned get_dof_number() const override;
233 [[nodiscard]] unsigned get_node_number() const override;
234 [[nodiscard]] unsigned get_total_number() const override;
235
236 void clear_node_ptr() override;
237 [[nodiscard]] const std::vector<weak_ptr<Node>>& get_node_ptr() const override;
238
239 [[nodiscard]] vec get_incre_displacement() const override;
240 [[nodiscard]] vec get_incre_velocity() const override;
241 [[nodiscard]] vec get_incre_acceleration() const override;
242 [[nodiscard]] vec get_trial_displacement() const override;
243 [[nodiscard]] vec get_trial_velocity() const override;
244 [[nodiscard]] vec get_trial_acceleration() const override;
245 [[nodiscard]] vec get_current_displacement() const override;
246 [[nodiscard]] vec get_current_velocity() const override;
247 [[nodiscard]] vec get_current_acceleration() const override;
248
249 [[nodiscard]] const vec& get_trial_resistance() const override;
250 [[nodiscard]] const vec& get_current_resistance() const override;
251 [[nodiscard]] const vec& get_trial_damping_force() const override;
252 [[nodiscard]] const vec& get_current_damping_force() const override;
253 [[nodiscard]] const cx_mat& get_trial_nonviscous_force() const override;
254 [[nodiscard]] const cx_mat& get_current_nonviscous_force() const override;
255 [[nodiscard]] const vec& get_trial_inertial_force() override;
256 [[nodiscard]] const vec& get_current_inertial_force() override;
257
258 [[nodiscard]] const vec& get_trial_body_force() const override;
259 [[nodiscard]] const vec& get_current_body_force() const override;
260 [[nodiscard]] const vec& get_trial_traction() const override;
261 [[nodiscard]] const vec& get_current_traction() const override;
262
263 [[nodiscard]] const mat& get_trial_mass() const override;
264 [[nodiscard]] const mat& get_trial_viscous() const override;
265 [[nodiscard]] const mat& get_trial_nonviscous() const override;
266 [[nodiscard]] const mat& get_trial_stiffness() const override;
267 [[nodiscard]] const mat& get_trial_geometry() const override;
268 [[nodiscard]] const mat& get_trial_secant() const override;
269
270 [[nodiscard]] const mat& get_current_mass() const override;
271 [[nodiscard]] const mat& get_current_viscous() const override;
272 [[nodiscard]] const mat& get_current_nonviscous() const override;
273 [[nodiscard]] const mat& get_current_stiffness() const override;
274 [[nodiscard]] const mat& get_current_geometry() const override;
275 [[nodiscard]] const mat& get_current_secant() const override;
276
277 [[nodiscard]] const mat& get_initial_mass() const override;
278 [[nodiscard]] const mat& get_initial_viscous() const override;
279 [[nodiscard]] const mat& get_initial_nonviscous() const override;
280 [[nodiscard]] const mat& get_initial_stiffness() const override;
281 [[nodiscard]] const mat& get_initial_geometry() const override;
282 [[nodiscard]] const mat& get_initial_secant() const override;
283
284 [[nodiscard]] const mat& get_mass_container() const override;
285 [[nodiscard]] const mat& get_stiffness_container() const override;
286
287 int clear_status() override = 0;
288 int commit_status() override = 0;
289 int reset_status() override = 0;
290
291 const vec& update_body_force(const vec&) override;
292 const vec& update_traction(const vec&) override;
293
294 std::vector<vec> record(OutputType) override;
295
296 [[nodiscard]] double get_strain_energy() const override;
297 [[nodiscard]] double get_complementary_energy() const override;
298 [[nodiscard]] double get_kinetic_energy() const override;
299 [[nodiscard]] double get_viscous_energy() const override;
300 [[nodiscard]] double get_nonviscous_energy() const override;
301 [[nodiscard]] const vec& get_momentum() const override;
302 [[nodiscard]] double get_momentum_component(DOF) const override;
303
304 [[nodiscard]] double get_characteristic_length() const override;
305
306 [[nodiscard]] mat compute_shape_function(const mat&, unsigned) const override;
307};
308
309std::vector<vec>& append_to(std::vector<vec>&, std::vector<vec>&&);
310
311#endif
312
OutputType
Definition: OutputType.h:23
A ElementBase class.
Definition: ElementBase.h:42
A Element class.
Definition: Element.h:117
friend void ConstantGeometry(DataElement *)
Definition: Element.cpp:637
std::vector< shared_ptr< Section > > get_section(const shared_ptr< DomainBase > &) const override
Definition: Element.cpp:248
const vec & get_current_resistance() const override
Definition: Element.cpp:448
Element(const Element &)=delete
mat get_coordinate(unsigned) const override
generate a matrix that contains coordinates of connected nodes
Definition: Element.cpp:75
void update_dof_encoding() override
Definition: Element.cpp:394
std::vector< shared_ptr< Material > > get_material(const shared_ptr< DomainBase > &) const override
Definition: Element.cpp:242
unsigned get_dof_number() const override
Definition: Element.cpp:436
const mat & get_initial_mass() const override
Definition: Element.cpp:500
unsigned get_node_number() const override
Definition: Element.cpp:438
const mat & get_current_viscous() const override
Definition: Element.cpp:490
bool allow_modify_nonviscous() const override
Definition: Element.cpp:424
const uvec & get_node_encoding() const override
Definition: Element.cpp:428
const vec & get_current_traction() const override
Definition: Element.cpp:474
Element(unsigned, unsigned, unsigned, uvec &&, std::vector< DOF > &&)
Definition: Element.cpp:254
const std::vector< weak_ptr< Node > > & get_node_ptr() const override
Definition: Element.cpp:444
const uvec & get_dof_encoding() const override
Definition: Element.cpp:426
const vec & get_current_inertial_force() override
Definition: Element.cpp:463
void clear_node_ptr() override
Definition: Element.cpp:442
~Element() override=default
const vec & get_trial_body_force() const override
Definition: Element.cpp:468
vec get_node_current_resistance() const override
Definition: Element.cpp:229
const mat & get_trial_stiffness() const override
Definition: Element.cpp:482
const vec & get_current_damping_force() const override
Definition: Element.cpp:452
friend void ConstantDamping(DataElement *)
Definition: Element.cpp:625
vec get_current_velocity() const override
Definition: Element.cpp:177
vec get_trial_velocity() const override
Definition: Element.cpp:138
const mat & get_stiffness_container() const override
Definition: Element.cpp:514
vec get_current_acceleration() const override
Definition: Element.cpp:190
const mat & get_initial_stiffness() const override
Definition: Element.cpp:506
const vec & get_current_body_force() const override
Definition: Element.cpp:470
double get_characteristic_length() const override
Definition: Element.cpp:610
const vec & get_trial_inertial_force() override
Definition: Element.cpp:458
bool if_update_viscous() const override
Definition: Element.cpp:412
double get_momentum_component(DOF) const override
Definition: Element.cpp:599
const cx_mat & get_trial_nonviscous_force() const override
Definition: Element.cpp:454
vec get_incre_acceleration() const override
Definition: Element.cpp:112
bool is_symmetric() const override
Definition: Element.cpp:390
bool if_update_stiffness() const override
Definition: Element.cpp:416
int initialize_base(const shared_ptr< DomainBase > &) final
Definition: Element.cpp:295
const std::vector< MappingDOF > & get_dof_mapping() const override
Definition: Element.cpp:430
const vec & get_momentum() const override
Definition: Element.cpp:597
const vec & get_trial_damping_force() const override
Definition: Element.cpp:450
vec get_current_displacement() const override
Definition: Element.cpp:164
friend void ConstantMass(DataElement *)
Definition: Element.cpp:619
std::vector< weak_ptr< Node > > node_ptr
Definition: Element.h:147
const mat & get_initial_secant() const override
Definition: Element.cpp:510
double get_nonviscous_energy() const override
Definition: Element.cpp:595
const mat & get_current_geometry() const override
Definition: Element.cpp:496
const mat & get_initial_viscous() const override
Definition: Element.cpp:502
bool is_nlgeom() const override
Definition: Element.cpp:392
const mat & get_current_mass() const override
Definition: Element.cpp:488
vec get_trial_acceleration() const override
Definition: Element.cpp:151
unsigned get_total_number() const override
Definition: Element.cpp:440
const mat & get_trial_geometry() const override
Definition: Element.cpp:484
int reset_status() override=0
Definition: Element.cpp:567
Element & operator=(Element &&)=delete
Element(Element &&)=delete
bool allow_modify_viscous() const override
Definition: Element.cpp:422
const mat & get_trial_nonviscous() const override
Definition: Element.cpp:480
vec get_trial_displacement() const override
Definition: Element.cpp:125
double get_viscous_energy() const override
Definition: Element.cpp:593
friend void ConstantStiffness(DataElement *)
Definition: Element.cpp:631
Element & operator=(const Element &)=delete
const mat & get_trial_secant() const override
Definition: Element.cpp:486
vec get_incre_velocity() const override
Definition: Element.cpp:99
const vec & update_body_force(const vec &) override
Definition: Element.cpp:581
int clear_status() override=0
Definition: Element.cpp:516
double get_strain_energy() const override
Definition: Element.cpp:587
const mat & get_initial_nonviscous() const override
Definition: Element.cpp:504
bool if_update_mass() const override
Definition: Element.cpp:410
void set_initialized(bool) const override
Definition: Element.cpp:384
const vec & get_trial_resistance() const override
Definition: Element.cpp:446
vec get_node_trial_resistance() const override
Definition: Element.cpp:216
bool allow_modify_mass() const override
Definition: Element.cpp:420
bool is_initialized() const override
Definition: Element.cpp:388
const mat & get_trial_mass() const override
Definition: Element.cpp:476
const cx_mat & get_current_nonviscous_force() const override
Definition: Element.cpp:456
const uvec & get_material_tag() const override
Definition: Element.cpp:432
vec get_incre_displacement() const override
Definition: Element.cpp:86
double get_complementary_energy() const override
Definition: Element.cpp:589
vec get_node_incre_resistance() const override
Definition: Element.cpp:203
const mat & get_current_nonviscous() const override
Definition: Element.cpp:492
const mat & get_trial_viscous() const override
Definition: Element.cpp:478
const vec & get_trial_traction() const override
Definition: Element.cpp:472
const mat & get_initial_geometry() const override
Definition: Element.cpp:508
const mat & get_current_stiffness() const override
Definition: Element.cpp:494
int commit_status() override=0
Definition: Element.cpp:547
const mat & get_current_secant() const override
Definition: Element.cpp:498
mat compute_shape_function(const mat &, unsigned) const override
Definition: Element.cpp:612
std::vector< vec > record(OutputType) override
Definition: Element.cpp:585
double get_kinetic_energy() const override
Definition: Element.cpp:591
bool if_update_nonviscous() const override
Definition: Element.cpp:414
bool if_update_geometry() const override
Definition: Element.cpp:418
const mat & get_mass_container() const override
Definition: Element.cpp:512
const uvec & get_section_tag() const override
Definition: Element.cpp:434
void set_symmetric(bool) const override
Definition: Element.cpp:386
const vec & update_traction(const vec &) override
Definition: Element.cpp:583
std::vector< vec > & append_to(std::vector< vec > &, std::vector< vec > &&)
Definition: Element.cpp:614
MaterialType
Definition: Material.h:34
DOF
Definition: DOF.h:29
SectionType
Definition: Section.h:33
Definition: Element.h:50
bool modify_nonviscous
Definition: Element.h:65
cx_mat trial_nonviscous_force
Definition: Element.h:91
vec trial_traction
Definition: Element.h:98
uvec dof_encoding
Definition: Element.h:67
bool update_stiffness
Definition: Element.h:60
mat traction
Definition: Element.h:102
mat trial_stiffness
Definition: Element.h:78
bool update_geometry
Definition: Element.h:61
bool modify_viscous
Definition: Element.h:64
double nonviscous_energy
Definition: Element.h:110
vec current_body_force
Definition: Element.h:97
const uvec section_tag
Definition: Element.h:53
mat trial_mass
Definition: Element.h:75
bool update_mass
Definition: Element.h:57
double complementary_energy
Definition: Element.h:111
mat initial_viscous
Definition: Element.h:70
cx_mat current_nonviscous_force
Definition: Element.h:92
mat current_viscous
Definition: Element.h:82
double viscous_energy
Definition: Element.h:109
vec current_resistance
Definition: Element.h:88
mat initial_nonviscous
Definition: Element.h:71
mat stiffness_container
Definition: Element.h:104
vec momentum
Definition: Element.h:112
vec trial_body_force
Definition: Element.h:96
bool update_viscous
Definition: Element.h:58
vec current_viscous_force
Definition: Element.h:90
mat initial_stiffness
Definition: Element.h:72
const double characteristic_length
Definition: Element.h:114
const bool nlgeom
Definition: Element.h:55
vec current_inertial_force
Definition: Element.h:94
mat mass_container
Definition: Element.h:105
vec trial_viscous_force
Definition: Element.h:89
const uvec node_encoding
Definition: Element.h:51
double strain_energy
Definition: Element.h:107
bool update_nonviscous
Definition: Element.h:59
mat trial_viscous
Definition: Element.h:76
mat body_force
Definition: Element.h:101
const uvec material_tag
Definition: Element.h:52
mat current_nonviscous
Definition: Element.h:83
mat initial_geometry
Definition: Element.h:73
vec trial_inertial_force
Definition: Element.h:93
mat trial_geometry
Definition: Element.h:79
mat current_mass
Definition: Element.h:81
mat current_geometry
Definition: Element.h:85
mat current_stiffness
Definition: Element.h:84
vec trial_resistance
Definition: Element.h:87
mat trial_nonviscous
Definition: Element.h:77
bool modify_mass
Definition: Element.h:63
vec current_traction
Definition: Element.h:99
mat initial_mass
Definition: Element.h:69
double kinetic_energy
Definition: Element.h:108