Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
MeshSTL Class Reference

Is based on Mesh but store results to be outputted in .stl format. More...

#include <MeshSTL.h>

Public Member Functions

 MeshSTL (std::string fileName, Material mat)
 Constructor. More...
 
void solveBendingMoments ()
 Calculates bending moments. More...
 
void solveTorsion ()
 Calculates the shear stress distribution under torsional load. Results are stored element wise unlike Mesh.
 
void solveShearX ()
 Calculates the shear stress distribution under shear force along x-axis. Results are stored element wise unlike Mesh.
 
void solveShearY ()
 Calculates the shear stress distribution under shear force along y-axis. Results are stored element wise unlike Mesh.
 
void applyShearFactor (MatrixXd &S, std::string)
 Divides the load vector by the seccond moment of area Iy or Ix.
 
void setMaterial (Material)
 Adds the same material to all the elements in the mesh.
 
double getAnglePrincipalAxes ()
 Returns the angle of the principal axes.
 
void constrainNodeNearCenter (SparseMatrix< double > &K, MatrixXd &R)
 Constrains the center node.
 
Node getNodeAt (int n)
 Returns the n'th node from the nodes vector.
 
ElementgetElementAt (int e)
 Returns the e'th element from the elements vector.
 
int getNumNodes ()
 Returns total number of nodes.
 
int getNumElements ()
 Returns total number of elements.
 
void SetSmoothNodalTau ()
 Sets the tau value for all the nodes equal to the avarage of the tau values from all the surrounding elements.
 
void calculateMeshProperties ()
 Calculates mesh properties. More...
 
void transformCoordinates ()
 Transforms coordinates for computation purposes. More...
 
void calculateMeshBendingStiffness ()
 Calculates bending stiffness. More...
 
void calculatePrincipalBendingStiffness ()
 Calculates the principal beding stiffnesses EI_{xp} and EI_{yp}. More...
 
void calculateMeshSecondMomentsOfArea ()
 Calculates second area moments. More...
 
void calculateAnglePrincipalAxes ()
 Calculates angle of the principal axes. More...
 
void solveEquations (SparseMatrix< double > &A, MatrixXd &b, MatrixXd &C)
 Solves the system equations. More...
 
void constrainDOF (SparseMatrix< double > &K, MatrixXd &R, int nNumber)
 Applies boundary conditions. More...
 
void calculatePrincipalSecondMomentsOfArea ()
 Calculates the principal moment of areas \(I{xp}\) and \(I{yp}\). More...
 
void calculateSigmaZfromShearLoad ()
 Calculates axial stress from applied shear load. More...
 
void calculateSigmaResulting ()
 
void calculateTauResulting ()
 Calculates resulting shear stress from axial, torsion and shear load.
 
void calculateEffectiveStress ()
 Calculates effective from axial, torsion and shear load. More...
 

Public Attributes

double Ax
 Area centre for mesh in X-direction.
 
double Ay
 Area centre for mesh in Y-direction.
 
double totalArea
 Total area of the mesh.
 
double areaStiffness
 Sum of all Ai * Ei.
 
double shearStiffness
 Sum of all Ai * Gi.
 
double EIx
 Bending stiffness about x-direction.
 
double EIy
 Bending stiffness about y-direction.
 
double EIxy
 Bending stiffness product.
 
double EImax
 Maximum bending stiffness for mesh along principal axis.
 
double EIxp
 Bending stiffness about principal x-direction.
 
double EIyp
 Bending stiffness about principal y-direction.
 
double Ix
 Second area moment for mesh in x-direction.
 
double Iy
 Second area moment for mesh in y-direction.
 
double Ixy
 Second area moment product.
 
double Imax
 Maximum second area moment for mesh along principal axis.
 
double Ixp
 Second area moment for mesh in principal x-direction.
 
double Iyp
 Second area moment for mesh in principal y-direction.
 
double GIt
 St.Venant stiffness.
 
double rateOfTwist
 Rate of twist, used for torsion analysis.
 
double Kx
 Shear factor x.
 
double Ky
 Shear factor y.
 
double torsion_xs
 Shear center in x-direction, due to torsion load.
 
double torsion_ys
 Shear center in y-direction, due to torsion load.
 
double N
 Normal force to be applied to the cross section.
 
double Mx
 Bending moment in x-direction to be applied to the cross section.
 
double My
 Bending moment in y-direction to be applied to the cross section.
 
double Vx
 Shear force in x-direction to be applied to the cross section.
 
double Vy
 Shear force in y-direction to be applied to the cross section.
 
double anglePrincipalAxes
 Stores the angle of the principal axes in degrees.
 
double anglePrincipalAxesRad
 Stores the angle of the principal axes in radians.
 
MatrixXd sigmaAxial
 Stores nodal stress from axial force.
 
MatrixXd sigmaTorsion
 Stores all nodal stresses \( \sigma_{z} \)from moment about x- and y-axis respectively.
 
MatrixXd sigmaShearXY
 Stores nodal \( \sigma_{z} \) from shear load in x- and y-direction respectively.
 
MatrixXd tauTorsion
 Stores nodal \( \tau_{xz} \), \( \tau_{yz} \) and \( \tau_{R} \) respectively from torsional load.
 
MatrixXd tauShearX
 Stores nodal \( \tau_{xz} \), \( \tau_{yz} \) and \( \tau_{R} \) respectively from shear load in x-direction.
 
MatrixXd tauShearY
 Stores nodal \( \tau_{xz} \), \( \tau_{yz} \) and \( \tau_{R} \) respectively from shear load in y-direction.
 
MatrixXd sigmaResulting
 Stores nodal \( \sigma_{resulting} \) from axial, torsion and shear load in both directions.
 
MatrixXd tauXZResulting
 Stores nodal \( \tau_{xz_{res}} \) from axial, torsion and shear load in both directions.
 
MatrixXd tauYZResulting
 Stores nodal \( \tau_{yz_{res}} \) from axial, torsion and shear load in both directions.
 
MatrixXd tauResulting
 Stores nodal \( \tau_{res} \) from axial, torsion and shear load in both directions.
 
MatrixXd effectiveStress
 Stores nodal \( \sigma_{eff} \) from axial, torsion and shear load in both directions.
 
MatrixXd torsion_displacement
 Stores values for displacement for the case of torsion.
 
MatrixXd torsion_load
 Stores values for load for the case of torsion.
 
MatrixXd shearX_load
 Stores values for load for the case of shearX.
 
MatrixXd shearX_displacement
 Stores values for displacement for the case of shearX.
 
MatrixXd shearY_load
 Stores values for load for the case of shearY.
 
MatrixXd shearY_displacement
 Stores values for displacement for the case of shearY.
 
MatrixXd printTemp1
 Used in testing to store desired value for printing.
 
MatrixXd printTemp2
 Used in testing to store desired value for printing.
 
std::vector< Element * > elements
 List of all elements in mesh.
 
std::vector< Nodenodes
 List of all nodes in mesh.
 
std::string shearType
 Variable used in applyShearLoad, that is dependent on the shear analysis being in x or y direction.
 

Static Public Attributes

static const int meshType = 0
 Boolean to separate mesh and meshSTL.
 

Private Member Functions

void systemEquations (SparseMatrix< double > &K, MatrixXd &R)
 Computes the global stiffness matrix for the mesh. More...
 
void systemLoadVector (MatrixXd &R)
 Creates the global load vector for the mesh.
 
void addLocalToGlobalSparse (SparseMatrix< double > &mat, int e)
 Uses getIEG() to assign elemental values to corresponding global parameters.
 
void addLocalToGlobalVector (MatrixXd &mat, int e)
 Uses getIEG() to assign elemental values to corresponding global parameters.
 
void addSubMatrix (SparseMatrix< double > &, int, int, double)
 Increases value at a position in matrix by a given value. More...
 
int getNodeNearCenter ()
 Returns a node near the area center.
 
void flush ()
 Sets all the system variables to zero.
 
void findSurroundingElementsForNodes ()
 Finds the number of elements surrounding each node.
 
void calculateShearDeformationFactorX ()
 Calculates the shear deformation factor contribution for the cross-section, in x-direction. More...
 
void calculateShearDeformationFactorY ()
 Gets the shear deformation factor contribution for the cross section, in y-direction. More...
 

Private Attributes

Material material
 Material with values for Youngs modulus, Poisson's ratio and shear modulus.
 
SparseMatrix< double > stiffness
 System stiffness matrix.
 
MatrixXd load
 system load vector
 
MatrixXd displacement
 system displacement vector
 

Detailed Description

Is based on Mesh but store results to be outputted in .stl format.

Documentation is not maintained as properly as Mesh.
If unclear, seek the documentation for mesh. Only torsion and shear loading have been implemented to output results element wise.
Purely for demonstrating and validating the implementation of different elements.

Constructor & Destructor Documentation

MeshSTL::MeshSTL ( std::string  fileName,
Material  mat 
)

Constructor.

Computes the area, areacentre and the stiffness matrix

Parameters
elementsList of all elements
nodesList of all nodes

Member Function Documentation

void MeshSTL::addSubMatrix ( SparseMatrix< double > &  systemMatrix,
int  n1,
int  n2,
double  value 
)
private

Increases value at a position in matrix by a given value.

Parameters
Matrixmatrix to edit
positioni-position in matrix.
positionj-position in matrix.
valueValue added to position in matrix.
void MeshSTL::calculateAnglePrincipalAxes ( )

Calculates angle of the principal axes.

\( t = \frac{-2I_{xy}}{I_x - I_y} \)
\( \alpha = \frac{1}{2}\arctan(t)\frac{180}{\pi} \)

Returns
Angle of one inertial axis.
void MeshSTL::calculateEffectiveStress ( )

Calculates effective from axial, torsion and shear load.

\( \sigma_{eff} = \sqrt{\sigma_{res}^2 + 3(\tau_{xz}^2 + \tau_{yz}^2)}\)

void MeshSTL::calculateMeshBendingStiffness ( )

Calculates bending stiffness.

Loops through all elements calculating the distance between mesh- and element area centres, and calculates the bendingStiffnesses for the mesh's x-, y- and xy-axis.

void MeshSTL::calculateMeshProperties ( )

Calculates mesh properties.

The function is run by constructor. It runs through all elements calculating element areas and element centres for each element.
It also calculates total area of mesh, and area centre of the mesh using
\( A_x = \sum{( \frac{dx_e*a_e}{A}) } \) and \( A_y = \sum{ (\frac{dy_e*a_e}{A}) } \)

void MeshSTL::calculateMeshSecondMomentsOfArea ( )

Calculates second area moments.

\( I_x = \frac{EI_x}{E_b} \)
\( I_y = \frac{EI_y}{E_b} \)
\( I_{xy} = \frac{EI_{xy}}{E_b} \)

void MeshSTL::calculatePrincipalBendingStiffness ( )

Calculates the principal beding stiffnesses EI_{xp} and EI_{yp}.

\( EI_{ xp } = \frac{ 1 }{2}*(EI_x + EI_y) + \frac{1}{2}(EI_x - EI_y)* cos(2 \theta) - EI_{ xy }*sin(2 \theta); \)
\( EI_{ yp } = \frac{ 1 }{2}(EI_x + EI_y) - \frac{ 1 }{2}(EI_x - EI_y)* cos(2 \theta) + EI_{ xy }*sin(2 \theta); \)
with \( \theta \) as the angle calculated by calculateAnglePrincipalAxes()

void MeshSTL::calculatePrincipalSecondMomentsOfArea ( )

Calculates the principal moment of areas \(I{xp}\) and \(I{yp}\).

\( I_{ xp } = \frac{EI_{xp}}{E_b} \)
\( I_{ yp } = \frac{EI_{yp}}{E_b} \)

void MeshSTL::calculateShearDeformationFactorX ( )
private

Calculates the shear deformation factor contribution for the cross-section, in x-direction.

\( \kappa_x^e = \frac{AG}{V_x EI_y}\left( E_e \textbf{x}^T \textbf{a} \textbf{v}_x \right) - \frac{\nu_e}{4(1+\nu)} \frac{E_e A_e}{EA} \frac{(EI_y - EI_x)}{EI_y} \)

Returns
shear deformation factor contribution in x-direction from element
void MeshSTL::calculateShearDeformationFactorY ( )
private

Gets the shear deformation factor contribution for the cross section, in y-direction.

\( \kappa_y^e = \frac{AG}{V_y EI_x}\left( E_e \textbf{y}^T \textbf{a} \textbf{v}_y \right) - \frac{\nu_e}{4(1+\nu)} \frac{E_e A_e}{EA} \frac{(EI_x - EI_y)}{EI_x} \)

Returns
shear deformation factor contribution in y-direction from element
void MeshSTL::calculateSigmaResulting ( )

Calculates resulting axial stress from axial, torsion and shear load

void MeshSTL::calculateSigmaZfromShearLoad ( )

Calculates axial stress from applied shear load.

\( \sigma_z = E (L-z)(C_x x + C_y y)\)
with \(C_x = \frac{V_x}{EI_{yp}}\) and \(C_y = \frac{V_y}{EI_{xp}} \)
where (L-z) is equal to 1

void MeshSTL::constrainDOF ( SparseMatrix< double > &  K,
MatrixXd &  R,
int  nNumber 
)

Applies boundary conditions.

puts the stiffness relation equations on the form \( \textbf{Ab} = \textbf{C} \Rightarrow \begin{bmatrix} & & & & \vdots \\ & & & & 0 \\ & & & & 0 \\ \cdots & 0 & 0 & 0 & 1\\ \end{bmatrix} \boldsymbol{b} = \begin{bmatrix} \vdots \\ - \\ - \\ 1\\ \end{bmatrix} \)

Parameters
Kis the global stiffness matrix
Ris the load vector
intis the node to be constrained
void MeshSTL::solveBendingMoments ( )

Calculates bending moments.

\( \sigma = \frac{y }{ I_x} \)
\( \sigma = {-x}{I_y} \)

void MeshSTL::solveEquations ( SparseMatrix< double > &  A,
MatrixXd &  b,
MatrixXd &  C 
)

Solves the system equations.

\( Kr = R \),
where K is the stiffness matrix, and r and R are vectors with displacements and loads in each node.

Parameters
Ais the stiffness matrix
bis the displacement
Cis the load vector
void MeshSTL::systemEquations ( SparseMatrix< double > &  K,
MatrixXd &  R 
)
private

Computes the global stiffness matrix for the mesh.

Stiffness matrix for each element is found by
\( k_e = t_e A_e B^T G B \),
where
\( G_v = \frac{0.5E}{1+v} \)
\( G = \left| \begin{array}{ccc} G_v & 0 \\ 0 & G_v \end{array} \right| \)
\( B = \left| \begin{array}{ccc} y_2-y_3 & y_3-y_1 & y_1-y_2 \\ x_3-x_2 & x_1-x_3 & x_2-x_1 \end{array} \right| \)
B matrix relates the strains to displacements for a triangle element.

Parameters
Kis the stiffness matrix
Ris the load vector
void MeshSTL::transformCoordinates ( )

Transforms coordinates for computation purposes.

\( x' = x-A_xcos(\alpha) + y-A_ysin(\alpha) \)
\( x' = y-A_ycos(\alpha) - x-A_xsin(\alpha) \)


The documentation for this class was generated from the following files: