3D Beam Finite Element Code  1.0
threed_beam_fea.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 THREED_BEAM_FEA_H
36 #define THREED_BEAM_FEA_H
37 
38 #ifdef EIGEN_USE_MKL_ALL
39 #include <Eigen/PardisoSupport>
40 #else
41 #include <Eigen/SparseLU>
42 #endif
43 
44 #include <Eigen/Core>
45 #include <Eigen/Geometry>
46 #include <Eigen/SparseCore>
47 
48 #include "containers.h"
49 #include "options.h"
50 #include "summary.h"
51 #include "csv_parser.h"
52 
53 namespace fea {
54 
58  typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> GlobalStiffMatrix;
59 
63  typedef Eigen::Matrix<double, 12, 12, Eigen::RowMajor> LocalMatrix;
64 
69  typedef Eigen::Matrix<double, Eigen::Dynamic, 1> ForceVector;
70 
74  typedef Eigen::SparseMatrix<double> SparseMat;
75 
85  inline double norm(const Node &n1, const Node &n2);
86 
91 
92  public:
93 
99  Kelem.setZero();
100  Klocal.setZero();
101  Aelem.setZero();
102  AelemT.setZero();
103  SparseKelem.resize(12, 12);
104  SparseKelem.reserve(40);
105  };
106 
118  void operator()(SparseMat &Kg, const Job &job, const std::vector<Tie> &ties);
119 
126  void calcKelem(unsigned int i, const Job &job);
127 
136  void calcAelem(const Eigen::Vector3d &nx, const Eigen::Vector3d &nz);
137 
142  LocalMatrix getKelem() {
143  return Kelem;
144  }
145 
150  LocalMatrix getAelem() {
151  return Aelem;
152  }
153 
154  private:
155  LocalMatrix Kelem;
157  LocalMatrix Klocal;
159  LocalMatrix Aelem;
161  LocalMatrix AelemT;
163  SparseMat SparseKelem;
164  };
165 
180  void loadBCs(SparseMat &Kg, ForceVector &force_vec, const std::vector<BC> &BCs, unsigned int num_nodes);
181 
182  void loadEquations(SparseMat &Kg, const std::vector<Equation> &equations, unsigned int num_nodes, unsigned int num_bcs);
183 
194  void loadTies(std::vector<Eigen::Triplet<double> > &triplets, const std::vector<Tie> &ties);
195 
196 
205  std::vector<std::vector<double> > computeTieForces(const std::vector<Tie> &ties,
206  const std::vector<std::vector<double> > &nodal_displacements);
207 
214  void loadForces(SparseMat &force_vec, const std::vector<Force> &forces);
215 
229  Summary solve(const Job &job,
230  const std::vector<BC> &BCs,
231  const std::vector<Force> &forces,
232  const std::vector<Tie> &ties,
233  const std::vector<Equation> &equations,
234  const Options &options);
235 } // namespace fea
236 
237 #endif // THREED_BEAM_FEA_H
Assembles the global stiffness matrix.
Definition: threed_beam_fea.h:90
GlobalStiffAssembler()
Default constructor.
Definition: threed_beam_fea.h:98
Eigen::Matrix< double, 12, 12, Eigen::RowMajor > LocalMatrix
Definition: threed_beam_fea.h:63
void calcAelem(const Eigen::Vector3d &nx, const Eigen::Vector3d &nz)
Updates the rotation and transposed rotation matrices.
Definition: threed_beam_fea.cpp:141
double norm(const Node &n1, const Node &n2)
Calculates the distance between 2 nodes.
Definition: threed_beam_fea.cpp:54
LocalMatrix getKelem()
Returns the currently stored elemental stiffness matrix.
Definition: threed_beam_fea.h:142
void loadBCs(SparseMat &Kg, ForceVector &force_vec, const std::vector< BC > &BCs, unsigned int num_nodes)
Loads the boundary conditions into the global stiffness matrix and force vector.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > GlobalStiffMatrix
Definition: threed_beam_fea.h:58
void loadTies(std::vector< Eigen::Triplet< double > > &triplets, const std::vector< Tie > &ties)
Loads any tie constraints into the set of triplets that will become the global stiffness matrix...
Definition: threed_beam_fea.cpp:329
Eigen::SparseMatrix< double > SparseMat
Definition: threed_beam_fea.h:74
LocalMatrix getAelem()
Returns the currently stored rotation matrix.
Definition: threed_beam_fea.h:150
void calcKelem(unsigned int i, const Job &job)
Updates the elemental stiffness matrix for the ith element.
Definition: threed_beam_fea.cpp:59
void loadForces(SparseMat &force_vec, const std::vector< Force > &forces)
Loads the prescribed forces into the force vector.
Definition: threed_beam_fea.cpp:388
std::vector< std::vector< double > > computeTieForces(const std::vector< Tie > &ties, const std::vector< std::vector< double > > &nodal_displacements)
Computes the forces in the tie elements based on the nodal displacements of the FE analysis and the s...
Definition: threed_beam_fea.cpp:363
void loadEquations(SparseMat &Kg, const std::vector< Equation > &equations, unsigned int num_nodes, unsigned int num_bcs)
Definition: threed_beam_fea.cpp:314
Eigen::Vector3d Node
A node that describes a mesh. Uses Eigen's predefined Vector class for added functionality.
Definition: containers.h:56
Summary solve(const Job &job, const std::vector< BC > &BCs, const std::vector< Force > &forces, const std::vector< Tie > &ties, const std::vector< Equation > &equations, const Options &options)
Solves the finite element analysis defined by the input Job, boundary conditions, and prescribed noda...
Definition: threed_beam_fea.cpp:398
Contains a node list, element list, and the properties of each element.
Definition: containers.h:309
Eigen::Matrix< double, Eigen::Dynamic, 1 > ForceVector
Definition: threed_beam_fea.h:69
Definition: containers.h:41
void operator()(SparseMat &Kg, const Job &job, const std::vector< Tie > &ties)
Assembles the global stiffness matrix.
Definition: threed_beam_fea.cpp:231