suanPan
Element.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (C) 2017-2022 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 
33 enum class MaterialType : unsigned;
34 enum class SectionType : unsigned;
35 
36 struct DataElement {
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 
72  vec trial_body_force{};
73  vec current_body_force{};
74  vec trial_traction{};
75  vec current_traction{};
76 
77  mat body_force{};
78  mat traction{};
79 
80  double strain_energy = 0.;
81  double kinetic_energy = 0.;
82  double viscous_energy = 0.;
83  double complementary_energy = 0.;
84  vec momentum{};
85 
86  const double characteristic_length = 1.;
87 };
88 
89 class Element : protected DataElement, public ElementBase {
90  const unsigned num_node; // number of nodes
91  const unsigned num_dof; // number of DoFs
92  const unsigned num_size = num_dof * num_node; // number of size
93 
94  const bool initialized = false;
95  const bool symmetric = false;
96  const bool use_group = false;
97  const unsigned use_other = 0;
98 
99  const MaterialType mat_type;
100  const SectionType sec_type;
101 
102  std::vector<DOF> dof_identifier;
103 
104  friend void ConstantMass(DataElement*);
105  friend void ConstantDamping(DataElement*);
106  friend void ConstantStiffness(DataElement*);
107  friend void ConstantGeometry(DataElement*);
108 
109  void update_strain_energy() override;
110  void update_kinetic_energy() override;
111  void update_viscous_energy() override;
112  void update_complementary_energy() override;
113  void update_momentum() override;
114 
115 protected:
116  std::vector<weak_ptr<Node>> node_ptr; // node pointers
117 
118  [[nodiscard]] mat get_coordinate(unsigned) const override;
119 
120  [[nodiscard]] vec get_incre_displacement() const override;
121  [[nodiscard]] vec get_incre_velocity() const override;
122  [[nodiscard]] vec get_incre_acceleration() const override;
123  [[nodiscard]] vec get_trial_displacement() const override;
124  [[nodiscard]] vec get_trial_velocity() const override;
125  [[nodiscard]] vec get_trial_acceleration() const override;
126  [[nodiscard]] vec get_current_displacement() const override;
127  [[nodiscard]] vec get_current_velocity() const override;
128  [[nodiscard]] vec get_current_acceleration() const override;
129 
130  [[nodiscard]] vec get_node_incre_resistance() const override;
131  [[nodiscard]] vec get_node_trial_resistance() const override;
132  [[nodiscard]] vec get_node_current_resistance() const override;
133 
134  [[nodiscard]] std::vector<shared_ptr<Material>> get_material(const shared_ptr<DomainBase>&) const override;
135  [[nodiscard]] std::vector<shared_ptr<Section>> get_section(const shared_ptr<DomainBase>&) const override;
136 
137 public:
138  Element(unsigned, // tag
139  unsigned, // number of nodes
140  unsigned, // number of dofs
141  uvec&&, // node encoding
142  std::vector<DOF>&& // dof identifier
143  );
144  Element(unsigned, // tag
145  unsigned, // number of nodes
146  unsigned, // number of dofs
147  uvec&&, // node encoding
148  uvec&&, // material tags
149  bool, // nonlinear geometry switch
150  MaterialType, // material type for internal check
151  std::vector<DOF>&& // dof identifier
152  );
153  Element(unsigned, // tag
154  unsigned, // number of nodes
155  unsigned, // number of dofs
156  uvec&&, // node encoding
157  uvec&&, // section tags
158  bool, // nonlinear geometry switch
159  SectionType, // section type for internal check
160  std::vector<DOF>&& // dof identifier
161  );
162  Element(unsigned, // tag
163  unsigned, // number of dofs
164  uvec&& // group encoding
165  );
166  Element(unsigned, // tag
167  unsigned, // number of dofs
168  unsigned, // other element tag
169  unsigned // node tag
170  );
171  Element(const Element&) = delete; // copy forbidden
172  Element(Element&&) = delete; // move forbidden
173  Element& operator=(const Element&) = delete; // assign forbidden
174  Element& operator=(Element&&) = delete; // assign forbidden
175 
176  ~Element() override;
177 
178  int initialize_base(const shared_ptr<DomainBase>&) final;
179 
180  void set_initialized(bool) const override;
181  void set_symmetric(bool) const override;
182  [[nodiscard]] bool is_initialized() const override;
183  [[nodiscard]] bool is_symmetric() const override;
184  [[nodiscard]] bool is_nlgeom() const override;
185 
186  void update_dof_encoding() override;
187 
188  [[nodiscard]] bool if_update_mass() const override;
189  [[nodiscard]] bool if_update_damping() const override;
190  [[nodiscard]] bool if_update_stiffness() const override;
191  [[nodiscard]] bool if_update_geometry() const override;
192 
193  [[nodiscard]] const uvec& get_dof_encoding() const override;
194  [[nodiscard]] const uvec& get_node_encoding() const override;
195 
196  [[nodiscard]] const uvec& get_material_tag() const override;
197  [[nodiscard]] const uvec& get_section_tag() const override;
198 
199  [[nodiscard]] unsigned get_dof_number() const override;
200  [[nodiscard]] unsigned get_node_number() const override;
201  [[nodiscard]] unsigned get_total_number() const override;
202 
203  void clear_node_ptr() override;
204  [[nodiscard]] const std::vector<weak_ptr<Node>>& get_node_ptr() const override;
205 
206  [[nodiscard]] const vec& get_trial_resistance() const override;
207  [[nodiscard]] const vec& get_current_resistance() const override;
208  [[nodiscard]] const vec& get_trial_damping_force() const override;
209  [[nodiscard]] const vec& get_current_damping_force() const override;
210  [[nodiscard]] const vec& get_trial_inertial_force() override;
211  [[nodiscard]] const vec& get_current_inertial_force() override;
212 
213  [[nodiscard]] const vec& get_trial_body_force() const override;
214  [[nodiscard]] const vec& get_current_body_force() const override;
215  [[nodiscard]] const vec& get_trial_traction() const override;
216  [[nodiscard]] const vec& get_current_traction() const override;
217 
218  [[nodiscard]] const mat& get_trial_mass() const override;
219  [[nodiscard]] const mat& get_trial_damping() const override;
220  [[nodiscard]] const mat& get_trial_stiffness() const override;
221  [[nodiscard]] const mat& get_trial_geometry() const override;
222  [[nodiscard]] const mat& get_trial_secant() const override;
223 
224  [[nodiscard]] const mat& get_current_mass() const override;
225  [[nodiscard]] const mat& get_current_damping() const override;
226  [[nodiscard]] const mat& get_current_stiffness() const override;
227  [[nodiscard]] const mat& get_current_geometry() const override;
228  [[nodiscard]] const mat& get_current_secant() const override;
229 
230  [[nodiscard]] const mat& get_initial_mass() const override;
231  [[nodiscard]] const mat& get_initial_damping() const override;
232  [[nodiscard]] const mat& get_initial_stiffness() const override;
233  [[nodiscard]] const mat& get_initial_geometry() const override;
234  [[nodiscard]] const mat& get_initial_secant() const override;
235 
236  int clear_status() override = 0;
237  int commit_status() override = 0;
238  int reset_status() override = 0;
239 
240  const vec& update_body_force(const vec&) override;
241  const vec& update_traction(const vec&) override;
242 
243  std::vector<vec> record(OutputType) override;
244 
245  [[nodiscard]] double get_strain_energy() const override;
246  [[nodiscard]] double get_complementary_energy() const override;
247  [[nodiscard]] double get_kinetic_energy() const override;
248  [[nodiscard]] double get_viscous_energy() const override;
249  [[nodiscard]] const vec& get_momentum() const override;
250  [[nodiscard]] double get_momentum_component(DOF) const override;
251 
252  [[nodiscard]] double get_characteristic_length() const override;
253 
254  [[nodiscard]] mat compute_shape_function(const mat&, unsigned) const override;
255 };
256 
257 #endif
258 
void ConstantDamping(DataElement *E)
Definition: Element.cpp:584
A Element class.
Definition: Element.h:89
Col< T > & get_current_acceleration(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:163
Col< T > & get_trial_damping_force(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:111
Col< T > & get_trial_inertial_force(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:113
shared_ptr< Section > & get_section(const shared_ptr< Domain > &D, const unsigned T)
Definition: DomainHelper.cpp:48
Col< T > & get_trial_resistance(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:109
shared_ptr< Material > & get_material(const shared_ptr< Domain > &D, const unsigned T)
Definition: DomainHelper.cpp:38
OutputType
Definition: OutputType.h:21
DOF
Definition: DOF.h:29
Col< T > & get_current_displacement(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:159
Col< T > & get_trial_velocity(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:117
MaterialType
Definition: Material.h:34
const uvec section_tag
Definition: Element.h:39
Col< T > & get_current_velocity(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:161
Col< T > & get_current_damping_force(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:155
void ConstantMass(DataElement *E)
Definition: Element.cpp:578
uvec dof_encoding
Definition: Element.h:48
mat get_coordinate(const ElementBase *const E, const unsigned N)
Definition: Element.cpp:602
Definition: Element.h:36
Col< T > & get_incre_velocity(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:139
std::vector< weak_ptr< Node > > node_ptr
Definition: Element.h:116
SectionType
Definition: Section.h:34
Col< T > & get_current_inertial_force(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:157
Col< T > & get_incre_acceleration(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:141
Col< T > & get_trial_displacement(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:115
const uvec material_tag
Definition: Element.h:38
void ConstantStiffness(DataElement *E)
Definition: Element.cpp:590
Col< T > & get_current_resistance(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:153
Col< T > & get_trial_acceleration(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:119
Col< T > & get_incre_displacement(const shared_ptr< Factory< T >> &W)
Definition: FactoryHelper.hpp:137
const uvec node_encoding
Definition: Element.h:37
A ElementBase class.
Definition: ElementBase.h:41
void ConstantGeometry(DataElement *E)
Definition: Element.cpp:596