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 
239  struct Equation {
240 
246  struct Term {
247  unsigned int node_number;
248  unsigned int dof;
249  double coefficient;
254  Term() : node_number(0), dof(0), coefficient(0) {};
255 
262  Term(unsigned int _node_number, unsigned int _dof, double _coefficient) :
263  node_number(_node_number), dof(_dof), coefficient(_coefficient) {};
264  };
265 
266  std::vector<Term> terms;
271  Equation() : terms(0) {};
272 
277  Equation(const std::vector<Term> &_terms) : terms(_terms) {};
278  };
279 
284  struct Elem {
285  Eigen::Vector2i node_numbers;
291  Elem() { };
292 
301  Elem(unsigned int node1, unsigned int node2, const Props &_props) : props(_props) {
302  node_numbers << node1, node2;
303  }
304  };
305 
309  struct Job {
310  std::vector<Node> nodes;
311  std::vector<Eigen::Vector2i> elems;
312  std::vector<Props> props;
317  Job() : nodes(0), elems(0), props(0) { };
318 
328  Job(const std::vector<Node> &_nodes, const std::vector<Elem> _elems) : nodes(_nodes) {
329  unsigned int num_elems = _elems.size();
330  elems.reserve(num_elems);
331  props.reserve(num_elems);
332 
333  for (unsigned int i = 0; i < num_elems; i++) {
334  elems.push_back(_elems[i].node_numbers);
335  props.push_back(_elems[i].props);
336  }
337  };
338  };
339 
343  enum DOF {
348 
353 
358 
363 
368 
377  };
378 
379 } // namespace fea
380 
381 #endif // FEA_CONTAINERS_H
Props props
Definition: containers.h:286
Force()
Default Constructor.
Definition: containers.h:124
BC()
Default Constructor.
Definition: containers.h:85
Definition: containers.h:357
double GJ
Definition: containers.h:153
unsigned int dof
Definition: containers.h:116
double coefficient
Definition: containers.h:249
double value
Definition: containers.h:79
Tie()
Default Constructor.
Definition: containers.h:204
std::vector< Eigen::Vector2i > elems
Definition: containers.h:311
unsigned int dof
Definition: containers.h:248
Elem(unsigned int node1, unsigned int node2, const Props &_props)
Constructor.
Definition: containers.h:301
double EA
Definition: containers.h:150
Equation(const std::vector< Term > &_terms)
Constructor.
Definition: containers.h:277
Places linear springs between all degrees of freedom of 2 nodes.
Definition: containers.h:194
std::vector< Node > nodes
Definition: containers.h:310
std::vector< Term > terms
Definition: containers.h:266
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
Term()
Definition: containers.h:254
std::vector< Props > props
Definition: containers.h:312
unsigned int node
Definition: containers.h:110
double lmult
Definition: containers.h:197
Definition: containers.h:376
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:328
Term(unsigned int _node_number, unsigned int _dof, double _coefficient)
Constructor.
Definition: containers.h:262
Definition: containers.h:372
unsigned int node_number
Definition: containers.h:247
A single term in the equation constraint.
Definition: containers.h:246
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:343
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:347
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:367
Eigen::Vector3d normal_vec
Definition: containers.h:154
Definition: containers.h:362
An element of the mesh. Contains the indices of the two fea::Node's that form the element as well as ...
Definition: containers.h:284
Props()
Definition: containers.h:156
double rmult
Definition: containers.h:198
Elem()
Default Constructor.
Definition: containers.h:291
Equation()
Definition: containers.h:271
A linear multipoint constraint.
Definition: containers.h:239
Contains a node list, element list, and the properties of each element.
Definition: containers.h:309
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:317
Definition: containers.h:352
Eigen::Vector2i node_numbers
Definition: containers.h:285