SurgSim::Physics::FemElement Class Referenceabstract

Base class for all Fem Element (1D, 2D, 3D) It handles the node ids to which it is connected and requires all derived classes to compute the element mass matrix and the force vector along with the derivatives (the stiffness and damping matrices). More...

#include <SurgSim/Physics/FemElement.h>

Inheritance diagram for SurgSim::Physics::FemElement:
[legend]
Collaboration diagram for SurgSim::Physics::FemElement:
[legend]

## Public Member Functions

FemElement ()
Constructor. More...

virtual ~FemElement ()
Virtual destructor. More...

virtual void initialize (const SurgSim::Math::OdeState &state)
Initialize the FemElement once everything has been set. 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 double getVolume (const SurgSim::Math::OdeState &state) const =0
Gets the element volume based on the input state (in m-3) More...

virtual void addForce (const SurgSim::Math::OdeState &state, SurgSim::Math::Vector *F, double scale=1.0)=0
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)=0
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)=0
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)=0
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)=0
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)=0
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 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...

virtual SurgSim::Math::Vector computeCartesianCoordinate (const SurgSim::Math::OdeState &state, const SurgSim::Math::Vector &naturalCoordinate) const =0
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 =0
Computes a natural coordinate given a global coordinate. More...

## Protected Member Functions

void setNumDofPerNode (size_t numDofPerNode)
Sets the number of degrees of freedom per node. More...

## Protected Attributes

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

Base class for all Fem Element (1D, 2D, 3D) It handles the node ids to which it is connected and requires all derived classes to compute the element mass matrix and the force vector along with the derivatives (the stiffness and damping matrices).

A extra method also exist to compute all of them at once for performance purposes. It holds on to the actual computed values (m_f, m_M, m_D, m_K) as its size is not predefined from outside and would requires intensive (de)allocation or a temporary variable anyway. It contains the linear elasticity parameter (Young modulus and Poisson ratio) as well as mass density

## Constructor & Destructor Documentation

 SurgSim::Physics::FemElement::FemElement ( )

Constructor.

 SurgSim::Physics::FemElement::~FemElement ( )
virtual

Virtual destructor.

## Member Function Documentation

 virtual void SurgSim::Physics::FemElement::addDamping ( const SurgSim::Math::OdeState & state, SurgSim::Math::Matrix * D, double scale = 1.0 )
pure virtual

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

Parameters
 state The state to compute the damping matrix with [in,out] D The complete system damping matrix to add the element damping matrix into scale A 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()
 virtual void SurgSim::Physics::FemElement::addFMDK ( const SurgSim::Math::OdeState & state, SurgSim::Math::Vector * F, SurgSim::Math::Matrix * M, SurgSim::Math::Matrix * D, SurgSim::Math::Matrix * K )
pure virtual

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
 state The state to compute everything with [in,out] F The complete system force vector to add the element force into [in,out] M The complete system mass matrix to add the element mass matrix into [in,out] D The complete system damping matrix to add the element damping matrix into [in,out] K The 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()
 virtual void SurgSim::Physics::FemElement::addForce ( const SurgSim::Math::OdeState & state, SurgSim::Math::Vector * F, double scale = 1.0 )
pure virtual

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

Parameters
 state The state to compute the force with [in,out] F The complete system force vector to add the element force into scale A 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()
 virtual void SurgSim::Physics::FemElement::addMass ( const SurgSim::Math::OdeState & state, SurgSim::Math::Matrix * M, double scale = 1.0 )
pure virtual

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

Parameters
 state The state to compute the mass matrix with [in,out] M The complete system mass matrix to add the element mass-matrix into scale A 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()
 virtual void SurgSim::Physics::FemElement::addMatVec ( const SurgSim::Math::OdeState & state, double alphaM, double alphaD, double alphaK, const SurgSim::Math::Vector & x, SurgSim::Math::Vector * F )
pure virtual

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
 state The state to compute everything with alphaM The scaling factor for the mass contribution alphaD The scaling factor for the damping contribution alphaK The scaling factor for the stiffness contribution x A complete system vector to be used as the vector in the matrix-vector multiplication [in,out] F The 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()
 virtual void SurgSim::Physics::FemElement::addStiffness ( const SurgSim::Math::OdeState & state, SurgSim::Math::Matrix * K, double scale = 1.0 )
pure virtual

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

Parameters
 state The state to compute the stiffness matrix with [in,out] K The complete system stiffness matrix to add the element stiffness matrix into scale A 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()
 virtual SurgSim::Math::Vector SurgSim::Physics::FemElement::computeCartesianCoordinate ( const SurgSim::Math::OdeState & state, const SurgSim::Math::Vector & naturalCoordinate ) const
pure virtual

Computes a given natural coordinate in cartesian coordinates.

Parameters
 state The state at which to transform coordinates naturalCoordinate The coordinates to transform
Returns
The resultant cartesian coordinates
 virtual SurgSim::Math::Vector SurgSim::Physics::FemElement::computeNaturalCoordinate ( const SurgSim::Math::OdeState & state, const SurgSim::Math::Vector & cartesianCoordinate ) const
pure virtual

Computes a natural coordinate given a global coordinate.

Parameters
 state The state at which to transform coordinates cartesianCoordinate The coordinates to transform
Returns
The resultant natural coordinates
 double SurgSim::Physics::FemElement::getMass ( const SurgSim::Math::OdeState & state ) const

Gets the element mass based on the input state (in Kg)

Parameters
 state The state to compute the mass with
Returns
The mass of this element (in Kg)
 double SurgSim::Physics::FemElement::getMassDensity ( ) const

Gets the mass density (in Kg.m-3)

Returns
The mass density
 size_t SurgSim::Physics::FemElement::getNodeId ( size_t elementNodeId ) const

Gets the elementNodeId-th node id.

Returns
The requested node id
 const std::vector< size_t > & SurgSim::Physics::FemElement::getNodeIds ( ) const

Gets the node ids for this element.

Returns
A vector containing the node ids on which the element is defined
 size_t SurgSim::Physics::FemElement::getNumDofPerNode ( ) const

Gets the number of degree of freedom per node.

Returns
The number of dof per node
 size_t SurgSim::Physics::FemElement::getNumNodes ( ) const

Gets the number of nodes connected by this element.

Returns
The number of nodes
 double SurgSim::Physics::FemElement::getPoissonRatio ( ) const

Gets the Poisson ratio (unitless)

Returns
The Poisson ratio
 virtual double SurgSim::Physics::FemElement::getVolume ( const SurgSim::Math::OdeState & state ) const
pure virtual

Gets the element volume based on the input state (in m-3)

Parameters
 state The state to compute the volume with
Returns
The volume of this element (in m-3)
 double SurgSim::Physics::FemElement::getYoungModulus ( ) const

Gets the Young modulus (in N.m-2)

Returns
The Young modulus
 void SurgSim::Physics::FemElement::initialize ( const SurgSim::Math::OdeState & state )
virtual

Initialize the FemElement once everything has been set.

Parameters
 state The state to initialize the FemElement with
 bool SurgSim::Physics::FemElement::isValidCoordinate ( const SurgSim::Math::Vector & naturalCoordinate ) const

Determines whether a given natural coordinate is valid.

Parameters
 naturalCoordinate Coordinate to check
Returns
True if valid
 void SurgSim::Physics::FemElement::setMassDensity ( double rho )

Sets the mass density (in Kg.m-3)

Parameters
 rho The mass density
 void SurgSim::Physics::FemElement::setNumDofPerNode ( size_t numDofPerNode )
protected

Sets the number of degrees of freedom per node.

Parameters
 numDofPerNode The number of dof per node
Note
Protected to be accessible only to derived classes which should be the only
ones able to set this parameter
 void SurgSim::Physics::FemElement::setPoissonRatio ( double nu )

Sets the Poisson ratio (unitless)

Parameters
 nu The Poisson ratio
 void SurgSim::Physics::FemElement::setYoungModulus ( double E )

Sets the Young modulus (in N.m-2)

Parameters
 E The Young modulus
 bool SurgSim::Physics::FemElement::update ( const SurgSim::Math::OdeState & state )
virtual

Update the element based on a given state.

Parameters
 state The state to compute the update from
Returns
True if the update is successful, False otherwise, in which case the element behavior becomes undefined. The representation should get deactivated/reset in this case.

Reimplemented in SurgSim::Physics::Fem3DElementCorotationalTetrahedron.

## Member Data Documentation

 double SurgSim::Physics::FemElement::m_E
protected

Young modulus (in N.m-2)

 std::vector SurgSim::Physics::FemElement::m_nodeIds
protected

Node ids connected by this element.

 double SurgSim::Physics::FemElement::m_nu
protected

Poisson ratio (unitless)

 size_t SurgSim::Physics::FemElement::m_numDofPerNode
protected

Number of degree of freedom per node for this element.

 double SurgSim::Physics::FemElement::m_rho
protected

Mass density (in Kg.m-3)

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