opensurgsim
|
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 <FemElement.h>
Public Types | |
typedef SurgSim::Framework::ObjectFactory1< FemElement, std::shared_ptr< FemElementStructs::FemElementParameter > > | FactoryType |
Public Member Functions | |
FemElement () | |
Constructor. | |
virtual | ~FemElement () |
Virtual destructor. | |
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 (SurgSim::Math::Vector *F, double scale) const |
Adds the element force (computed for a given state) to a complete system force vector F (assembly) More... | |
virtual void | addForce (SurgSim::Math::Vector *F) const |
virtual void | addMass (SurgSim::Math::SparseMatrix *M, double scale) const |
Adds the element mass matrix M (computed for a given state) to a complete system mass matrix M (assembly) More... | |
virtual void | addMass (SurgSim::Math::SparseMatrix *M) const |
virtual void | addDamping (SurgSim::Math::SparseMatrix *D, double scale) const |
Adds the element damping matrix D (= -df/dv) (comuted for a given state) to a complete system damping matrix D (assembly) More... | |
virtual void | addDamping (SurgSim::Math::SparseMatrix *D) const |
virtual void | addStiffness (SurgSim::Math::SparseMatrix *K, double scale) const |
Adds the element stiffness matrix K (= -df/dx) (computed for a given state) to a complete system stiffness matrix K (assembly) More... | |
virtual void | addStiffness (SurgSim::Math::SparseMatrix *K) const |
virtual void | addFMDK (SurgSim::Math::Vector *F, SurgSim::Math::SparseMatrix *M, SurgSim::Math::SparseMatrix *D, SurgSim::Math::SparseMatrix *K) const |
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 (double alphaM, double alphaD, double alphaK, const SurgSim::Math::Vector &x, SurgSim::Math::Vector *F, SurgSim::Math::Vector *extractedX, SurgSim::Math::Vector *acumulator) const |
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... | |
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... | |
template<typename T , int Opt, typename StorageIndex > | |
void | assembleMatrixBlocks (const Eigen::Ref< const Math::Matrix > &subMatrix, const std::vector< size_t > &blockIds, size_t blockSize, Eigen::SparseMatrix< T, Opt, StorageIndex > *matrix) const |
Add a sub-matrix made of squared-blocks into a matrix that could be un-initialized. More... | |
template<typename T , int Opt, typename StorageIndex > | |
void | assembleMatrixBlocksNoInitialize (const Eigen::Ref< const Math::Matrix > &subMatrix, const std::vector< size_t > &blockIds, size_t blockSize, Eigen::SparseMatrix< T, Opt, StorageIndex > *matrix) const |
Add a sub-matrix made of squared-blocks into a matrix that is already initialized. More... | |
void | updateFMDK (const Math::OdeState &state, int options) |
Update the FemElement based on the given state. More... | |
Static Public Member Functions | |
static FactoryType & | getFactory () |
Protected Member Functions | |
void | setNumDofPerNode (size_t numDofPerNode) |
Sets the number of degrees of freedom per node. More... | |
virtual void | doUpdateFMDK (const Math::OdeState &state, int options)=0 |
Update the FemElement based on the given state. More... | |
void | initializeFMDK () |
Initialize f, M, D, K variables. | |
virtual void | doInitializeFMDK () |
Function to be overridden by the derived classes to initialize the f, M, D, K variables. | |
Protected Attributes | |
size_t | m_numDofPerNode |
Number of degree of freedom per node for this element. | |
std::vector< size_t > | m_nodeIds |
Node ids connected by this element. | |
SurgSim::Math::Vector | m_f |
The force vector. | |
SurgSim::Math::Matrix | m_K |
The stiffness matrix. | |
SurgSim::Math::Matrix | m_M |
The mass matrix. | |
SurgSim::Math::Matrix | m_D |
The damping matrix. | |
bool | m_useDamping |
Flag to specify of the damping is used. | |
double | m_rho |
Mass density (in Kg.m-3) | |
double | m_E |
Young modulus (in N.m-2) | |
double | m_nu |
Poisson ratio (unitless) | |
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
|
virtual |
Adds the element damping matrix D (= -df/dv) (comuted for a given state) to a complete system damping matrix D (assembly)
[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 |
|
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)
[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 |
|
virtual |
Adds the element force (computed for a given state) to a complete system force vector F (assembly)
[in,out] | F | The complete system force vector to add the element force into |
scale | A factor to scale the added force with |
|
virtual |
Adds the element mass matrix M (computed for a given state) to a complete system mass matrix M (assembly)
[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 |
|
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)
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 |
[out] | extractedX,acumulator | temporary memory for the function operation, this is an optimization as addMatVec will get repeatedly called during one physics frame, preallocating these vectors helps |
|
virtual |
Adds the element stiffness matrix K (= -df/dx) (computed for a given state) to a complete system stiffness matrix K (assembly)
[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 |
void SurgSim::Physics::FemElement::assembleMatrixBlocks | ( | const Eigen::Ref< const Math::Matrix > & | subMatrix, |
const std::vector< size_t > & | blockIds, | ||
size_t | blockSize, | ||
Eigen::SparseMatrix< T, Opt, StorageIndex > * | matrix | ||
) | const |
Add a sub-matrix made of squared-blocks into a matrix that could be un-initialized.
T,Opt,StorageIndex | Types and option defining the output matrix type SparseMatrix<T, Opt, StorageIndex> |
subMatrix | The sub-matrix (containing all the squared-blocks) | |
blockIds | Vector of block indices (for accessing matrix) corresponding to the blocks in sub-matrix | |
blockSize | The blocks size | |
[out] | matrix | The matrix to add the sub-matrix blocks into |
void SurgSim::Physics::FemElement::assembleMatrixBlocksNoInitialize | ( | const Eigen::Ref< const Math::Matrix > & | subMatrix, |
const std::vector< size_t > & | blockIds, | ||
size_t | blockSize, | ||
Eigen::SparseMatrix< T, Opt, StorageIndex > * | matrix | ||
) | const |
Add a sub-matrix made of squared-blocks into a matrix that is already initialized.
T,Opt,StorageIndex | Types and option defining the output matrix type SparseMatrix<T, Opt, StorageIndex> |
subMatrix | The sub-matrix (containing all the squared-blocks) | |
blockIds | Vector of block indices (for accessing matrix) corresponding to the blocks in sub-matrix | |
blockSize | The blocks size | |
[out] | matrix | The matrix to add the sub-matrix blocks into |
|
pure virtual |
Computes a given natural coordinate in cartesian coordinates.
state | The state at which to transform coordinates |
naturalCoordinate | The coordinates to transform |
Implemented in SurgSim::Physics::Fem2DElementTriangle, SurgSim::Physics::Fem3DElementCube, SurgSim::Physics::Fem1DElementBeam, and SurgSim::Physics::Fem3DElementTetrahedron.
|
pure virtual |
Computes a natural coordinate given a global coordinate.
state | The state at which to transform coordinates |
cartesianCoordinate | The coordinates to transform |
Implemented in SurgSim::Physics::Fem2DElementTriangle, SurgSim::Physics::Fem3DElementCube, SurgSim::Physics::Fem1DElementBeam, and SurgSim::Physics::Fem3DElementTetrahedron.
|
protectedpure virtual |
Update the FemElement based on the given state.
state | \((x, v)\) the current position and velocity to evaluate the various terms with |
options | Flag to specify which of the F, M, D, K needs to be updated |
Implemented in SurgSim::Physics::Fem2DElementTriangle, SurgSim::Physics::Fem3DElementCube, SurgSim::Physics::Fem1DElementBeam, SurgSim::Physics::Fem3DElementTetrahedron, and SurgSim::Physics::Fem3DElementCorotationalTetrahedron.
double SurgSim::Physics::FemElement::getMass | ( | const SurgSim::Math::OdeState & | state | ) | const |
Gets the element mass based on the input state (in Kg)
state | The state to compute the mass with |
double SurgSim::Physics::FemElement::getMassDensity | ( | ) | const |
Gets the mass density (in Kg.m-3)
size_t SurgSim::Physics::FemElement::getNodeId | ( | size_t | elementNodeId | ) | const |
Gets the elementNodeId-th node id.
const std::vector< size_t > & SurgSim::Physics::FemElement::getNodeIds | ( | ) | const |
Gets the node ids for this element.
size_t SurgSim::Physics::FemElement::getNumDofPerNode | ( | ) | const |
Gets the number of degree of freedom per node.
size_t SurgSim::Physics::FemElement::getNumNodes | ( | ) | const |
Gets the number of nodes connected by this element.
double SurgSim::Physics::FemElement::getPoissonRatio | ( | ) | const |
Gets the Poisson ratio (unitless)
|
pure virtual |
Gets the element volume based on the input state (in m-3)
state | The state to compute the volume with |
Implemented in SurgSim::Physics::MockFemElement, SurgSim::Physics::Fem2DElementTriangle, SurgSim::Physics::Fem3DElementCube, SurgSim::Physics::Fem3DElementTetrahedron, and SurgSim::Physics::Fem1DElementBeam.
double SurgSim::Physics::FemElement::getYoungModulus | ( | ) | const |
Gets the Young modulus (in N.m-2)
|
virtual |
Initialize the FemElement once everything has been set.
state | The state to initialize the FemElement with |
Reimplemented in SurgSim::Physics::MockFemElement, SurgSim::Physics::Fem2DElementTriangle, SurgSim::Physics::Fem3DElementCube, SurgSim::Physics::Fem3DElementTetrahedron, SurgSim::Physics::Fem3DElementCorotationalTetrahedron, and SurgSim::Physics::Fem1DElementBeam.
bool SurgSim::Physics::FemElement::isValidCoordinate | ( | const SurgSim::Math::Vector & | naturalCoordinate | ) | const |
Determines whether a given natural coordinate is valid.
naturalCoordinate | Coordinate to check |
void SurgSim::Physics::FemElement::setMassDensity | ( | double | rho | ) |
Sets the mass density (in Kg.m-3)
rho | The mass density |
|
protected |
Sets the number of degrees of freedom per node.
numDofPerNode | The number of dof per node |
void SurgSim::Physics::FemElement::setPoissonRatio | ( | double | nu | ) |
Sets the Poisson ratio (unitless)
nu | The Poisson ratio |
void SurgSim::Physics::FemElement::setYoungModulus | ( | double | E | ) |
Sets the Young modulus (in N.m-2)
E | The Young modulus |
void SurgSim::Physics::FemElement::updateFMDK | ( | const Math::OdeState & | state, |
int | options | ||
) |
Update the FemElement based on the given state.
state | \((x, v)\) the current position and velocity to evaluate the various terms with |
options | Flag to specify which of the F, M, D, K needs to be updated |