My Project
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_X_DUE_TO_N = 0;
23  int SIGMA_X_DUE_TO_B = 3;
25  int EFFECTIVE_STRESS = 5;
26 
27  int OMEGA_DIAGRAM = 0;
28 
31  double Ax, Ay;
32  double EA;
33  double EIx, EIy, EIxy, EImax;
34  double EIxp, EIyp;
35  double Sx, Sy;
36  double xs;
37  double ys;
38  double C;
39  double totalArea;
40  double areaStiffness;
43  double kappaX;
44  double kappaY;
45  double baseE = 210000;
46  double baseG = 80770;
47 
48  double N;
49  double Mx;
50  double My;
51  double Vx;
52  double Vy;
53  double Bi;
54  double T_stv;
55  double T_wrp;
59 
60  MatrixXd B;
61  VectorXd a;
62  VectorXd p;
63 
76  MatrixXd D;
77 
87  VectorXd f_d;
88 
98  VectorXd f_d_Vx;
99 
109  VectorXd f_d_Vy;
110 
120  VectorXd f_d_Wrp;
121 
122  MatrixXd A1;
123  MatrixXd A2;
124  MatrixXd G1;
125  MatrixXd G2;
126  VectorXd q0;
127 
128  std::vector<LineElement*> elements;
129  std::vector<Node> nodes;
130  std::vector<std::vector<LineElement*>> cycles;
131  std::vector<LineElement*> orderedElements;
132  std::vector<std::vector<double>> midPoints;
133 
152  std::vector<std::vector<std::vector<double>>> omegaIntersectionPoints;
153 
154 
181  std::vector<std::vector<std::vector<double>>> sigmaXIntersectionPoints;
182 
183  std::vector<std::vector<bool>> omegaIntersection;
184 
185 
186  std::vector<double> extraPoint;
187  std::vector<double> tauIntersect;
188 
215  std::vector<std::vector<std::vector<double>>> tauIntersectionPoints;
216 
217 
243  std::vector<std::vector<bool>> sigmaXIntersection;
244 
245  LineMesh(std::string fileName);
246  LineMesh();
247 
254  void transformCoordinates();
255 
257 
258  void calculateAreaStiffness();
259 
263  void printCoordinates();
264 
275 
283 
293 
297  void printCellAreas();
301  void printCells();
302 
303 
313  void constructBMatrix();
314 
323 
331  void solveSystemEquation();
332 
341 
345  void calculateShearFlow();
346 
354  void calculateOmega_c();
355 
364  std::vector<LineElement*> findCommonElements(std::vector<LineElement*> a, std::vector<LineElement*> b);
365 
371  std::vector<LineElement*> DFS();
372 
381  bool contains(std::vector<int> a, int b);
382 
386  void printOmega();
387 
388  void printOmega_c();
389 
393  void printDeltaOmega_c();
394 
398  void calculateShearCenter();
399 
403  void calculateOmega();
404 
409 
414 
422  void LineMesh::calculateSigmaXIntersection(int type, std::vector<std::vector<std::vector<double>>> *intersectionPoints, std::vector<std::vector<bool>> *intersection);
423 
431  void LineMesh::calculateOmegaIntersection(int type, std::vector<std::vector<std::vector<double>>> *intersectionPoints, std::vector<std::vector<bool>> *intersection);
432 
433 
437  void calculateEk();
438 
448  void calculateAxialStress();
449 
457 
464  void addElementPoints(VectorXd f_d, int type);
465 
472  void findElementIntersections(VectorXd f_d, int type);
473 
480  void calculateNodalTau(VectorXd f_d, int type);
481 
492  void initiateCVectors();
493 
499  void createA1Matrix();
500 
506  void createA2Matrix();
507 
519  void calculateG1Matrix();
520 
531  void calculateG2Matrix();
532 
556  void calculateQ0(VectorXd f_d, int type);
557 
564  void printEigenMatrix(MatrixXd A, std::string s);
565 
600  void initializeMatrices();
601 
612  double calculateQs(double s, LineElement* element, VectorXd f_d, int type);
613 
620  void calculateTau(VectorXd f_d, int type);
621 
625  void calculateTauSTV();
626 
627  void findMidPoints();
628 
629  void findElementsNextToNode();
630 
631  void findIntersections();
632 
643  void calculateKappaX();
644 
655  void calculateKappaY();
656 
657 
662 
663 
672  double calculateVonMisesStress(LineElement* element, int j);
673 
678 
679  ~LineMesh();
680 };
681 
int SIGMA_X_DUE_TO_B
Int corrosponding to sigma_x due to B.
Definition: LineMesh.h:23
int TAU_DUE_TO_VY
Int corrosponding to tau due to Vy.
Definition: LineMesh.h:15
void addElementPoints(VectorXd f_d, int type)
Adds points along the element used for visualization of quadratic functions.
Definition: LineMesh.cpp:664
Performs cycle detection on the cross section.
Definition: CycleDetection.h:7
void transformCoordinates()
Transforms coordinates for computation purposes.
Definition: LineMesh.cpp:150
void calculateOmegaIntersection()
Iterates through all elements and finds an omega intersection point if it exists. ...
Definition: LineMesh.cpp:514
void calculateKappaX()
Calculates shear deformation factor x.
Definition: LineMesh.cpp:1071
void printCells()
Prints each cell, and it&#39;s elements.
Definition: LineMesh.cpp:216
double T_wrp
Warping torsion to be applied to the cross section.
Definition: LineMesh.h:55
int SIGMA_X_RESULTING
Int corrosponding to resulting sigma_x.
Definition: LineMesh.h:24
void findElementIntersections(VectorXd f_d, int type)
Finds the element intersection points for quadratic functions along the element.
Definition: LineMesh.cpp:701
std::vector< std::vector< LineElement * > > cycles
2d vector containing all cycles in the cross-section
Definition: LineMesh.h:130
void createA2Matrix()
Creates A2 matrix.
Definition: LineMesh.cpp:815
int OMEGA_DIAGRAM
Int corrosponding to omega diagram.
Definition: LineMesh.h:27
double EImax
Bending stiffness about global x- and y-axes.
Definition: LineMesh.h:33
double kappaY
Shear deformation factor y.
Definition: LineMesh.h:44
void findElementsNextToNode()
Finds the number of elements that are neighboring each node.
Definition: LineMesh.cpp:1047
double N
Normal force to be applied to the cross section.
Definition: LineMesh.h:48
void initiateCVectors()
Initializes the C vectors for each element.
Definition: LineMesh.cpp:655
void calculateKappaY()
Calculates shear deformation factor y.
Definition: LineMesh.cpp:1111
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:395
void printOmega_c()
prints omega_c values
Definition: LineMesh.cpp:635
int TAU_DUE_TO_VX
Int corrosponding to tau due to Vx.
Definition: LineMesh.h:14
void calculatePrincipalMomentOfAreas()
Calculates the principal moment of areas EIxp and EIyp.
Definition: LineMesh.cpp:141
int SIGMA_X_DUE_TO_MY
Int corrosponding to sigma_x due to My.
Definition: LineMesh.h:22
double Ay
Area centre for mesh in X- and Y-direction.
Definition: LineMesh.h:31
void calculateAreaStiffness()
Calculates the area stiffness.
Definition: LineMesh.cpp:99
int numberOfNodes
Number of nodes in the cross-section.
Definition: LineMesh.h:56
double C
Shear center constant.
Definition: LineMesh.h:38
void printEigenMatrix(MatrixXd A, std::string s)
prints out a matrix on Eigen format
Definition: LineMesh.cpp:943
void calculateEk()
Calculates average E value of all elements surrounding a node.
Definition: LineMesh.cpp:554
void solveSystemEquation()
Solves the system of equations.
Definition: LineMesh.cpp:270
void calculateQ0(VectorXd f_d, int type)
Calculates q0.
Definition: LineMesh.cpp:905
std::vector< double > tauIntersect
Vector containing intersectionpoints of tau.
Definition: LineMesh.h:187
VectorXd p
Modified shear flows around each cell.
Definition: LineMesh.h:62
void calculatePureStvTorsionStress()
Calculates the pure St.Venants torsion stress.
Definition: LineMesh.cpp:566
std::vector< LineElement * > elements
List of all elements in mesh.
Definition: LineMesh.h:128
double T_stv
St.Venant torsion to be applied to the cross section.
Definition: LineMesh.h:54
void calculateOmega_c()
Calculates for all the elements.
Definition: LineMesh.cpp:327
void findIntersections()
Finds diagram intersections for Sigma_x as well as omega.
Definition: LineMesh.cpp:1057
Contains element data and relevant functions.
Definition: LineElement.h:6
std::vector< std::vector< double > > midPoints
Vector containing the middle points of each elements.
Definition: LineMesh.h:132
double My
Bending moment in y-direction to be applied to the cross section.
Definition: LineMesh.h:50
void calculateG1Matrix()
Calculates G1 matrix.
Definition: LineMesh.cpp:846
double Vx
Shear force in x-direction to be applied to the cross section.
Definition: LineMesh.h:51
void calculateSigmaXIntersection(int type, std::vector< std::vector< std::vector< double >>> *intersectionPoints, std::vector< std::vector< bool >> *intersection)
Iterates through all elements and finds /f$ /f$ intersection values if they exist.
Definition: LineMesh.cpp:527
VectorXd a
A vector of doubles representing the areas of the cells found in the elements.
Definition: LineMesh.h:61
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:1007
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:414
void calculateResultingSigmaExtra()
Calculates to resulting sigma for all extra points in the element.
Definition: LineMesh.cpp:1148
void constructBMatrix()
Constructs coefficiant matrix .
Definition: LineMesh.cpp:227
int TAU_RESULTING
Int corrosponding to tau 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:49
void calculateOmega()
Calculates omega for each node in the cross-section.
Definition: LineMesh.cpp:490
double calculateVonMisesStress(LineElement *element, int j)
Calculates von mises stress.
Definition: LineMesh.cpp:1166
void calculateNodalTau(VectorXd f_d, int type)
Calculates tau values for the nodes.
Definition: LineMesh.cpp:773
void calculateTauSTV()
Calculates tau for applied T_stv.
Definition: LineMesh.cpp:1032
VectorXd q0
Vector of shear flow in the middle of each element.
Definition: LineMesh.h:126
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:183
MatrixXd G2
Matrix with G values, used to calculate q_0.
Definition: LineMesh.h:125
void initializeMatrices()
Initializes matrices.
Definition: LineMesh.cpp:954
void printCellAreas()
Prints cell areas.
Definition: LineMesh.cpp:609
std::vector< double > extraPoint
Vector of function values at points along the element, used for display of quadratic functions...
Definition: LineMesh.h:186
MatrixXd D
D matrix.
Definition: LineMesh.h:76
void calculateAxialStress()
Calculates the resulting axial stress for all nodes in the cross-section, as well as axial stress du...
Definition: LineMesh.cpp:583
double kappaX
Shear deformation factor x.
Definition: LineMesh.h:43
int TAU_STV
Int corrosponding to tau due to T_stv.
Definition: LineMesh.h:18
double baseG
Shear modulus of base material.
Definition: LineMesh.h:46
double EIyp
Bending stiffness about principal x- and y-axes.
Definition: LineMesh.h:34
void calculateStVenantStiffness(CycleDetection c)
Calculates the St.Venant stiffness .
Definition: LineMesh.cpp:298
std::vector< std::vector< std::vector< double > > > omegaIntersectionPoints
Three dimensional vector containing intersection points for .
Definition: LineMesh.h:152
double ys
y-position of hear center
Definition: LineMesh.h:37
void printDeltaOmega_c()
Prints delta_Omega_c values.
Definition: LineMesh.cpp:645
double baseE
Young&#39;s modulus of base material.
Definition: LineMesh.h:45
void calculateG2Matrix()
Calculates G2 matrix.
Definition: LineMesh.cpp:883
double Sy
TODO.
Definition: LineMesh.h:35
MatrixXd A1
Matrix with directional values. The matrix dimensions are [nrOfNodes x nrOfElements]. is +1 if the LineElement direction is away from the node, and -1 if the direction is towards the node.
Definition: LineMesh.h:122
VectorXd f_d_Vy
Vector containing input forces and moments .
Definition: LineMesh.h:109
double stVenantStiffness
St.Venant stiffness GI_t.
Definition: LineMesh.h:41
void calculateShearCenter()
Calculates shear center of the cross-section by summing the shear centers of each individual element...
Definition: LineMesh.cpp:456
void calculateTau(VectorXd f_d, int type)
Calculates tau for different applied loads.
Definition: LineMesh.cpp:1025
double xs
x-position of shear center
Definition: LineMesh.h:36
void createA1Matrix()
Creates A1 matrix.
Definition: LineMesh.cpp:798
MatrixXd A2
Matrix with directional values. The matrix dimensions are [nrOfCells x nrOfElements]. is +1 if the LineElement coincides with a positive counter clockwise direction of the cell, and -1 otherwise.
Definition: LineMesh.h:123
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:446
std::vector< std::vector< std::vector< double > > > sigmaXIntersectionPoints
Three dimensional vector containing intersection points for .
Definition: LineMesh.h:181
std::vector< Node > nodes
List of all nodes in mesh.
Definition: LineMesh.h:129
void calculateEffectiveStress()
Calculates effective stress for cross-section.
Definition: LineMesh.cpp:1174
int TAU_DUE_TO_WRP
Int corrosponding to tau due to T_wrp.
Definition: LineMesh.h:16
void constructAVector(CycleDetection c)
Constructs area vector a.
Definition: LineMesh.cpp:261
void calculateMeshProperties()
Calculates mesh properties.
Definition: LineMesh.cpp:90
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:1039
void calculateShearFlow()
Calculates the shear flow for all elements in the cross-section.
Definition: LineMesh.cpp:319
std::vector< LineElement * > orderedElements
List of all elements ordered in a DFS manner.
Definition: LineMesh.h:131
void printCoordinates()
Prints node coordinates.
Definition: LineMesh.cpp:616
void calculateAnglePrincipalAxes()
Calculates angle of the principal axes.
Definition: LineMesh.cpp:184
double warpingStiffness
Warping stiffness EI_.
Definition: LineMesh.h:42
Contains mesh data and has function to calculate and retrieve mesh properties.
Definition: LineMesh.h:11
void printOmega()
Prints omega values.
Definition: LineMesh.cpp:625
int numberOfElementSegments
Number of element segments along an element, used for displaying quadratic functions.
Definition: LineMesh.h:57
int SIGMA_X_DUE_TO_N
Int corrosponding to sigma_x due to N.
Definition: LineMesh.h:20
double Bi
Bimoment to be applied to the cross section.
Definition: LineMesh.h:53
double totalArea
The sum of all element areas.
Definition: LineMesh.h:39
MatrixXd B
Coefficiant matrix B is used to find st. venants stiffness.
Definition: LineMesh.h:60
double EA
Axial stiffness.
Definition: LineMesh.h:32
int numberOfExtraElementPoints
Number of extra points along an element, used for displaying quadratic functions. ...
Definition: LineMesh.h:58
std::vector< std::vector< std::vector< double > > > tauIntersectionPoints
Three dimensional vector containing intersection points for .
Definition: LineMesh.h:215
double Vy
Shear force in y-direction to be applied to the cross section.
Definition: LineMesh.h:52
double areaStiffness
Area stiffness EA.
Definition: LineMesh.h:40
int SIGMA_X_DUE_TO_MX
Int corrosponding to sigma_x due to Mx.
Definition: LineMesh.h:21
double anglePrincipalAxesRad
Stores the angle of the principal axes in radians.
Definition: LineMesh.h:30
std::vector< std::vector< bool > > sigmaXIntersection
Two dimensional vector containing boolean values if an element has an intersection or not...
Definition: LineMesh.h:243
VectorXd f_d_Wrp
Vector containing input forces and moments .
Definition: LineMesh.h:120
void calculateWarpingStiffness()
Calculates the warping stiffness (EI_w) for the mesh by summing the warping stiffness found in each e...
Definition: LineMesh.cpp:498
void calculateBendingStiffness()
Calculates seccond area moments.
Definition: LineMesh.cpp:116
VectorXd f_d
Vector containing input forces and moments .
Definition: LineMesh.h:87
VectorXd f_d_Vx
Vector containing input forces and moments .
Definition: LineMesh.h:98
MatrixXd G1
Matrix with G values, used to calculate q_0.
Definition: LineMesh.h:124