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

Contains mesh data for massive analysis. Performs stress analysis on this mesh. More...

#include <Mesh.h>

Public Member Functions

 Mesh (std::string fileName, Material mat)
 Constructor. More...
 
void solveTorsion ()
 Calculates the shear stress distribution under torsional load.
 
void solveShearX ()
 Calculates the shear stress distribution under shear force along x-axis.
 
void solveShearY ()
 Calculates the shear stress distribution under shear force along y-axis.
 
void calculateComposite ()
 Calculates the stress distribution under torsional and shear loading combined. Function to be used for further implementation of composite analysis.
 
double getAnglePrincipalAxes ()
 Returns the angle of the principal axes calculated by calculateAnglePrincipalAxes.
 
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 solveBendingMoments ()
 Calculates bending moments. More...
 
void setMaterial (Material)
 Adds the same material to all the elements in the mesh. More...
 
void applyShearFactor (MatrixXd &S, std::string shearType)
 Divides the load vector by the seccond moment of area Iy or Ix. More...
 
void constrainNodeNearCenter (SparseMatrix< double > &K, MatrixXd &R)
 Constrains the center node. More...
 
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. Then forced to be less than 45 and greater than -45 . 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 ( \(\tau\)) from axial, torsion and shear load.
 
void calculateEffectiveStress ()
 Calculates effective stress ( \(\sigma_{eff}\)) 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 It
 St. Venant torsion constant.
 
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 Mz
 Torsion moment about z-axis 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.
 
std::string shearType
 Variable used in applyShearLoad, that is dependent on the shear analysis being in x or y directions.
 
Material baseMaterial
 Material with values for Youngs modulus, Poisson's ratio and shear modulus.
 
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 tauComposite
 Stores nodal \(\sigma_z, \tau_{xz} \) and \( \tau_{yz} \) respectively from torsion and shear load in both directions.
 
MatrixXd effectiveStress
 Stores nodal \( \sigma_{eff} \) from axial, torsion and shear load in both directions.
 
MatrixXd torsion_load
 Stores values for load for the case of torsion.
 
MatrixXd torsion_displacement
 Stores values for displacement for the case of torsion. Only used for validation during testing.
 
MatrixXd shearX_load
 Stores values for load for the case of shearX.
 
MatrixXd shearX_displacement
 Stores values for displacement for the case of shearX. Only used for validation during testing.
 
MatrixXd shearY_load
 Stores values for load for the case of shearY.
 
MatrixXd shearY_displacement
 Stores values for displacement for the case of shearY. Only used for validation during testing.
 
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.
 

Static Public Attributes

static const int meshType = 1
 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 \(\boldsymbol{R}\) for the mesh. More...
 
void addLocalToGlobalSparse (SparseMatrix< double > &K, int e)
 Uses getIEG() to assign elemental values to corresponding global parameters. More...
 
void addLocalToGlobalVector (MatrixXd &R, int e)
 Uses getIEG() to assign elemental values to corresponding global load vector. More...
 
void addSubMatrix (SparseMatrix< double > &systemMatrix, int n1, int n2, double value)
 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

SparseMatrix< double > stiffness
 System stiffness matrix.
 
MatrixXd load
 system load vector
 
MatrixXd displacement
 system displacement vector
 

Detailed Description

Contains mesh data for massive analysis. Performs stress analysis on this mesh.

Constructor & Destructor Documentation

Mesh::Mesh ( 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 Mesh::addLocalToGlobalSparse ( SparseMatrix< double > &  K,
int  e 
)
private

Uses getIEG() to assign elemental values to corresponding global parameters.

Parameters
Kglobal stiffnes matrix
eelement for which local stiffness matrix is retrieved to add to global stiffness matrix
void Mesh::addLocalToGlobalVector ( MatrixXd &  R,
int  e 
)
private

Uses getIEG() to assign elemental values to corresponding global load vector.

Parameters
Rglobal load vector R
void Mesh::addSubMatrix ( SparseMatrix< double > &  systemMatrix,
int  n1,
int  n2,
double  value 
)
private

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

Parameters
systemMatrixMatrix matrix to edit
n1position i-position in matrix.
n2position j-position in matrix.
valueValue added to position in matrix.
void Mesh::applyShearFactor ( MatrixXd &  S,
std::string  shearType 
)

Divides the load vector by the seccond moment of area Iy or Ix.

Parameters
Smatrix with tau values
shearTypeindicates if "shearX" or "shearY" is the loading case
void Mesh::calculateAnglePrincipalAxes ( )

Calculates angle of the principal axes. Then forced to be less than 45 and greater than -45 .

\( t = \frac{I_x - I_{max}}{I_{xy}} \)
\( \alpha = \arctan(t)\frac{180}{\pi} \)
\( \alpha_{rad} = \alpha \times \frac{\pi}{180} \)

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

Calculates effective stress ( \(\sigma_{eff}\)) from axial, torsion and shear load.

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

void Mesh::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 Mesh::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 Mesh::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 Mesh::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 Mesh::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 Mesh::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 Mesh::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 Mesh::calculateSigmaResulting ( )

Calculates resulting axial stress ( \( \sigma_z \)) from axial, torsion, and shear load

void Mesh::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 Mesh::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 Mesh::constrainNodeNearCenter ( SparseMatrix< double > &  K,
MatrixXd &  R 
)

Constrains the center node.

Parameters
Kglobal stiffness matrix
Rglobal load vector
void Mesh::setMaterial ( Material  mat)

Adds the same material to all the elements in the mesh.

Parameters
Materialthe material that is assigned to every element
void Mesh::solveBendingMoments ( )

Calculates bending moments.

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

void Mesh::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 Mesh::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 Mesh::systemLoadVector ( MatrixXd &  R)
private

Creates the global load vector \(\boldsymbol{R}\) for the mesh.

Parameters
Rglobal load vector
void Mesh::transformCoordinates ( )

Transforms coordinates for computation purposes.

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


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