LineMesh.h
1 #include "LineParser.h"
2 #include "CycleDetection.h"
3 #define EIGEN_NO_DEBUG
4 #include <Eigen/Dense>
5 #include <time.h>
6 #include <math.h>
7 #include "ResultWriter.h"
8 
9 #pragma once
10 class LineMesh
12 {
13 public:
14  int TAU_DUE_TO_VX = 0;
15  int TAU_DUE_TO_VY = 1;
16  int TAU_DUE_TO_WRP = 2;
17  int TAU_RESULTING = 3;
18  int TAU_STV = 4;
19 
20  int SIGMA_Z_DUE_TO_N = 0;
23  int SIGMA_Z_DUE_TO_B = 3;
25  int EFFECTIVE_STRESS = 5;
26 
27  int OMEGA_DIAGRAM = 0;
28 
31  double Ax;
32  double Ay;
33  double EA;
34  double EIx;
35  double EIy;
36  double EIxy;
37  double EImax;
38  double EIxp;
39  double EIyp;
40  double Sx;
41  double Sy;
42  double xs;
43  double ys;
44  double C;
45  double totalArea;
46  double areaStiffness;
48  double It;
50  double warpingConstant;
51  double kappaX;
52  double kappaY;
53 
54  double N;
55  double Mx;
56  double My;
57  double Vx;
58  double Vy;
59  double Bi;
60  double T_stv;
61  double T_wrp;
66 
67  MatrixXd B;
68  VectorXd a;
69  VectorXd p;
70 
83  MatrixXd D;
84 
94  VectorXd f_d;
95 
105  VectorXd f_d_Vx;
106 
116  VectorXd f_d_Vy;
117 
127  VectorXd f_d_Wrp;
128 
129  MatrixXd A1;
130  MatrixXd A2;
131  MatrixXd G1;
132  MatrixXd G2;
133  VectorXd q0;
134 
135  std::vector<LineElement*> elements;
136  std::vector<Node> nodes;
137  std::vector<std::vector<LineElement*>> cycles;
138  std::vector<LineElement*> orderedElements;
139  std::vector<std::vector<double>> midPoints;
140 
159  std::vector<std::vector<std::vector<double>>> omegaIntersectionPoints;
160 
161 
188  std::vector<std::vector<std::vector<double>>> sigmaZIntersectionPoints;
189 
190  std::vector<std::vector<bool>> omegaIntersection;
191 
192 
193  std::vector<double> extraPoint;
194  std::vector<double> tauIntersect;
195 
222  std::vector<std::vector<std::vector<double>>> tauIntersectionPoints;
223 
224 
250  std::vector<std::vector<bool>> sigmaZIntersection;
251 
252  LineMesh(std::string fileName, Material baseMaterial, int extraLineSegments);
253  LineMesh();
254 
261  void transformCoordinates();
270 
271  void calculateAreaStiffness();
272 
276  void printCoordinates();
277 
288 
293 
305 
309  void printCellAreas();
313  void printCells();
314 
315 
325  void constructBMatrix();
326 
335 
343  void solveSystemEquation();
344 
353 
357  void calculateShearFlow();
358 
366  void calculateOmega_c();
367 
376  std::vector<LineElement*> findCommonElements(std::vector<LineElement*> a, std::vector<LineElement*> b);
377 
383  std::vector<LineElement*> DFS();
384 
393  bool contains(std::vector<int> a, int b);
394 
398  void printOmega();
399 
400  void printOmega_c();
401 
405  void printDeltaOmega_c();
406 
410  void calculateShearCenter();
411 
415  void calculateOmega();
416 
421 
426 
434  void LineMesh::calculateSigmaZIntersection(int type, std::vector<std::vector<std::vector<double>>> *intersectionPoints, std::vector<std::vector<bool>> *intersection);
435 
443  void LineMesh::calculateOmegaIntersection(int type, std::vector<std::vector<std::vector<double>>> *intersectionPoints, std::vector<std::vector<bool>> *intersection);
444 
445 
449  void calculateEk();
450 
460  void calculateAxialStress();
461 
469 
476  void addElementPoints(VectorXd f_d, int type);
477 
484  void findElementIntersections(VectorXd f_d, int type);
485 
492  void calculateNodalTau(VectorXd f_d, int type);
493 
504  void initiateCVectors();
505 
511  void createA1Matrix();
512 
518  void createA2Matrix();
519 
531  void calculateG1Matrix();
532 
543  void calculateG2Matrix();
544 
568  void calculateQ0(VectorXd f_d, int type);
569 
576  void printEigenMatrix(MatrixXd A, std::string s);
577 
618  void initializeMatrices();
619 
630  double calculateQs(double s, LineElement* element, VectorXd f_d, int type);
631 
638  void calculateTau(VectorXd f_d, int type);
639 
643  void calculateTauSTV();
644 
645  void findMidPoints();
646 
647  void findElementsNextToNode();
648 
649  void findIntersections();
650 
661  void calculateKappaX();
662 
673  void calculateKappaY();
674 
675 
680 
681 
690  double calculateVonMisesStress(LineElement* element, int j);
691 
696 
697  ~LineMesh();
698 };
699 
int TAU_DUE_TO_VY
Int corrosponding to due to .
Definition: LineMesh.h:15
void addElementPoints(VectorXd f_d, int type)
Adds points along the element used for visualization of quadratic stress distributions.
Definition: LineMesh.cpp:534
Performs cycle detection on the cross section, used for determination of cells during thin-wall analy...
Definition: CycleDetection.h:7
void transformCoordinates()
Transforms coordinates for computation purposes.
Definition: LineMesh.cpp:130
std::vector< std::vector< std::vector< double > > > sigmaZIntersectionPoints
Three dimensional vector containing intersection points for .
Definition: LineMesh.h:188
void calculateOmegaIntersection()
Iterates through all elements and finds an omega intersection point if it exists. ...
Definition: LineMesh.cpp:439
void calculateKappaX()
Calculates shear deformation factor .
Definition: LineMesh.cpp:863
int SIGMA_Z_DUE_TO_B
Int corrosponding to due to .
Definition: LineMesh.h:23
void printCells()
Prints each cell, and its elements.
Definition: LineMesh.cpp:941
double T_wrp
Warping torsion to be applied to the cross section.
Definition: LineMesh.h:61
void findElementIntersections(VectorXd f_d, int type)
Finds the element intersection points for quadratic functions along the element.
Definition: LineMesh.cpp:569
std::vector< std::vector< LineElement * > > cycles
2d vector containing all cycles in the cross-section
Definition: LineMesh.h:137
double EIxy
Bending stiffness product.
Definition: LineMesh.h:36
void createA2Matrix()
Creates A2 matrix.
Definition: LineMesh.cpp:718
int OMEGA_DIAGRAM
Int corrosponding to omega diagram.
Definition: LineMesh.h:27
double EImax
Maximum bending stiffness.
Definition: LineMesh.h:37
double kappaY
Shear deformation factor .
Definition: LineMesh.h:52
void findElementsNextToNode()
Finds the number of elements that are neighboring each node.
Definition: LineMesh.cpp:854
double N
Normal force to be applied to the cross section.
Definition: LineMesh.h:54
void initiateCVectors()
Initializes the C vectors for each element.
Definition: LineMesh.cpp:526
void calculateKappaY()
Calculates shear deformation factor .
Definition: LineMesh.cpp:885
std::vector< LineElement * > findCommonElements(std::vector< LineElement * > a, std::vector< LineElement * > b)
Finds common elements in two vectors, could be moved to a UTILS class.
Definition: LineMesh.cpp:332
void printOmega_c()
prints omega_c values
Definition: LineMesh.cpp:976
int TAU_DUE_TO_VX
Int corrosponding to due to .
Definition: LineMesh.h:14
void calculatePrincipalMomentOfAreas()
Calculates the principal moment of areas and .
Definition: LineMesh.cpp:122
double Ay
Area centre for mesh in y-direction.
Definition: LineMesh.h:32
void calculateAreaStiffness()
Calculates the area stiffness EA.
Definition: LineMesh.cpp:88
int numberOfNodes
Number of nodes in the cross-section.
Definition: LineMesh.h:62
double C
Shear center constant.
Definition: LineMesh.h:44
void printEigenMatrix(MatrixXd A, std::string s)
prints out a matrix on Eigen format
Definition: LineMesh.cpp:996
void calculateEk()
Calculates average E value of all elements surrounding a node.
Definition: LineMesh.cpp:479
void solveSystemEquation()
Solves the system of equations.
Definition: LineMesh.cpp:230
void calculateQ0(VectorXd f_d, int type)
Calculates .
Definition: LineMesh.cpp:793
std::vector< double > tauIntersect
Vector containing intersectionpoints of tau.
Definition: LineMesh.h:194
VectorXd p
Modified shear flows around each cell.
Definition: LineMesh.h:69
void calculatePureStvTorsionStress()
Calculates the pure St.Venants torsion stress.
Definition: LineMesh.cpp:487
std::vector< LineElement * > elements
List of all elements in mesh.
Definition: LineMesh.h:135
int SIGMA_Z_RESULTING
Int corrosponding to resulting .
Definition: LineMesh.h:24
int SIGMA_Z_DUE_TO_N
Int corrosponding to due to .
Definition: LineMesh.h:20
double T_stv
St.Venant torsion to be applied to the cross section.
Definition: LineMesh.h:60
void calculateOmega_c()
Calculates for all the elements.
Definition: LineMesh.cpp:271
void findIntersections()
Finds diagram intersections for Sigma_z as well as omega.
Definition: LineMesh.cpp:653
double EIxp
Bending stiffness about principal x-axes.
Definition: LineMesh.h:38
Contains element data and relevant functions for thin-wall analysis.
Definition: LineElement.h:7
std::vector< std::vector< double > > midPoints
Vector containing the middle points of each elements.
Definition: LineMesh.h:139
double My
Bending moment in y-direction to be applied to the cross section.
Definition: LineMesh.h:56
void calculateG1Matrix()
Calculates G1 matrix.
Definition: LineMesh.cpp:752
double Vx
Shear force in x-direction to be applied to the cross section.
Definition: LineMesh.h:57
int SIGMA_Z_DUE_TO_MY
Int corrosponding to due to .
Definition: LineMesh.h:22
VectorXd a
A vector of doubles representing the areas of the cells found in the elements.
Definition: LineMesh.h:68
double anglePrincipalAxes
Stores the angle of the principal axes in degrees.
Definition: LineMesh.h:29
double calculateQs(double s, LineElement *element, VectorXd f_d, int type)
Calculates the shear value at a distance s along the element.
Definition: LineMesh.cpp:815
std::vector< LineElement * > DFS()
Creates a vector of LineElement pointers that are sorted in a DFS fashion, could be extracted to a UT...
Definition: LineMesh.cpp:350
int SIGMA_Z_DUE_TO_MX
Int corrosponding to due to .
Definition: LineMesh.h:21
void calculateResultingSigmaExtra()
Calculates to resulting sigma for all extra points in the element.
Definition: LineMesh.cpp:907
void constructBMatrix()
Constructs coefficiant matrix .
Definition: LineMesh.cpp:187
int TAU_RESULTING
Int corrosponding to due to resulting tau.
Definition: LineMesh.h:17
double Mx
Bending moment in x-direction to be applied to the cross section.
Definition: LineMesh.h:55
void calculateOmega()
Calculates omega for each node in the cross-section.
Definition: LineMesh.cpp:416
double calculateVonMisesStress(LineElement *element, int j)
Calculates von mises stress.
Definition: LineMesh.cpp:924
void calculateNodalTau(VectorXd f_d, int type)
Calculates tau values for the nodes.
Definition: LineMesh.cpp:634
void calculateTauSTV()
Calculates tau for applied .
Definition: LineMesh.cpp:840
VectorXd q0
Vector of shear flow in the middle of each element.
Definition: LineMesh.h:133
std::vector< std::vector< bool > > omegaIntersection
Two dimensional vector containing boolean values if an element has an intersection of the omega diagr...
Definition: LineMesh.h:190
MatrixXd G2
Matrix with G values, used to calculate .
Definition: LineMesh.h:132
void initializeMatrices()
Initializes matrices.
Definition: LineMesh.cpp:666
void printCellAreas()
Prints cell areas.
Definition: LineMesh.cpp:950
std::vector< double > extraPoint
Vector of function values at points along the element, used for display of quadratic functions...
Definition: LineMesh.h:193
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 D
D matrix.
Definition: LineMesh.h:83
double warpingConstant
Warping constant .
Definition: LineMesh.h:50
double Sx
Weighted moment about global x-axis.
Definition: LineMesh.h:40
void calculateAxialStress()
Calculates the resulting axial stress for all nodes in the cross-section, as well as axial stress du...
Definition: LineMesh.cpp:501
double kappaX
Shear deformation factor .
Definition: LineMesh.h:51
int TAU_STV
Int corrosponding to due to .
Definition: LineMesh.h:18
double EIyp
Bending stiffness about principal y-axes.
Definition: LineMesh.h:39
void calculateStVenantStiffness(CycleDetection c)
Calculates the St.Venant stiffness .
Definition: LineMesh.cpp:251
std::vector< std::vector< bool > > sigmaZIntersection
Two dimensional vector containing boolean values if an element has an intersection or not...
Definition: LineMesh.h:250
std::vector< std::vector< std::vector< double > > > omegaIntersectionPoints
Three dimensional vector containing intersection points for .
Definition: LineMesh.h:159
double ys
y-position of hear center
Definition: LineMesh.h:43
double Ax
Area centre for mesh in x-direction.
Definition: LineMesh.h:31
void printDeltaOmega_c()
Prints delta_Omega_c values.
Definition: LineMesh.cpp:986
void calculateG2Matrix()
Calculates G2 matrix.
Definition: LineMesh.cpp:777
double Sy
Wighted moment about global y-axis.
Definition: LineMesh.h:41
MatrixXd A1
Matrix with directional values. The matrix dimensions are [nrOfNodes nrOfElements]. is +1 if the LineElement direction is away from the node, and -1 if the direction is towards the node.
Definition: LineMesh.h:129
VectorXd f_d_Vy
Vector containing input forces and moments .
Definition: LineMesh.h:116
double stVenantStiffness
St.Venant stiffness .
Definition: LineMesh.h:47
void calculateShearCenter()
Calculates shear center of the cross-section by summing the shear centers of each individual element...
Definition: LineMesh.cpp:386
void calculateSigmaZIntersection(int type, std::vector< std::vector< std::vector< double >>> *intersectionPoints, std::vector< std::vector< bool >> *intersection)
Iterates through all elements and finds intersection values if they exist.
Definition: LineMesh.cpp:452
void calculateTau(VectorXd f_d, int type)
Calculates for different applied loads.
Definition: LineMesh.cpp:833
double xs
x-position of shear center
Definition: LineMesh.h:42
void createA1Matrix()
Creates A1 matrix.
Definition: LineMesh.cpp:702
MatrixXd A2
Matrix with directional values. The matrix dimensions are [nrOfCells nrOfElements]. is +1 if the LineElement coincides with a positive counter clockwise direction of the cell, and -1 otherwise.
Definition: LineMesh.h:130
double EIy
Bending stiffness about global y-axes.
Definition: LineMesh.h:35
bool contains(std::vector< int > a, int b)
Checks wether a vector of ints contains a certain int, could be placed in a UTILS class...
Definition: LineMesh.cpp:377
std::vector< Node > nodes
List of all nodes in mesh.
Definition: LineMesh.h:136
void calculateEffectiveStress()
Calculates effective stress for cross-section.
Definition: LineMesh.cpp:932
int TAU_DUE_TO_WRP
Int corrosponding to due to .
Definition: LineMesh.h:16
void constructAVector(CycleDetection c)
Constructs area vector .
Definition: LineMesh.cpp:221
void calculateMeshProperties()
Calculates mesh properties.
Definition: LineMesh.cpp:79
int EFFECTIVE_STRESS
Int corrosponding to resulting effective stress.
Definition: LineMesh.h:25
void findMidPoints()
Finds the middle points of each element.
Definition: LineMesh.cpp:847
void calculateShearFlow()
Calculates the shear flow for all elements in the cross-section.
Definition: LineMesh.cpp:265
std::vector< LineElement * > orderedElements
List of all elements ordered in a DFS manner.
Definition: LineMesh.h:138
double It
St. Ventant torsion constant .
Definition: LineMesh.h:48
void printCoordinates()
Prints node coordinates.
Definition: LineMesh.cpp:957
void calculateAnglePrincipalAxes()
Calculates angle of the principal axes. Then forced to be less than 45 and greater than -45 ...
Definition: LineMesh.cpp:160
double warpingStiffness
Warping stiffness .
Definition: LineMesh.h:49
Contains mesh data for thin-wall analysis. Performs stress analysis on this mesh. ...
Definition: LineMesh.h:11
void printOmega()
Prints omega values.
Definition: LineMesh.cpp:966
int numberOfElementSegments
Number of element segments along an element, used for displaying quadratic functions.
Definition: LineMesh.h:63
double Bi
Bimoment to be applied to the cross section.
Definition: LineMesh.h:59
Material baseMaterial
Base material of thin-walled cross section.
Definition: LineMesh.h:65
double totalArea
The sum of all element areas.
Definition: LineMesh.h:45
MatrixXd B
Coefficiant matrix B is used to find st. venants stiffness.
Definition: LineMesh.h:67
double EA
Axial stiffness.
Definition: LineMesh.h:33
int numberOfExtraElementPoints
Number of extra points along an element, used for displaying quadratic functions. ...
Definition: LineMesh.h:64
std::vector< std::vector< std::vector< double > > > tauIntersectionPoints
Three dimensional vector containing intersection points for .
Definition: LineMesh.h:222
double Vy
Shear force in y-direction to be applied to the cross section.
Definition: LineMesh.h:58
double areaStiffness
Area stiffness EA.
Definition: LineMesh.h:46
double anglePrincipalAxesRad
Stores the angle of the principal axes in radians.
Definition: LineMesh.h:30
VectorXd f_d_Wrp
Vector containing input forces and moments .
Definition: LineMesh.h:127
void calculateWarpingStiffness()
Calculates the warping stiffness for the mesh by summing the warping stiffness found in each element...
Definition: LineMesh.cpp:422
void calculateBendingStiffness()
Calculates global bending stiffness EIx and EIy by summing the elements respective bending stiffnesse...
Definition: LineMesh.cpp:105
VectorXd f_d
Vector containing input forces and moments. Forced negative to obtain correct results. .
Definition: LineMesh.h:94
VectorXd f_d_Vx
Vector containing input forces and moments .
Definition: LineMesh.h:105
MatrixXd G1
Matrix with G values, used to calculate .
Definition: LineMesh.h:131
double EIx
Bending stiffness about global x-axes.
Definition: LineMesh.h:34