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 
26 class MeshSTL
27 {
28 
29 public:
30  // \cond
31  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
32  // \endcond
33 
34  static const int meshType = 0;
35 
36  double Ax;
37  double Ay;
38  double totalArea;
39  double areaStiffness;
40  double shearStiffness;
41 
42  double EIx;
43  double EIy;
44  double EIxy;
45  double EImax;
46 
47  double EIxp;
48  double EIyp;
49 
50  double Ix;
51  double Iy;
52  double Ixy;
53  double Imax;
54 
55  double Ixp;
56  double Iyp;
57 
58  double GIt;
59  double rateOfTwist;
60  double Kx;
61  double Ky;
62  double torsion_xs;
63  double torsion_ys;
64 
65  double N;
66  double Mx;
67  double My;
68  double Vx;
69  double Vy;
70 
73 
74  MatrixXd sigmaAxial;
75  MatrixXd sigmaTorsion;
76  MatrixXd sigmaShearXY;
77 
78  MatrixXd tauTorsion;
79  MatrixXd tauShearX;
80  MatrixXd tauShearY;
81 
82  MatrixXd sigmaResulting;
83  MatrixXd tauXZResulting;
84  MatrixXd tauYZResulting;
85  MatrixXd tauResulting;
86 
87  MatrixXd effectiveStress;
88 
90  MatrixXd torsion_load;
91 
92  MatrixXd shearX_load;
94 
95  MatrixXd shearY_load;
97 
98  MatrixXd printTemp1;
99  MatrixXd printTemp2;
100 
108  MeshSTL(std::string fileName, Material mat);
109  MeshSTL();
110 
111  std::vector<Element*> elements;
112  std::vector<Node> nodes;
113 
120  void solveBendingMoments();
121 
122 
123 
124  void solveTorsion();
125  void solveShearX();
126  void solveShearY();
127  void applyShearFactor(MatrixXd &S, std::string);
128  std::string shearType;
129  void setMaterial(Material);
130  double getAnglePrincipalAxes();
131 
132  void constrainNodeNearCenter(SparseMatrix<double> &K, MatrixXd &R);
133  Node getNodeAt(int n);
134  Element* getElementAt(int e);
135  int getNumNodes() { return nodes.size(); }
136  int getNumElements() { return elements.size(); }
137  void SetSmoothNodalTau();
138 
148  void calculateMeshProperties();
149 
156  void transformCoordinates();
157 
164  void calculateMeshBendingStiffness();
165 
173  void calculatePrincipalBendingStiffness();
174 
182  void calculateMeshSecondMomentsOfArea();
183 
191  void calculateAnglePrincipalAxes();
192 
193 
203  void solveEquations(SparseMatrix<double> &A, MatrixXd &b, MatrixXd &C);
204 
230  void constrainDOF(SparseMatrix<double> &K, MatrixXd &R, int nNumber);
231 
232 
240  void calculatePrincipalSecondMomentsOfArea();
241 
242 
250  void calculateSigmaZfromShearLoad();
251 
252 
256  void calculateSigmaResulting();
257 
258 
262  void calculateTauResulting();
263 
264 
270  void calculateEffectiveStress();
271 
272 
273 
274 private:
276 
277  SparseMatrix<double> stiffness;
278  MatrixXd load;
279  MatrixXd displacement;
280 
301  void systemEquations(SparseMatrix<double> &K, MatrixXd &R);
302 
303  void systemLoadVector(MatrixXd &R);
304 
305  void addLocalToGlobalSparse(SparseMatrix<double> &mat, int e);
306  void addLocalToGlobalVector(MatrixXd &mat, int e);
307 
316  void addSubMatrix(SparseMatrix<double> &, int, int, double);
317 
318  int getNodeNearCenter();
319 
320  void flush();
321 
326  void findSurroundingElementsForNodes();
327 
335  void calculateShearDeformationFactorX();
336 
344  void calculateShearDeformationFactorY();
345 
346 
347 };
348 
349 #endif
double anglePrincipalAxes
Stores the angle of the principal axes in degrees.
Definition: MeshSTL.h:71
double torsion_ys
Shear center in y-direction, due to torsion load.
Definition: MeshSTL.h:63
Contains element data and relevant functions for massive analysis.
Definition: Element.h:13
Is based on Mesh but store results to be outputted in .stl format.
Definition: MeshSTL.h:26
int getNumElements()
Returns total number of elements.
Definition: MeshSTL.h:136
MatrixXd torsion_displacement
Stores values for displacement for the case of torsion.
Definition: MeshSTL.h:89
Struct that holds nodal properties.
Definition: Node.h:10
MatrixXd displacement
system displacement vector
Definition: MeshSTL.h:279
MatrixXd torsion_load
Stores values for load for the case of torsion.
Definition: MeshSTL.h:90
double Ky
Shear factor y.
Definition: MeshSTL.h:61
MatrixXd sigmaAxial
Stores nodal stress from axial force.
Definition: MeshSTL.h:74
MatrixXd sigmaTorsion
Stores all nodal stresses from moment about x- and y-axis respectively.
Definition: MeshSTL.h:75
double EIx
Bending stiffness about x-direction.
Definition: MeshSTL.h:42
double Vy
Shear force in y-direction to be applied to the cross section.
Definition: MeshSTL.h:69
double Mx
Bending moment in x-direction to be applied to the cross section.
Definition: MeshSTL.h:66
std::vector< Element * > elements
List of all elements in mesh.
Definition: MeshSTL.h:111
MatrixXd shearY_load
Stores values for load for the case of shearY.
Definition: MeshSTL.h:95
double Iyp
Second area moment for mesh in principal y-direction.
Definition: MeshSTL.h:56
MatrixXd sigmaResulting
Stores nodal from axial, torsion and shear load in both directions.
Definition: MeshSTL.h:82
Material material
Material with values for Youngs modulus, Poisson&#39;s ratio and shear modulus.
Definition: MeshSTL.h:275
double GIt
St.Venant stiffness.
Definition: MeshSTL.h:58
double anglePrincipalAxesRad
Stores the angle of the principal axes in radians.
Definition: MeshSTL.h:72
double Imax
Maximum second area moment for mesh along principal axis.
Definition: MeshSTL.h:53
double torsion_xs
Shear center in x-direction, due to torsion load.
Definition: MeshSTL.h:62
MatrixXd shearX_load
Stores values for load for the case of shearX.
Definition: MeshSTL.h:92
double N
Normal force to be applied to the cross section.
Definition: MeshSTL.h:65
MatrixXd tauYZResulting
Stores nodal from axial, torsion and shear load in both directions.
Definition: MeshSTL.h:84
double Ix
Second area moment for mesh in x-direction.
Definition: MeshSTL.h:50
MatrixXd shearX_displacement
Stores values for displacement for the case of shearX.
Definition: MeshSTL.h:93
double EIxp
Bending stiffness about principal x-direction.
Definition: MeshSTL.h:47
MatrixXd printTemp1
Used in testing to store desired value for printing.
Definition: MeshSTL.h:98
std::string shearType
Variable used in applyShearLoad, that is dependent on the shear analysis being in x or y direction...
Definition: MeshSTL.h:128
MatrixXd effectiveStress
Stores nodal from axial, torsion and shear load in both directions.
Definition: MeshSTL.h:87
MatrixXd tauShearX
Stores nodal , and respectively from shear load in x-direction.
Definition: MeshSTL.h:79
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
double Vx
Shear force in x-direction to be applied to the cross section.
Definition: MeshSTL.h:68
double Ay
Area centre for mesh in Y-direction.
Definition: MeshSTL.h:37
double EIy
Bending stiffness about y-direction.
Definition: MeshSTL.h:43
double totalArea
Total area of the mesh.
Definition: MeshSTL.h:38
double My
Bending moment in y-direction to be applied to the cross section.
Definition: MeshSTL.h:67
MatrixXd tauShearY
Stores nodal , and respectively from shear load in y-direction.
Definition: MeshSTL.h:80
double EImax
Maximum bending stiffness for mesh along principal axis.
Definition: MeshSTL.h:45
double Iy
Second area moment for mesh in y-direction.
Definition: MeshSTL.h:51
double Ax
Area centre for mesh in X-direction.
Definition: MeshSTL.h:36
std::vector< Node > nodes
List of all nodes in mesh.
Definition: MeshSTL.h:112
int getNumNodes()
Returns total number of nodes.
Definition: MeshSTL.h:135
MatrixXd tauResulting
Stores nodal from axial, torsion and shear load in both directions.
Definition: MeshSTL.h:85
double Ixy
Second area moment product.
Definition: MeshSTL.h:52
double shearStiffness
Sum of all Ai * Gi.
Definition: MeshSTL.h:40
double Ixp
Second area moment for mesh in principal x-direction.
Definition: MeshSTL.h:55
MatrixXd load
system load vector
Definition: MeshSTL.h:278
MatrixXd tauTorsion
Stores nodal , and respectively from torsional load.
Definition: MeshSTL.h:78
MatrixXd sigmaShearXY
Stores nodal from shear load in x- and y-direction respectively.
Definition: MeshSTL.h:76
double rateOfTwist
Rate of twist, used for torsion analysis.
Definition: MeshSTL.h:59
double EIyp
Bending stiffness about principal y-direction.
Definition: MeshSTL.h:48
MatrixXd printTemp2
Used in testing to store desired value for printing.
Definition: MeshSTL.h:99
MatrixXd tauXZResulting
Stores nodal from axial, torsion and shear load in both directions.
Definition: MeshSTL.h:83
MatrixXd shearY_displacement
Stores values for displacement for the case of shearY.
Definition: MeshSTL.h:96
SparseMatrix< double > stiffness
System stiffness matrix.
Definition: MeshSTL.h:277
double EIxy
Bending stiffness product.
Definition: MeshSTL.h:44
double Kx
Shear factor x.
Definition: MeshSTL.h:60
double areaStiffness
Sum of all Ai * Ei.
Definition: MeshSTL.h:39