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