Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SurgSim::Physics::Fem3DElementTetrahedron Class Reference

Class for Fem Element 3D based on a tetrahedron volume discretization. More...

#include <SurgSim/Physics/Fem3DElementTetrahedron.h>

Inheritance diagram for SurgSim::Physics::Fem3DElementTetrahedron:
SurgSim::Physics::FemElement SurgSim::Physics::Fem3DElementCorotationalTetrahedron

Public Member Functions

 Fem3DElementTetrahedron (std::array< size_t, 4 > nodeIds)
 Constructor. More...
 
virtual void initialize (const SurgSim::Math::OdeState &state) override
 Initialize the FemElement once everything has been set. More...
 
virtual double getVolume (const SurgSim::Math::OdeState &state) const override
 Get the element volume based on the input state. More...
 
virtual void addForce (const SurgSim::Math::OdeState &state, SurgSim::Math::Vector *F, double scale=1.0) override
 Adds the element force (computed for a given state) to a complete system force vector F (assembly) More...
 
virtual void addMass (const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *M, double scale=1.0) override
 Adds the element mass matrix M (computed for a given state) to a complete system mass matrix M (assembly) More...
 
virtual void addDamping (const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *D, double scale=1.0) override
 Adds the element damping matrix D (= -df/dv) (comuted for a given state) to a complete system damping matrix D (assembly) More...
 
virtual void addStiffness (const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *K, double scale=1.0) override
 Adds the element stiffness matrix K (= -df/dx) (computed for a given state) to a complete system stiffness matrix K (assembly) More...
 
virtual void addFMDK (const SurgSim::Math::OdeState &state, SurgSim::Math::Vector *F, SurgSim::Math::Matrix *M, SurgSim::Math::Matrix *D, SurgSim::Math::Matrix *K) override
 Adds the element force vector, mass, stiffness and damping matrices (computed for a given state) into a complete system data structure F, M, D, K (assembly) More...
 
virtual void addMatVec (const SurgSim::Math::OdeState &state, double alphaM, double alphaD, double alphaK, const SurgSim::Math::Vector &x, SurgSim::Math::Vector *F) override
 Adds the element matrix-vector contribution F += (alphaM.M + alphaD.D + alphaK.K).x (computed for a given state) into a complete system data structure F (assembly) More...
 
virtual SurgSim::Math::Vector computeCartesianCoordinate (const SurgSim::Math::OdeState &state, const SurgSim::Math::Vector &naturalCoordinate) const override
 Computes a given natural coordinate in cartesian coordinates. More...
 
virtual SurgSim::Math::Vector computeNaturalCoordinate (const SurgSim::Math::OdeState &state, const SurgSim::Math::Vector &cartesianCoordinate) const override
 Computes a natural coordinate given a global coordinate. More...
 
- Public Member Functions inherited from SurgSim::Physics::FemElement
 FemElement ()
 Constructor. More...
 
virtual ~FemElement ()
 Virtual destructor. More...
 
size_t getNumDofPerNode () const
 Gets the number of degree of freedom per node. More...
 
size_t getNumNodes () const
 Gets the number of nodes connected by this element. More...
 
size_t getNodeId (size_t elementNodeId) const
 Gets the elementNodeId-th node id. More...
 
const std::vector< size_t > & getNodeIds () const
 Gets the node ids for this element. More...
 
void setYoungModulus (double E)
 Sets the Young modulus (in N.m-2) More...
 
double getYoungModulus () const
 Gets the Young modulus (in N.m-2) More...
 
void setPoissonRatio (double nu)
 Sets the Poisson ratio (unitless) More...
 
double getPoissonRatio () const
 Gets the Poisson ratio (unitless) More...
 
void setMassDensity (double rho)
 Sets the mass density (in Kg.m-3) More...
 
double getMassDensity () const
 Gets the mass density (in Kg.m-3) More...
 
double getMass (const SurgSim::Math::OdeState &state) const
 Gets the element mass based on the input state (in Kg) More...
 
virtual bool update (const SurgSim::Math::OdeState &state)
 Update the element based on a given state. More...
 
bool isValidCoordinate (const SurgSim::Math::Vector &naturalCoordinate) const
 Determines whether a given natural coordinate is valid. More...
 

Protected Member Functions

void computeShapeFunctions (const SurgSim::Math::OdeState &state, double *volume, std::array< double, 4 > *ai, std::array< double, 4 > *bi, std::array< double, 4 > *ci, std::array< double, 4 > *di) const
 Computes the tetrahedron shape functions. More...
 
void computeStiffness (const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 12, 12 > *k)
 Computes the tetrahedron stiffness matrix. More...
 
void computeMass (const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 12, 12 > *m)
 Computes the tetrahedron mass matrix. More...
 
void addForce (const SurgSim::Math::OdeState &state, const Eigen::Matrix< double, 12, 12 > &k, SurgSim::Math::Vector *F, double scale=1.0)
 Adds the element force (computed for a given state) to a complete system force vector F (assembly) This method relies on a given stiffness matrix and does not evaluate it from the state. More...
 
- Protected Member Functions inherited from SurgSim::Physics::FemElement
void setNumDofPerNode (size_t numDofPerNode)
 Sets the number of degrees of freedom per node. More...
 

Protected Attributes

double m_restVolume
 Shape functions: Tetrahedron rest volume. More...
 
std::array< double, 4 > m_ai
 Shape functions coefficients Ni(x,y,z) = 1/6V ( ai + x.bi + y.ci + z.di ) More...
 
std::array< double, 4 > m_bi
 
std::array< double, 4 > m_ci
 
std::array< double, 4 > m_di
 
Eigen::Matrix< double, 12, 1 > m_x0
 The tetrahedon rest state. More...
 
Eigen::Matrix< double, 6, 6 > m_Em
 Elasticity material matrix (contains the elastic properties of the material) More...
 
Eigen::Matrix< double, 6, 12 > m_strain
 Strain matrix. More...
 
Eigen::Matrix< double, 6, 12 > m_stress
 Stress matrix. More...
 
Eigen::Matrix< double, 12, 12 > m_M
 Mass matrix. More...
 
Eigen::Matrix< double, 12, 12 > m_K
 Stiffness matrix. More...
 
- Protected Attributes inherited from SurgSim::Physics::FemElement
size_t m_numDofPerNode
 Number of degree of freedom per node for this element. More...
 
std::vector< size_t > m_nodeIds
 Node ids connected by this element. More...
 
double m_rho
 Mass density (in Kg.m-3) More...
 
double m_E
 Young modulus (in N.m-2) More...
 
double m_nu
 Poisson ratio (unitless) More...
 

Detailed Description

Class for Fem Element 3D based on a tetrahedron volume discretization.

Note
The inertia property (mass) of the tetrahedron is derived from
"Theory of Matrix Structural Analysis" from J.S. Przemieniecki
The force and stiffness matrix of the tetrahedron is derived from
http://www.colorado.edu/engineering/CAS/courses.d/AFEM.d/AFEM.Ch09.d/AFEM.Ch09.pdf
The deformation is based on the linear elasticity theory and not on the visco-elasticity theory.
Therefore the element does not have any damping component.

Constructor & Destructor Documentation

SurgSim::Physics::Fem3DElementTetrahedron::Fem3DElementTetrahedron ( std::array< size_t, 4 >  nodeIds)
explicit

Constructor.

Parameters
nodeIdsAn array of 4 node (A, B, C, D) ids defining this tetrahedron element in a overall mesh
Note
It is required that the triangle ABC is CCW looking from D (i.e. dot(cross(AB, AC), AD) > 0)
This is required from the signed volume calculation method getVolume()
A warning will be logged when the initialize function is called if this condition is not met, but the
simulation will keep running. Behavior will be undefined because of possible negative volume terms.

Member Function Documentation

void SurgSim::Physics::Fem3DElementTetrahedron::addDamping ( const SurgSim::Math::OdeState state,
SurgSim::Math::Matrix D,
double  scale = 1.0 
)
overridevirtual

Adds the element damping matrix D (= -df/dv) (comuted for a given state) to a complete system damping matrix D (assembly)

Parameters
stateThe state to compute the damping matrix with
[in,out]DThe complete system damping matrix to add the element damping matrix into
scaleA factor to scale the added damping matrix with
Note
The element damping matrix is square of size getNumDofPerNode() x getNumNodes()
This method supposes that the incoming state contains information with the same number of
dof per node as getNumDofPerNode()
Fem3DElementTetrahedron uses linear elasticity (not visco-elasticity), so it does not give any damping.

Implements SurgSim::Physics::FemElement.

void SurgSim::Physics::Fem3DElementTetrahedron::addFMDK ( const SurgSim::Math::OdeState state,
SurgSim::Math::Vector F,
SurgSim::Math::Matrix M,
SurgSim::Math::Matrix D,
SurgSim::Math::Matrix K 
)
overridevirtual

Adds the element force vector, mass, stiffness and damping matrices (computed for a given state) into a complete system data structure F, M, D, K (assembly)

Parameters
stateThe state to compute everything with
[in,out]FThe complete system force vector to add the element force into
[in,out]MThe complete system mass matrix to add the element mass matrix into
[in,out]DThe complete system damping matrix to add the element damping matrix into
[in,out]KThe complete system stiffness matrix to add the element stiffness matrix into
Note
This method supposes that the incoming state contains information with the same number of dof
per node as getNumDofPerNode()

Implements SurgSim::Physics::FemElement.

void SurgSim::Physics::Fem3DElementTetrahedron::addForce ( const SurgSim::Math::OdeState state,
SurgSim::Math::Vector F,
double  scale = 1.0 
)
overridevirtual

Adds the element force (computed for a given state) to a complete system force vector F (assembly)

Parameters
stateThe state to compute the force with
[in,out]FThe complete system force vector to add the element force into
scaleA factor to scale the added force with
Note
The element force is of size (getNumDofPerNode() x getNumNodes())
This method supposes that the incoming state contains information with the same number of dof
per node as getNumDofPerNode()

Implements SurgSim::Physics::FemElement.

Reimplemented in SurgSim::Physics::Fem3DElementCorotationalTetrahedron.

void SurgSim::Physics::Fem3DElementTetrahedron::addForce ( const SurgSim::Math::OdeState state,
const Eigen::Matrix< double, 12, 12 > &  k,
SurgSim::Math::Vector F,
double  scale = 1.0 
)
protected

Adds the element force (computed for a given state) to a complete system force vector F (assembly) This method relies on a given stiffness matrix and does not evaluate it from the state.

Parameters
stateThe state to compute the force with
kThe given element stiffness matrix
[in,out]FThe complete system force vector to add the element force into
scaleA factor to scale the added force with
Note
The element force is of size (getNumDofPerNode() x getNumNodes())
This method supposes that the incoming state contains information with the same number of dof
per node as getNumDofPerNode()
void SurgSim::Physics::Fem3DElementTetrahedron::addMass ( const SurgSim::Math::OdeState state,
SurgSim::Math::Matrix M,
double  scale = 1.0 
)
overridevirtual

Adds the element mass matrix M (computed for a given state) to a complete system mass matrix M (assembly)

Parameters
stateThe state to compute the mass matrix with
[in,out]MThe complete system mass matrix to add the element mass-matrix into
scaleA factor to scale the added mass matrix with
Note
The element mass matrix is square of size getNumDofPerNode() x getNumNodes()
This method supposes that the incoming state contains information with the same number of
dof per node as getNumDofPerNode()

Implements SurgSim::Physics::FemElement.

void SurgSim::Physics::Fem3DElementTetrahedron::addMatVec ( const SurgSim::Math::OdeState state,
double  alphaM,
double  alphaD,
double  alphaK,
const SurgSim::Math::Vector x,
SurgSim::Math::Vector F 
)
overridevirtual

Adds the element matrix-vector contribution F += (alphaM.M + alphaD.D + alphaK.K).x (computed for a given state) into a complete system data structure F (assembly)

Parameters
stateThe state to compute everything with
alphaMThe scaling factor for the mass contribution
alphaDThe scaling factor for the damping contribution
alphaKThe scaling factor for the stiffness contribution
xA complete system vector to use as the vector in the matrix-vector multiplication
[in,out]FThe complete system force vector to add the element matrix-vector contribution into
Note
This method supposes that the incoming state contains information with the same number of dof
per node as getNumDofPerNode()

Implements SurgSim::Physics::FemElement.

Reimplemented in SurgSim::Physics::Fem3DElementCorotationalTetrahedron.

void SurgSim::Physics::Fem3DElementTetrahedron::addStiffness ( const SurgSim::Math::OdeState state,
SurgSim::Math::Matrix K,
double  scale = 1.0 
)
overridevirtual

Adds the element stiffness matrix K (= -df/dx) (computed for a given state) to a complete system stiffness matrix K (assembly)

Parameters
stateThe state to compute the stiffness matrix with
[in,out]KThe complete system stiffness matrix to add the element stiffness matrix into
scaleA factor to scale the added stiffness matrix with
Note
The element stiffness matrix is square of size getNumDofPerNode() x getNumNodes()
This method supposes that the incoming state contains information with the same number of
dof per node as getNumDofPerNode()

Implements SurgSim::Physics::FemElement.

Reimplemented in SurgSim::Physics::Fem3DElementCorotationalTetrahedron.

SurgSim::Math::Vector SurgSim::Physics::Fem3DElementTetrahedron::computeCartesianCoordinate ( const SurgSim::Math::OdeState state,
const SurgSim::Math::Vector naturalCoordinate 
) const
overridevirtual

Computes a given natural coordinate in cartesian coordinates.

Parameters
stateThe state at which to transform coordinates
naturalCoordinateThe coordinates to transform
Returns
The resultant cartesian coordinates

Implements SurgSim::Physics::FemElement.

void SurgSim::Physics::Fem3DElementTetrahedron::computeMass ( const SurgSim::Math::OdeState state,
Eigen::Matrix< double, 12, 12 > *  m 
)
protected

Computes the tetrahedron mass matrix.

Parameters
stateThe state to compute the mass matrix from
[out]mThe mass matrix to store the result into
SurgSim::Math::Vector SurgSim::Physics::Fem3DElementTetrahedron::computeNaturalCoordinate ( const SurgSim::Math::OdeState state,
const SurgSim::Math::Vector cartesianCoordinate 
) const
overridevirtual

Computes a natural coordinate given a global coordinate.

Parameters
stateThe state at which to transform coordinates
cartesianCoordinateThe coordinates to transform
Returns
The resultant natural coordinates

Implements SurgSim::Physics::FemElement.

void SurgSim::Physics::Fem3DElementTetrahedron::computeShapeFunctions ( const SurgSim::Math::OdeState state,
double *  volume,
std::array< double, 4 > *  ai,
std::array< double, 4 > *  bi,
std::array< double, 4 > *  ci,
std::array< double, 4 > *  di 
) const
protected

Computes the tetrahedron shape functions.

Parameters
stateThe deformable rest state to compute the shape function from
[out]volumethe volume calculated with the given state
[out]aifrom the shape function, Ni(x, y, z) = 1/6*volume (ai + bi.x + ci.y + di.z)
[out]bifrom the shape function, Ni(x, y, z) = 1/6*volume (ai + bi.x + ci.y + di.z)
[out]cifrom the shape function, Ni(x, y, z) = 1/6*volume (ai + bi.x + ci.y + di.z)
[out]difrom the shape function, Ni(x, y, z) = 1/6*volume (ai + bi.x + ci.y + di.z)
void SurgSim::Physics::Fem3DElementTetrahedron::computeStiffness ( const SurgSim::Math::OdeState state,
Eigen::Matrix< double, 12, 12 > *  k 
)
protected

Computes the tetrahedron stiffness matrix.

Parameters
stateThe state to compute the stiffness matrix from
[out]kThe stiffness matrix to store the result into
double SurgSim::Physics::Fem3DElementTetrahedron::getVolume ( const SurgSim::Math::OdeState state) const
overridevirtual

Get the element volume based on the input state.

Parameters
stateThe state to compute the volume with

Computes the tetrahedron volume 1/6 * | 1 p0x p0y p0z | | 1 p1x p1y p1z | | 1 p2x p2y p2z | | 1 p3x p3y p3z |

Implements SurgSim::Physics::FemElement.

void SurgSim::Physics::Fem3DElementTetrahedron::initialize ( const SurgSim::Math::OdeState state)
overridevirtual

Initialize the FemElement once everything has been set.

Parameters
stateThe state to initialize the FemElement with
Note
We use the theory of linear elasticity, so this method pre-compute the stiffness and mass matrices
It is required that the triangle ABC is CCW looking from D (i.e. dot(cross(AB, AC), AD) > 0)
This is required from the signed volume calculation method getVolume()
A warning will be logged in if this condition is not met, but the simulation will keep running. Behavior will be undefined because of possible negative volume terms.

Reimplemented from SurgSim::Physics::FemElement.

Reimplemented in SurgSim::Physics::Fem3DElementCorotationalTetrahedron.

Member Data Documentation

std::array<double, 4> SurgSim::Physics::Fem3DElementTetrahedron::m_ai
protected

Shape functions coefficients Ni(x,y,z) = 1/6V ( ai + x.bi + y.ci + z.di )

std::array<double, 4> SurgSim::Physics::Fem3DElementTetrahedron::m_bi
protected
std::array<double, 4> SurgSim::Physics::Fem3DElementTetrahedron::m_ci
protected
std::array<double, 4> SurgSim::Physics::Fem3DElementTetrahedron::m_di
protected
Eigen::Matrix<double, 6, 6> SurgSim::Physics::Fem3DElementTetrahedron::m_Em
protected

Elasticity material matrix (contains the elastic properties of the material)

Eigen::Matrix<double, 12, 12> SurgSim::Physics::Fem3DElementTetrahedron::m_K
protected

Stiffness matrix.

Eigen::Matrix<double, 12, 12> SurgSim::Physics::Fem3DElementTetrahedron::m_M
protected

Mass matrix.

double SurgSim::Physics::Fem3DElementTetrahedron::m_restVolume
protected

Shape functions: Tetrahedron rest volume.

Eigen::Matrix<double, 6, 12> SurgSim::Physics::Fem3DElementTetrahedron::m_strain
protected

Strain matrix.

Eigen::Matrix<double, 6, 12> SurgSim::Physics::Fem3DElementTetrahedron::m_stress
protected

Stress matrix.

Eigen::Matrix<double, 12, 1> SurgSim::Physics::Fem3DElementTetrahedron::m_x0
protected

The tetrahedon rest state.


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