3D Beam Finite Element Code  1.0
containers.h
Go to the documentation of this file.
1 
10 // Copyright 2015. All rights reserved.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are met:
14 //
15 // * Redistributions of source code must retain the above copyright notice,
16 // this list of conditions and the following disclaimer.
17 // * Redistributions in binary form must reproduce the above copyright notice,
18 // this list of conditions and the following disclaimer in the documentation
19 // and/or other materials provided with the distribution.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 // POSSIBILITY OF SUCH DAMAGE.
32 //
33 // Author: ryan.latture@gmail.com (Ryan Latture)
34 
35 #ifndef FEA_CONTAINERS_H
36 #define FEA_CONTAINERS_H
37 
38 #include <vector>
39 #include <Eigen/Core>
40 
41 namespace fea {
42 
56  typedef Eigen::Vector3d Node;
57 
70  struct BC {
71  unsigned int node;
77  unsigned int dof;
78 
79  double value;
85  BC() : node(0), dof(0), value(0) { };
86 
93  BC(unsigned int _node, unsigned int _dof, double _value) : node(_node), dof(_dof), value(_value) { };
94  };
95 
109  struct Force {
110  unsigned int node;
116  unsigned int dof;
117 
118  double value;
124  Force() : node(0), dof(0), value(0) { };
125 
132  Force(unsigned int _node, unsigned int _dof, double _value) : node(_node), dof(_dof), value(_value) { };
133  };
134 
149  struct Props {
150  double EA;
151  double EIz;
152  double EIy;
153  double GJ;
154  Eigen::Vector3d normal_vec;
156  Props() : EA(0), EIz(0), EIy(0), GJ(0) { };
168  Props(double _EA, double _EIz, double _EIy, double _GJ, const std::vector<double> &_normal_vec)
169  : EA(_EA), EIz(_EIz), EIy(_EIy), GJ(_GJ) {
170  normal_vec << _normal_vec[0], _normal_vec[1], _normal_vec[2];
171  };
172  };
173 
194  struct Tie {
195  unsigned int node_number_1;
196  unsigned int node_number_2;
197  double lmult;
198  double rmult;
204  Tie() : node_number_1(0), node_number_2(0), lmult(0), rmult(0) { };
205 
213  Tie(unsigned int _node_number_1, unsigned int _node_number_2, double _lmult, double _rmult) :
214  node_number_1(_node_number_1), node_number_2(_node_number_2), lmult(_lmult), rmult(_rmult) { };
215  };
216 
221  struct Elem {
222  Eigen::Vector2i node_numbers;
228  Elem() { };
229 
238  Elem(unsigned int node1, unsigned int node2, const Props &_props) : props(_props) {
239  node_numbers << node1, node2;
240  }
241  };
242 
246  struct Job {
247  std::vector<Node> nodes;
248  std::vector<Eigen::Vector2i> elems;
249  std::vector<Props> props;
254  Job() : nodes(0), elems(0), props(0) { };
255 
265  Job(const std::vector<Node> &_nodes, const std::vector<Elem> _elems) : nodes(_nodes) {
266  unsigned int num_elems = _elems.size();
267  elems.reserve(num_elems);
268  props.reserve(num_elems);
269 
270  for (unsigned int i = 0; i < num_elems; i++) {
271  elems.push_back(_elems[i].node_numbers);
272  props.push_back(_elems[i].props);
273  }
274  };
275  };
276 
280  enum DOF {
285 
290 
295 
300 
305 
314  };
315 
316 } // namespace fea
317 
318 #endif // FEA_CONTAINERS_H
Props props
Definition: containers.h:223
Force()
Default Constructor.
Definition: containers.h:124
BC()
Default Constructor.
Definition: containers.h:85
Definition: containers.h:294
double GJ
Definition: containers.h:153
unsigned int dof
Definition: containers.h:116
double value
Definition: containers.h:79
Tie()
Default Constructor.
Definition: containers.h:204
std::vector< Eigen::Vector2i > elems
Definition: containers.h:248
Elem(unsigned int node1, unsigned int node2, const Props &_props)
Constructor.
Definition: containers.h:238
double EA
Definition: containers.h:150
Places linear springs between all degrees of freedom of 2 nodes.
Definition: containers.h:194
std::vector< Node > nodes
Definition: containers.h:247
Tie(unsigned int _node_number_1, unsigned int _node_number_2, double _lmult, double _rmult)
Constructor.
Definition: containers.h:213
A nodal force to enforce.
Definition: containers.h:109
unsigned int node
Definition: containers.h:71
std::vector< Props > props
Definition: containers.h:249
unsigned int node
Definition: containers.h:110
double lmult
Definition: containers.h:197
Definition: containers.h:313
unsigned int dof
Definition: containers.h:77
double value
Definition: containers.h:118
double EIz
Definition: containers.h:151
Job(const std::vector< Node > &_nodes, const std::vector< Elem > _elems)
Constructor.
Definition: containers.h:265
Definition: containers.h:309
unsigned int node_number_2
Definition: containers.h:196
double EIy
Definition: containers.h:152
DOF
Convenience enumerator for specifying the active degree of freedom in a constraint.
Definition: containers.h:280
BC(unsigned int _node, unsigned int _dof, double _value)
Constructor.
Definition: containers.h:93
Props(double _EA, double _EIz, double _EIy, double _GJ, const std::vector< double > &_normal_vec)
Constructor.
Definition: containers.h:168
Definition: containers.h:284
Eigen::Vector3d Node
A node that describes a mesh. Uses Eigen's predefined Vector class for added functionality.
Definition: containers.h:56
Definition: containers.h:304
Eigen::Vector3d normal_vec
Definition: containers.h:154
Definition: containers.h:299
An element of the mesh. Contains the indices of the two fea::Node's that form the element as well as ...
Definition: containers.h:221
Props()
Definition: containers.h:156
double rmult
Definition: containers.h:198
Elem()
Default Constructor.
Definition: containers.h:228
Contains a node list, element list, and the properties of each element.
Definition: containers.h:246
The set of properties associated with an element.
Definition: containers.h:149
Force(unsigned int _node, unsigned int _dof, double _value)
Constructor.
Definition: containers.h:132
A boundary condition to enforce.
Definition: containers.h:70
unsigned int node_number_1
Definition: containers.h:195
Definition: containers.h:41
Job()
Default constructor.
Definition: containers.h:254
Definition: containers.h:289
Eigen::Vector2i node_numbers
Definition: containers.h:222