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 
21 class Mesh
22 {
23 
24 public:
25  // \cond
26  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
27  // \endcond
28 
29  static const int meshType = 1;
30  double Ax;
31  double Ay;
32  double totalArea;
33  double areaStiffness;
34  double shearStiffness;
35 
36  double EIx;
37  double EIy;
38  double EIxy;
39  double EImax;
40 
41  double EIxp;
42  double EIyp;
43 
44  double Ix;
45  double Iy;
46  double Ixy;
47  double Imax;
48 
49  double Ixp;
50  double Iyp;
51  double It;
52 
53  double GIt;
54  double rateOfTwist;
55  double Kx;
56  double Ky;
57  double torsion_xs;
58  double torsion_ys;
59 
60  double N;
61  double Mx;
62  double My;
63  double Mz;
64  double Vx;
65  double Vy;
66 
69  std::string shearType;
70 
72 
73  MatrixXd sigmaAxial;
74  MatrixXd sigmaTorsion;
75  MatrixXd sigmaShearXY;
76 
77  MatrixXd tauTorsion;
78  MatrixXd tauShearX;
79  MatrixXd tauShearY;
80 
81  MatrixXd sigmaResulting;
82  MatrixXd tauXZResulting;
83  MatrixXd tauYZResulting;
84  MatrixXd tauResulting;
85 
86  MatrixXd tauComposite;
87 
88  MatrixXd effectiveStress;
89 
90  MatrixXd torsion_load;
92 
93  MatrixXd shearX_load;
95 
96  MatrixXd shearY_load;
98 
99  MatrixXd printTemp1;
100  MatrixXd printTemp2;
101 
109  Mesh(std::string fileName, Material mat);
110  Mesh();
111 
112  std::vector<Element*> elements;
113  std::vector<Node> nodes;
114 
115  void solveTorsion();
116  void solveShearX();
117  void solveShearY();
118  void calculateComposite();
119  double getAnglePrincipalAxes();
120 
121  Node getNodeAt(int n);
122  Element* getElementAt(int e);
123  int getNumNodes() { return nodes.size(); }
124  int getNumElements() { return elements.size(); }
125  void SetSmoothNodalTau();
126 
127 
134  void solveBendingMoments();
135 
141  void setMaterial(Material);
142 
149  void applyShearFactor(MatrixXd &S, std::string shearType);
150 
157  void constrainNodeNearCenter(SparseMatrix<double> &K, MatrixXd &R);
158 
168  void calculateMeshProperties();
169 
176  void transformCoordinates();
177 
184  void calculateMeshBendingStiffness();
185 
193  void calculatePrincipalBendingStiffness();
194 
202  void calculateMeshSecondMomentsOfArea();
203 
212  void calculateAnglePrincipalAxes();
213 
214 
224  void solveEquations(SparseMatrix<double> &A, MatrixXd &b, MatrixXd &C);
225 
251  void constrainDOF(SparseMatrix<double> &K, MatrixXd &R, int nNumber);
252 
253 
261  void calculatePrincipalSecondMomentsOfArea();
262 
263 
271  void calculateSigmaZfromShearLoad();
272 
273 
277  void calculateSigmaResulting();
278 
279 
283  void calculateTauResulting();
284 
285 
291  void calculateEffectiveStress();
292 
293 
294 
295 private:
296 
297 
298  SparseMatrix<double> stiffness;
299  MatrixXd load;
300  MatrixXd displacement;
301 
322  void systemEquations(SparseMatrix<double> &K, MatrixXd &R);
323 
330  void systemLoadVector(MatrixXd &R);
331 
338  void addLocalToGlobalSparse(SparseMatrix<double> &K, int e);
339 
340 
346  void addLocalToGlobalVector(MatrixXd &R, int e);
347 
356  void addSubMatrix(SparseMatrix<double> &systemMatrix, int n1, int n2, double value);
357 
361  int getNodeNearCenter();
362 
366  void flush();
367 
372  void findSurroundingElementsForNodes();
373 
381  void calculateShearDeformationFactorX();
382 
390  void calculateShearDeformationFactorY();
391 
392 };
393 
394 #endif
MatrixXd tauYZResulting
Stores nodal from axial, torsion and shear load in both directions.
Definition: Mesh.h:83
MatrixXd tauTorsion
Stores nodal , and respectively from torsional load.
Definition: Mesh.h:77
Contains mesh data for massive analysis. Performs stress analysis on this mesh.
Definition: Mesh.h:21
Contains element data and relevant functions for massive analysis.
Definition: Element.h:13
double My
Bending moment in y-direction to be applied to the cross section.
Definition: Mesh.h:62
int getNumElements()
Returns total number of elements.
Definition: Mesh.h:124
double Vy
Shear force in y-direction to be applied to the cross section.
Definition: Mesh.h:65
double EImax
Maximum bending stiffness for mesh along principal axis.
Definition: Mesh.h:39
Struct that holds nodal properties.
Definition: Node.h:10
MatrixXd torsion_displacement
Stores values for displacement for the case of torsion. Only used for validation during testing...
Definition: Mesh.h:91
double N
Normal force to be applied to the cross section.
Definition: Mesh.h:60
MatrixXd load
system load vector
Definition: Mesh.h:299
Material baseMaterial
Material with values for Youngs modulus, Poisson&#39;s ratio and shear modulus.
Definition: Mesh.h:71
SparseMatrix< double > stiffness
System stiffness matrix.
Definition: Mesh.h:298
MatrixXd displacement
system displacement vector
Definition: Mesh.h:300
MatrixXd tauComposite
Stores nodal and respectively from torsion and shear load in both directions.
Definition: Mesh.h:86
std::string shearType
Variable used in applyShearLoad, that is dependent on the shear analysis being in x or y directions...
Definition: Mesh.h:69
double EIx
Bending stiffness about x-direction.
Definition: Mesh.h:36
double torsion_xs
Shear center in x-direction, due to torsion load.
Definition: Mesh.h:57
double EIy
Bending stiffness about y-direction.
Definition: Mesh.h:37
MatrixXd tauShearX
Stores nodal , and respectively from shear load in x-direction.
Definition: Mesh.h:78
double Imax
Maximum second area moment for mesh along principal axis.
Definition: Mesh.h:47
MatrixXd effectiveStress
Stores nodal from axial, torsion and shear load in both directions.
Definition: Mesh.h:88
double rateOfTwist
Rate of twist, used for torsion analysis.
Definition: Mesh.h:54
double It
St. Venant torsion constant.
Definition: Mesh.h:51
double Ax
Area centre for mesh in X-direction.
Definition: Mesh.h:30
double shearStiffness
Sum of all Ai * Gi.
Definition: Mesh.h:34
MatrixXd shearY_displacement
Stores values for displacement for the case of shearY. Only used for validation during testing...
Definition: Mesh.h:97
MatrixXd shearX_load
Stores values for load for the case of shearX.
Definition: Mesh.h:93
double totalArea
Total area of the mesh.
Definition: Mesh.h:32
double areaStiffness
Sum of all Ai * Ei.
Definition: Mesh.h:33
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 tauResulting
Stores nodal from axial, torsion and shear load in both directions.
Definition: Mesh.h:84
MatrixXd sigmaShearXY
Stores nodal from shear load in x- and y-direction respectively.
Definition: Mesh.h:75
double Mz
Torsion moment about z-axis to be applied to the cross-section.
Definition: Mesh.h:63
MatrixXd sigmaAxial
Stores nodal stress from axial force.
Definition: Mesh.h:73
std::vector< Node > nodes
List of all nodes in mesh.
Definition: Mesh.h:113
MatrixXd printTemp2
Used in testing to store desired value for printing.
Definition: Mesh.h:100
MatrixXd sigmaTorsion
Stores all nodal stresses from moment about x- and y-axis respectively.
Definition: Mesh.h:74
MatrixXd tauShearY
Stores nodal , and respectively from shear load in y-direction.
Definition: Mesh.h:79
double Mx
Bending moment in x-direction to be applied to the cross section.
Definition: Mesh.h:61
std::vector< Element * > elements
List of all elements in mesh.
Definition: Mesh.h:112
double Kx
Shear factor x.
Definition: Mesh.h:55
double Ixp
Second area moment for mesh in principal x-direction.
Definition: Mesh.h:49
double Ixy
Second area moment product.
Definition: Mesh.h:46
double Vx
Shear force in x-direction to be applied to the cross section.
Definition: Mesh.h:64
double Ky
Shear factor y.
Definition: Mesh.h:56
double EIyp
Bending stiffness about principal y-direction.
Definition: Mesh.h:42
double Iyp
Second area moment for mesh in principal y-direction.
Definition: Mesh.h:50
double Ay
Area centre for mesh in Y-direction.
Definition: Mesh.h:31
MatrixXd sigmaResulting
Stores nodal from axial, torsion and shear load in both directions.
Definition: Mesh.h:81
double GIt
St.Venant stiffness.
Definition: Mesh.h:53
double Ix
Second area moment for mesh in x-direction.
Definition: Mesh.h:44
MatrixXd tauXZResulting
Stores nodal from axial, torsion and shear load in both directions.
Definition: Mesh.h:82
int getNumNodes()
Returns total number of nodes.
Definition: Mesh.h:123
MatrixXd shearY_load
Stores values for load for the case of shearY.
Definition: Mesh.h:96
double Iy
Second area moment for mesh in y-direction.
Definition: Mesh.h:45
double torsion_ys
Shear center in y-direction, due to torsion load.
Definition: Mesh.h:58
double anglePrincipalAxes
Stores the angle of the principal axes in degrees.
Definition: Mesh.h:67
double EIxp
Bending stiffness about principal x-direction.
Definition: Mesh.h:41
MatrixXd shearX_displacement
Stores values for displacement for the case of shearX. Only used for validation during testing...
Definition: Mesh.h:94
MatrixXd torsion_load
Stores values for load for the case of torsion.
Definition: Mesh.h:90
double EIxy
Bending stiffness product.
Definition: Mesh.h:38
MatrixXd printTemp1
Used in testing to store desired value for printing.
Definition: Mesh.h:99
double anglePrincipalAxesRad
Stores the angle of the principal axes in radians.
Definition: Mesh.h:68