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