All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
SurgSim::Math::OdeState Class Reference

OdeState defines the state y of an ode of 2nd order of the form M(x,v).a = F(x, v) with boundary conditions. More...

#include <SurgSim/Math/OdeState.h>

Collaboration diagram for SurgSim::Math::OdeState:
Collaboration graph
[legend]

Public Member Functions

 OdeState ()
 Default constructor. More...
 
 ~OdeState ()
 Destructor. More...
 
bool operator== (const OdeState &state) const
 Comparison operator (equality test) More...
 
bool operator!= (const OdeState &state) const
 Comparison operator (difference test) More...
 
void reset ()
 Resets the state. More...
 
void setNumDof (size_t numDofPerNode, size_t numNodes)
 Allocates the state for a given number of degrees of freedom. More...
 
size_t getNumDof () const
 Retrieves the number of degrees of freedom. More...
 
size_t getNumNodes () const
 Retrieves the number of nodes. More...
 
SurgSim::Math::VectorgetPositions ()
 Retrieves all degrees of freedom's position (non-const version) More...
 
const SurgSim::Math::VectorgetPositions () const
 Retrieves all degrees of freedom's position (const version) More...
 
const SurgSim::Math::Vector3d getPosition (size_t nodeId) const
 Retrieves the position of a given node (const version) More...
 
SurgSim::Math::VectorgetVelocities ()
 Retrieves all degrees of freedom's velocity (non-const version) More...
 
const SurgSim::Math::VectorgetVelocities () const
 Retrieves all degrees of freedom's velocity (const version) More...
 
const SurgSim::Math::Vector3d getVelocity (size_t nodeId) const
 Retrieves the velocity of a given node (const version) More...
 
void addBoundaryCondition (size_t nodeId)
 Adds boundary conditions for a given node (fixes all the dof for this node) More...
 
void addBoundaryCondition (size_t nodeId, size_t nodeDofId)
 Adds a boundary condition on a given dof of a given node (only 1 dof is fixed) More...
 
size_t getNumBoundaryConditions () const
 Retrieves the number of boundary conditions. More...
 
const std::vector< size_t > & getBoundaryConditions () const
 Retrieves all boundary conditions. More...
 
bool isBoundaryCondition (size_t dof) const
 Queries if a specific dof is a boundary condition or not. More...
 
VectorapplyBoundaryConditionsToVector (Vector *vector) const
 Apply boundary conditions to a given vector. More...
 
void applyBoundaryConditionsToMatrix (Matrix *matrix, bool hasCompliance=true) const
 Apply boundary conditions to a given matrix. More...
 
bool isValid () const
 Check if this state is numerically valid. More...
 

Private Attributes

size_t m_numDofPerNode
 Default public copy constructor and assignment operator are being used on purpose. More...
 
size_t m_numNodes
 
SurgSim::Math::Vector m_x
 Degrees of freedom position. More...
 
SurgSim::Math::Vector m_v
 Degrees of freedom velocity (m_x 1st derivative w.r.t. time) More...
 
std::vector< size_t > m_boundaryConditionsAsDofIds
 Boundary conditions stored as a list of dof ids. More...
 
Eigen::Matrix< bool,
Eigen::Dynamic, 1 > 
m_boundaryConditionsPerDof
 Boundary conditions stored per dof (True indicates a boundary condition, False does not) More...
 

Detailed Description

OdeState defines the state y of an ode of 2nd order of the form M(x,v).a = F(x, v) with boundary conditions.

Note
This ode equation is solved as an ode of order 1 by defining the state vector y = (x v)^t:
y' = ( x' ) = ( dx/dt ) = ( v )
( v' ) = ( dv/dt ) = ( M(x, v)^{-1}.F(x, v) )

Constructor & Destructor Documentation

SurgSim::Math::OdeState::OdeState ( )

Default constructor.

SurgSim::Math::OdeState::~OdeState ( )

Destructor.

Member Function Documentation

void SurgSim::Math::OdeState::addBoundaryCondition ( size_t  nodeId)

Adds boundary conditions for a given node (fixes all the dof for this node)

Parameters
nodeIdThe node to set the boundary conditions on
void SurgSim::Math::OdeState::addBoundaryCondition ( size_t  nodeId,
size_t  nodeDofId 
)

Adds a boundary condition on a given dof of a given node (only 1 dof is fixed)

Parameters
nodeIdThe node on which the boundary condition needs to be set
nodeDofIdThe dof of the node to set as boundary condition
void SurgSim::Math::OdeState::applyBoundaryConditionsToMatrix ( Matrix matrix,
bool  hasCompliance = true 
) const

Apply boundary conditions to a given matrix.

Parameters
matrixThe matrix to apply the boundary conditions on
hasComplianceTrue if the fixed dofs should have a compliance of 1 with themselves in the matrix or not.
Note
hasCompliance is practical to remove all compliance, which is helpful when the compliance matrix is used
in an architecture of type LCP. It ensures that a separate constraint resolution will never violates the
boundary conditions.
Vector * SurgSim::Math::OdeState::applyBoundaryConditionsToVector ( Vector vector) const

Apply boundary conditions to a given vector.

Parameters
vectorThe vector to apply the boundary conditions on
Returns
vector. This enables chained use like the pseudo-code U = K^1 * applyBoundaryConditionsToVector(x)
const std::vector< size_t > & SurgSim::Math::OdeState::getBoundaryConditions ( ) const

Retrieves all boundary conditions.

Returns
All boundary conditions as a vector of dof ids
size_t SurgSim::Math::OdeState::getNumBoundaryConditions ( ) const

Retrieves the number of boundary conditions.

Returns
The number of boundary conditions
size_t SurgSim::Math::OdeState::getNumDof ( ) const

Retrieves the number of degrees of freedom.

Returns
The number of DOF for this representation
size_t SurgSim::Math::OdeState::getNumNodes ( ) const

Retrieves the number of nodes.

Returns
The number of nodes for this representation
const SurgSim::Math::Vector3d SurgSim::Math::OdeState::getPosition ( size_t  nodeId) const

Retrieves the position of a given node (const version)

Parameters
nodeIdThe desired node id for which the position is requested (must be a valid id)
Returns
The position of the node nodeId
Note
Behavior undefined if the nodeId is not in the correct range [0 getNumNodes()-1]
SurgSim::Math::Vector & SurgSim::Math::OdeState::getPositions ( )

Retrieves all degrees of freedom's position (non-const version)

Returns
Vector of collected DOF's position
const SurgSim::Math::Vector & SurgSim::Math::OdeState::getPositions ( ) const

Retrieves all degrees of freedom's position (const version)

Returns
Vector of collected DOF's position
SurgSim::Math::Vector & SurgSim::Math::OdeState::getVelocities ( )

Retrieves all degrees of freedom's velocity (non-const version)

Returns
Vector of collected DOF's velocity
const SurgSim::Math::Vector & SurgSim::Math::OdeState::getVelocities ( ) const

Retrieves all degrees of freedom's velocity (const version)

Returns
Vector of collected DOF's velocity
const SurgSim::Math::Vector3d SurgSim::Math::OdeState::getVelocity ( size_t  nodeId) const

Retrieves the velocity of a given node (const version)

Parameters
nodeIdThe desired node id for which the velocity is requested (must be a valid id)
Returns
The velocity of the node nodeId
Note
Behavior undefined if the nodeId is not in the correct range [0 getNumNodes()-1]
bool SurgSim::Math::OdeState::isBoundaryCondition ( size_t  dof) const

Queries if a specific dof is a boundary condition or not.

Parameters
dofThe requested dof
Returns
True if dof is a boundary condition, False otherwise
Note
The behavior is undefined when dof is out of range [0 getNumBoundaryConditions()-1]
bool SurgSim::Math::OdeState::isValid ( ) const

Check if this state is numerically valid.

Returns
True if all positions and velocities are valid numerical values, False otherwise
bool SurgSim::Math::OdeState::operator!= ( const OdeState state) const

Comparison operator (difference test)

Parameters
stateThe state to compare it to
Returns
False if the 2 states are equal, True otherwise
bool SurgSim::Math::OdeState::operator== ( const OdeState state) const

Comparison operator (equality test)

Parameters
stateThe state to compare it to
Returns
True if the 2 states are equal, False otherwise
void SurgSim::Math::OdeState::reset ( )

Resets the state.

Note
Simply set all positions/velocities to 0 and remove all boundary conditions
void SurgSim::Math::OdeState::setNumDof ( size_t  numDofPerNode,
size_t  numNodes 
)

Allocates the state for a given number of degrees of freedom.

Parameters
numDofPerNodeThe number of degrees of freedom per node to account for
numNodesThe number of nodes to account for
Note
This method clears all the data structures and remove all existing boundary conditions

Member Data Documentation

std::vector<size_t> SurgSim::Math::OdeState::m_boundaryConditionsAsDofIds
private

Boundary conditions stored as a list of dof ids.

Eigen::Matrix<bool, Eigen::Dynamic, 1> SurgSim::Math::OdeState::m_boundaryConditionsPerDof
private

Boundary conditions stored per dof (True indicates a boundary condition, False does not)

size_t SurgSim::Math::OdeState::m_numDofPerNode
private

Default public copy constructor and assignment operator are being used on purpose.

Keep track of the number of degrees of freedom per node and the number of nodes

size_t SurgSim::Math::OdeState::m_numNodes
private
SurgSim::Math::Vector SurgSim::Math::OdeState::m_v
private

Degrees of freedom velocity (m_x 1st derivative w.r.t. time)

SurgSim::Math::Vector SurgSim::Math::OdeState::m_x
private

Degrees of freedom position.


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