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 
42 #include <Eigen/SparseLU>
43 
44 #endif
45 
46 #include <Eigen/Core>
47 #include <Eigen/Geometry>
48 #include <Eigen/SparseCore>
49 
50 #include <chrono>
51 #include <cmath>
52 #include <iostream>
53 #include <limits>
54 
55 #include "containers.h"
56 #include "options.h"
57 #include "summary.h"
58 #include "csv_parser.h"
59 
60 namespace fea {
61 
65  typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> GlobalStiffMatrix;
66 
70  typedef Eigen::Matrix<double, 12, 12, Eigen::RowMajor> LocalMatrix;
71 
76  typedef Eigen::Matrix<double, Eigen::Dynamic, 1> ForceVector;
77 
81  typedef Eigen::SparseMatrix<double> SparseMat;
82 
92  inline double norm(const Node &n1, const Node &n2);
93 
98 
99  public:
100 
106  Kelem.setZero();
107  Klocal.setZero();
108  Aelem.setZero();
109  AelemT.setZero();
110  SparseKelem.resize(12, 12);
111  SparseKelem.reserve(40);
112  };
113 
125  void operator()(SparseMat &Kg, const Job &job, const std::vector<Tie> &ties);
126 
133  void calcKelem(unsigned int i, const Job &job);
134 
143  void calcAelem(const Eigen::Vector3d &nx, const Eigen::Vector3d &nz);
144 
149  LocalMatrix getKelem() {
150  return Kelem;
151  }
152 
157  LocalMatrix getAelem() {
158  return Aelem;
159  }
160 
161  private:
162  LocalMatrix Kelem;
164  LocalMatrix Klocal;
166  LocalMatrix Aelem;
168  LocalMatrix AelemT;
170  SparseMat SparseKelem;
171  };
172 
187  void loadBCs(SparseMat &Kg, ForceVector &force_vec, const std::vector<BC> &BCs, unsigned int num_nodes);
188 
199  void loadTies(std::vector<Eigen::Triplet<double> > &triplets, const std::vector<Tie> &ties);
200 
201 
210  std::vector<std::vector<double> > computeTieForces(const std::vector<Tie> &ties,
211  const std::vector<std::vector<double> > &nodal_displacements);
212 
219  void loadForces(SparseMat &force_vec, const std::vector<Force> &forces);
220 
234  Summary solve(const Job &job,
235  const std::vector<BC> &BCs,
236  const std::vector<Force> &forces,
237  const std::vector<Tie> &ties,
238  const Options &options);
239 } // namespace fea
240 
241 #endif // THREED_BEAM_FEA_H
Assembles the global stiffness matrix.
Definition: threed_beam_fea.h:97
GlobalStiffAssembler()
Default constructor.
Definition: threed_beam_fea.h:105
Eigen::Matrix< double, 12, 12, Eigen::RowMajor > LocalMatrix
Definition: threed_beam_fea.h:70
void calcAelem(const Eigen::Vector3d &nx, const Eigen::Vector3d &nz)
Updates the rotation and transposed rotation matrices.
Definition: threed_beam_fea.cpp:136
double norm(const Node &n1, const Node &n2)
Calculates the distance between 2 nodes.
Definition: threed_beam_fea.cpp:49
Summary solve(const Job &job, const std::vector< BC > &BCs, const std::vector< Force > &forces, const std::vector< Tie > &ties, const Options &options)
Solves the finite element analysis defined by the input Job, boundary conditions, and prescribed noda...
Definition: threed_beam_fea.cpp:378
LocalMatrix getKelem()
Returns the currently stored elemental stiffness matrix.
Definition: threed_beam_fea.h:149
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:65
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:309
Eigen::SparseMatrix< double > SparseMat
Definition: threed_beam_fea.h:81
LocalMatrix getAelem()
Returns the currently stored rotation matrix.
Definition: threed_beam_fea.h:157
void calcKelem(unsigned int i, const Job &job)
Updates the elemental stiffness matrix for the ith element.
Definition: threed_beam_fea.cpp:54
void loadForces(SparseMat &force_vec, const std::vector< Force > &forces)
Loads the prescribed forces into the force vector.
Definition: threed_beam_fea.cpp:368
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:343
Eigen::Vector3d Node
A node that describes a mesh. Uses Eigen's predefined Vector class for added functionality.
Definition: containers.h:56
Contains a node list, element list, and the properties of each element.
Definition: containers.h:246
Eigen::Matrix< double, Eigen::Dynamic, 1 > ForceVector
Definition: threed_beam_fea.h:76
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:226