My Project
Mesh.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 MESH
15 #define MESH
16 
17 using namespace Eigen;
18 
20 class Mesh
21 {
22 
23 public:
24  // \cond
25  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
26  // \endcond
27 
28 
29  double Ax;
30  double Ay;
31  double totalArea;
32  double areaStiffness;
33 
34  double Ix;
35  double Iy;
36  double Ixy;
37  double Imax;
38 
39  double EIx;
40  double EIy;
41  double EIxy;
42  double EImax;
43 
46 
54  Mesh(std::string fileName, Material mat);
55  Mesh();
56 
57  std::vector<Element*> elements;
58  std::vector<Node> nodes;
59 
66  void solveBendingMoments();
67 
68  MatrixXd sigmaAxial;
69 
70  MatrixXd sigmaOfX;
71  MatrixXd sigmaOfY;
72 
73  void solveTorsion();
74  void solveShearX();
75  void solveShearY();
76  void Mesh::applyShearFactor(MatrixXd &S, std::string);
77  std::string shearType;
78  void setMaterial(Material);
79 
89  void calculateMeshProperties();
90 
97  void transformCoordinates();
98 
105  void calculateMeshBendingStiffness();
106 
114  void calculateMeshSecondMomentsOfArea();
115 
124  void calculateAnglePrincipalAxes();
125 
126  double getAnglePrincipalAxes();
127 
128 
138  void solveEquations(SparseMatrix<double> &A, MatrixXd &b, MatrixXd &C);
139 
165  void constrainDOF(SparseMatrix<double> &K, MatrixXd &R, int nNumber);
166 
167  void constrainNodeNearCenter(SparseMatrix<double> &K, MatrixXd &R);
168 
169  Node getNodeAt(int n);
170 
171  Element* getElementAt(int e);
172 
173  int getNumNodes() {return nodes.size();}
174 
175  int getNumElements() {return elements.size();}
176 
177  void SetSmoothNodalTau();
178 
179  MatrixXd tauXZtorsion;
180  MatrixXd tauYZtorsion;
181  MatrixXd tauRtorsion;
182 
183  MatrixXd tauXZshearX;
184  MatrixXd tauYZshearX;
185  MatrixXd tauRshearX;
186 
187  MatrixXd tauXZshearY;
188  MatrixXd tauYZshearY;
189  MatrixXd tauRshearY;
190 
192  MatrixXd torsion_load;
193 
194  MatrixXd shearX_load;
196 
197  MatrixXd shearY_load;
199 
200  MatrixXd printTemp1;
201  MatrixXd printTemp2;
202 
203 private:
204  Material material;
205 
206  void clean(MatrixXd &);
207 
208  SparseMatrix<double> stiffness;
209  MatrixXd load;
210  MatrixXd displacement;
211 
232  void systemEquations(SparseMatrix<double> &K, MatrixXd &R);
233 
234  void systemLoadVector(MatrixXd &R);
235 
236  void addLocalToGlobalSparse(SparseMatrix<double> &mat, int e);
237  void addLocalToGlobalSparse(SparseMatrix<double> &mat);
238  void addLocalToGlobalVector(MatrixXd &mat, int e);
239  void addLocalToGlobalVector(VectorXd &vec, int e);
240 
249  void addSubMatrix(SparseMatrix<double> &, int, int, double);
250 
251  int getNodeNearCenter();
252 
253  void flush();
254 
255 };
256 
257 #endif
MatrixXd tauYZtorsion
Stores nodal from torsional load.
Definition: Mesh.h:180
Contains mesh data and has function to calculate and retrieve mesh properties.
Definition: Mesh.h:20
Contains element data and relevant functions.
Definition: Element.h:12
int getNumElements()
Returns total number of elements.
Definition: Mesh.h:175
double EImax
Maximum second area moment for mesh along principal axis.
Definition: Mesh.h:42
Struct that holds the x and y coordinate for each node.
Definition: Node.h:10
MatrixXd torsion_displacement
Stores values for displacement for the case of torsion.
Definition: Mesh.h:191
MatrixXd sigmaOfY
Stores all nodal stresses from moment about y-axis.
Definition: Mesh.h:71
std::string shearType
Variable used in applyShearLoad, that is dependent on the shear analysis being in x or y direction...
Definition: Mesh.h:77
double EIx
Second area moment for mesh in X-direction.
Definition: Mesh.h:39
double EIy
Second area moment for mesh in Y-direction.
Definition: Mesh.h:40
double Imax
Maximum second area moment for mesh along principal axis.
Definition: Mesh.h:37
void applyShearFactor(MatrixXd &S, std::string)
Divides the load vector by the seccond moment of area Iy or Ix.
Definition: Mesh.cpp:551
double Ax
Area centre for mesh in X-direction.
Definition: Mesh.h:29
MatrixXd shearY_displacement
Stores values for displacement for the case of shearY.
Definition: Mesh.h:198
MatrixXd tauRtorsion
Stores nodal from torsional load.
Definition: Mesh.h:181
MatrixXd shearX_load
Stores values for load for the case of shearX.
Definition: Mesh.h:194
double totalArea
Total area of the mesh.
Definition: Mesh.h:31
double areaStiffness
Sum of all Ai * Ei.
Definition: Mesh.h:32
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 tauRshearX
Stores nodal from shear load in x-direction.
Definition: Mesh.h:185
MatrixXd sigmaAxial
Stores nodal stress from axial force.
Definition: Mesh.h:68
MatrixXd tauYZshearY
Stores nodal from shear load in y-direction.
Definition: Mesh.h:188
std::vector< Node > nodes
List of all nodes in mesh.
Definition: Mesh.h:58
MatrixXd printTemp2
Used in testing to store desired value for printing.
Definition: Mesh.h:201
MatrixXd sigmaOfX
Stores all nodal stresses from moment about x-axis.
Definition: Mesh.h:70
MatrixXd tauXZshearY
Stores nodal from shear load in y-direction.
Definition: Mesh.h:187
std::vector< Element * > elements
List of all elements in mesh.
Definition: Mesh.h:57
MatrixXd tauYZshearX
Stores nodal from shear load in x-direction.
Definition: Mesh.h:184
double Ixy
Second area moment for mesh in XY-direction.
Definition: Mesh.h:36
MatrixXd tauXZshearX
Stores nodal from shear load in x-direction.
Definition: Mesh.h:183
MatrixXd tauRshearY
Stores nodal from shear load in y-direction.
Definition: Mesh.h:189
double Ay
Area centre for mesh in Y-direction.
Definition: Mesh.h:30
double Ix
Second area moment for mesh in X-direction.
Definition: Mesh.h:34
int getNumNodes()
Returns total number of nodes.
Definition: Mesh.h:173
MatrixXd shearY_load
Stores values for load for the case of shearY.
Definition: Mesh.h:197
double Iy
Second area moment for mesh in Y-direction.
Definition: Mesh.h:35
MatrixXd tauXZtorsion
Stores nodal from torsional load.
Definition: Mesh.h:179
double anglePrincipalAxes
Stores the angle of the principal axes in degrees.
Definition: Mesh.h:44
MatrixXd shearX_displacement
Stores values for displacement for the case of shearX.
Definition: Mesh.h:195
MatrixXd torsion_load
Stores values for load for the case of torsion.
Definition: Mesh.h:192
double EIxy
Second area moment for mesh in XY-direction.
Definition: Mesh.h:41
MatrixXd printTemp1
Used in testing to store desired value for printing.
Definition: Mesh.h:200
double anglePrincipalAxesRad
Stores the angle of the principal axes in radians.
Definition: Mesh.h:45