My Project
MeshSTL.h
1 #include "Node.h"
2 #include "Material.h"
3 #include "Element.h"
4 #include "MSHParser.h"
5 #include <vector>
6 
7 #define EIGEN_NO_DEBUG
8 #include <Eigen/Sparse>
9 #include <Eigen/SparseCholesky>
10 #include <Eigen/SparseLU>
11 #include <time.h>
12 #include <math.h>
13 
14 #ifndef MESHSTL
15 #define MESHSTL
16 
17 using namespace Eigen;
18 
20 class MeshSTL
21 {
22 
23 public:
24  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
25 
26  double Ax;
27  double Ay;
28  double totalArea;
29  double areaStiffness;
30 
31  double Ix;
32  double Iy;
33  double Ixy;
34  double Imax;
37 
42  MeshSTL(std::string fileName, Material mat);
43  MeshSTL();
44 
45  std::vector<Element*> elements;
46  std::vector<Node> nodes;
47 
53  void solveBendingMoments();
54 
55  MatrixXd sigmaAxial;
56 
57  MatrixXd sigmaOfX;
58  MatrixXd sigmaOfY;
59 
61  void solveTorsion();
63 
64  void solveShearX();
65  void solveShearY();
66  void applyShearFactor(MatrixXd &S, std::string);
67  std::string shearType; // Variable used in applyShearLoad, that is dependent on the shear analysis being in x or y direction
68 
72  void setMaterial(Material);
73 
83  void calculateMeshProperties();
84 
91  void transformCoordinates();
92 
97  void calculateSecondAreaMoments();
98 
106  void calculateAnglePrincipalAxes();
107  double getAnglePrincipalAxes();
108 
109  void calculateLineCenterNodes();
110 
111  // double computeShearYCentre();
112 
118  void solveEquations(SparseMatrix<double> &A, MatrixXd &b, MatrixXd &C);
119  void constrainDOF(SparseMatrix<double> &K, MatrixXd &R, int nNumber);
120  void constrainNodeNearCenter(SparseMatrix<double> &K, MatrixXd &R);
121 
122  Node getNodeAt(int n);
123  Element* getElementAt(int e);
124 
125  int getNumNodes() { return nodes.size(); }
126  int getNumElements() { return elements.size(); }
127 
128  MatrixXd tauXZtorsion;
129  MatrixXd tauYZtorsion;
130  MatrixXd tauRtorsion;
131 
132  MatrixXd tauXZshearX;
133  MatrixXd tauYZshearX;
134  MatrixXd tauRshearX;
135 
136  MatrixXd tauXZshearY;
137  MatrixXd tauYZshearY;
138  MatrixXd tauRshearY;
139 
140  MatrixXd torsion_displacement; //Stores values for displacement for the case of torsion
141  MatrixXd torsion_load; //Stores values for load for the case of torsion
142 
143  MatrixXd shearX_load; //Stores values for load for the case of shearX
144  MatrixXd shearX_displacement; //Stores values for displacement for the case of shearX
145 
146  MatrixXd shearY_load; //Stores values for load for the case of shearY
147  MatrixXd shearY_displacement; //Stores values for displacement for the case of shearY
148 
149  MatrixXd printTemp1;
150  MatrixXd printTemp2;
151 
152  void SetSmoothNodalTau();
153 
154 private:
155  //Material with values for Youngs modulus, Poisson's ratio and shear modulus
156  Material material;
157 
162  void clean(MatrixXd &);
163  void printr(int[], int);
164 
165  // ********** Torsional Moment **********
166 
167  //SparseMatrix<double> torsionalStiffness; //!< System stiffness matrix
168  //MatrixXd torsionalLoad; //!< System load matrix
169  //MatrixXd torsionalDisplacement; //!< System displacement matrix
170  //
171  //SparseMatrix<double> shearXStiffness;
172  //MatrixXd shearXLoad;
173  //MatrixXd shearXDisplacement;
174 
175  //SparseMatrix<double> shearYStiffness;
176  //MatrixXd shearYLoad;
177  //MatrixXd shearYDisplacement;
178 
179  SparseMatrix<double> stiffness;
180  MatrixXd load;
181  MatrixXd displacement;
182 
199  void systemEquations(SparseMatrix<double> &K, MatrixXd &R);
200 
201  void systemLoadVector(MatrixXd &R);
202 
203 
210  void addToGlobal2DMatrix(SparseMatrix<double> &, MatrixXd, std::vector<int>);
211  void addtoGlobalRowMatrix(MatrixXd &, MatrixXd, std::vector<int>);
212 
213  void addLocalToGlobalSparse(SparseMatrix<double> &mat, int e);
214  void addLocalToGlobalSparse(SparseMatrix<double> &mat);
215  void addLocalToGlobalVector(MatrixXd &mat, int e);
216  void addLocalToGlobalVector(VectorXd &vec, int e);
217 
225  void addSubMatrix(SparseMatrix<double> &, int, int, double);
226 
227  int getNodeNearCenter();
228 
234  void flush();
235 
236 };
237 
238 #endif
double anglePrincipalAxes
Stores the angle of the principal axes in degrees.
Definition: MeshSTL.h:35
MatrixXd sigmaOfY
Stores all nodal stresses from moment about y-axis.
Definition: MeshSTL.h:58
Contains element data and relevant functions.
Definition: Element.h:12
Contains mesh data and has function to calculate and retrieve mesh properties.
Definition: MeshSTL.h:20
Struct that holds the x and y coordinate for each node.
Definition: Node.h:10
MatrixXd sigmaAxial
Stores nodal stress from axial force.
Definition: MeshSTL.h:55
std::vector< Element * > elements
List of all elements in mesh.
Definition: MeshSTL.h:45
MatrixXd tauXZtorsion
Stores nodal from torsional load.
Definition: MeshSTL.h:128
double anglePrincipalAxesRad
Stores the angle of the principal axes in radians.
Definition: MeshSTL.h:36
double Imax
Maximum second area moment for mesh along principal axis.
Definition: MeshSTL.h:34
MatrixXd tauYZshearY
Stores nodal from shear load in y-direction.
Definition: MeshSTL.h:137
double Ix
Second area moment for mesh in X-direction.
Definition: MeshSTL.h:31
MatrixXd sigmaOfX
Stores all nodal stresses from moment about x-axis.
Definition: MeshSTL.h:57
MatrixXd tauXZshearY
Stores nodal from shear load in y-direction.
Definition: MeshSTL.h:136
MatrixXd printTemp1
Used in testing to store desired value for printing.
Definition: MeshSTL.h:149
MatrixXd tauXZshearX
Stores nodal from shear load in x-direction.
Definition: MeshSTL.h:132
Contains material data such as Young&#39;s Modulus, Shear Modulus and Poisson&#39;s ratio, and if needed could include additional material properties.
Definition: Material.h:3
MatrixXd tauRshearY
Stores nodal from shear load in y-direction.
Definition: MeshSTL.h:138
double Ay
Area centre for mesh in Y-direction.
Definition: MeshSTL.h:27
MatrixXd tauYZtorsion
Stores nodal from torsional load.
Definition: MeshSTL.h:129
double totalArea
Total area of the mesh.
Definition: MeshSTL.h:28
double Iy
Second area moment for mesh in Y-direction.
Definition: MeshSTL.h:32
std::vector< Node > nodes
List of all nodes in mesh.
Definition: MeshSTL.h:46
double Ixy
Second area moment for mesh in XY-direction.
Definition: MeshSTL.h:33
MatrixXd tauRshearX
Stores nodal from shear load in x-direction.
Definition: MeshSTL.h:134
MatrixXd printTemp2
Used in testing to store desired value for printing.
Definition: MeshSTL.h:150
MatrixXd tauYZshearX
Stores nodal from shear load in x-direction.
Definition: MeshSTL.h:133
EIGEN_MAKE_ALIGNED_OPERATOR_NEW double Ax
< Neccessary for std::vector of objects with Eigen members.
Definition: MeshSTL.h:26
double areaStiffness
Sum of all Ai * Ei.
Definition: MeshSTL.h:29
MatrixXd tauRtorsion
Stores nodal from torsional load.
Definition: MeshSTL.h:130