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