opensurgsim
|
The state \(y\) of an ode of 2nd order of the form \(M(x,v).a = F(x, v)\) with boundary conditions. More...
#include <OdeState.h>
Public Member Functions | |
OdeState () | |
Default constructor. | |
virtual | ~OdeState () |
Destructor. | |
bool | operator== (const OdeState &state) const |
Comparison operator (equality test) More... | |
bool | operator!= (const OdeState &state) const |
Comparison operator (difference test) More... | |
virtual void | reset () |
Resets the state. More... | |
virtual 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::Vector & | getPositions () |
Retrieves all degrees of freedom's position (non-const version) More... | |
const SurgSim::Math::Vector & | getPositions () 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::Vector & | getVelocities () |
Retrieves all degrees of freedom's velocity (non-const version) More... | |
const SurgSim::Math::Vector & | getVelocities () 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... | |
Vector * | applyBoundaryConditionsToVector (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... | |
void | applyBoundaryConditionsToMatrix (SparseMatrix *matrix, bool hasCompliance=true) const |
Apply boundary conditions to a given matrix. More... | |
void | addBoundaryConditionStaticDof (size_t nodeId, double value) |
Adds a boundary condition on the static dof of a given node (we consider here that each node has a single static dof) More... | |
size_t | getNumBoundaryConditionsStaticDof () const |
const std::vector< std::pair< size_t, double > > & | getBoundaryConditionsStaticDof () const |
void | setBoundaryConditionsStaticDof (const std::vector< std::pair< size_t, double >> &staticDof) |
Set all boundary conditions on static dofs. More... | |
void | changeBoundaryConditionStaticDof (size_t nodeId, double value) |
Set the value of an existing boundary condition on a static dof. More... | |
virtual bool | isValid () const |
Check if this state is numerically valid. More... | |
OdeState | interpolate (const OdeState &other, double t) const |
Returns the linear interpolated ODE state between this and other at parameter t. More... | |
The state \(y\) of an ode of 2nd order of the form \(M(x,v).a = F(x, v)\) with boundary conditions.
This ode equation is solved as an ode of order 1 by defining the state vector \(y = \left(\begin{array}{c}x\\v\end{array}\right)\):
\[ y' = \left(\begin{array}{c} x' \\ v' \end{array}\right) = \left(\begin{array}{c} v \\ M(x, v)^{-1}.F(x, v) \end{array}\right) \]
void SurgSim::Math::OdeState::addBoundaryCondition | ( | size_t | nodeId | ) |
Adds boundary conditions for a given node (fixes all the dof for this node)
nodeId | The 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)
nodeId | The node on which the boundary condition needs to be set |
nodeDofId | The dof of the node to set as boundary condition |
void SurgSim::Math::OdeState::addBoundaryConditionStaticDof | ( | size_t | nodeId, |
double | value | ||
) |
Adds a boundary condition on the static dof of a given node (we consider here that each node has a single static dof)
nodeId | The node on which the boundary condition needs to be set |
value | The boundary conidtion value that the static dof needs to be set on |
void SurgSim::Math::OdeState::applyBoundaryConditionsToMatrix | ( | Matrix * | matrix, |
bool | hasCompliance = true |
||
) | const |
Apply boundary conditions to a given matrix.
matrix | The dense matrix to apply the boundary conditions on |
hasCompliance | True if the fixed dofs should have a compliance of 1 with themselves in the matrix or not. |
void SurgSim::Math::OdeState::applyBoundaryConditionsToMatrix | ( | SparseMatrix * | matrix, |
bool | hasCompliance = true |
||
) | const |
Apply boundary conditions to a given matrix.
matrix | The sparse matrix to apply the boundary conditions on |
hasCompliance | True if the fixed dofs should have a compliance of 1 with themselves in the matrix or not. |
Apply boundary conditions to a given vector.
vector | The vector to apply the boundary conditions on |
void SurgSim::Math::OdeState::changeBoundaryConditionStaticDof | ( | size_t | nodeId, |
double | value | ||
) |
Set the value of an existing boundary condition on a static dof.
nodeId | The node for which the static dof must be set |
value | The value to set the static dof of the given node |
const std::vector< size_t > & SurgSim::Math::OdeState::getBoundaryConditions | ( | ) | const |
Retrieves all boundary conditions.
const std::vector< std::pair< size_t, double > > & SurgSim::Math::OdeState::getBoundaryConditionsStaticDof | ( | ) | const |
size_t SurgSim::Math::OdeState::getNumBoundaryConditions | ( | ) | const |
Retrieves the number of boundary conditions.
size_t SurgSim::Math::OdeState::getNumBoundaryConditionsStaticDof | ( | ) | const |
size_t SurgSim::Math::OdeState::getNumDof | ( | ) | const |
Retrieves the number of degrees of freedom.
size_t SurgSim::Math::OdeState::getNumNodes | ( | ) | const |
Retrieves the number of nodes.
const SurgSim::Math::Vector3d SurgSim::Math::OdeState::getPosition | ( | size_t | nodeId | ) | const |
Retrieves the position of a given node (const version)
nodeId | The desired node id for which the position is requested (must be a valid id) |
SurgSim::Math::Vector & SurgSim::Math::OdeState::getPositions | ( | ) |
Retrieves all degrees of freedom's position (non-const version)
const SurgSim::Math::Vector & SurgSim::Math::OdeState::getPositions | ( | ) | const |
Retrieves all degrees of freedom's position (const version)
SurgSim::Math::Vector & SurgSim::Math::OdeState::getVelocities | ( | ) |
Retrieves all degrees of freedom's velocity (non-const version)
const SurgSim::Math::Vector & SurgSim::Math::OdeState::getVelocities | ( | ) | const |
Retrieves all degrees of freedom's velocity (const version)
const SurgSim::Math::Vector3d SurgSim::Math::OdeState::getVelocity | ( | size_t | nodeId | ) | const |
Retrieves the velocity of a given node (const version)
nodeId | The desired node id for which the velocity is requested (must be a valid id) |
Returns the linear interpolated ODE state between this and other at parameter t.
other | the end point for the linear interpolation |
t | the interpolation time |
bool SurgSim::Math::OdeState::isBoundaryCondition | ( | size_t | dof | ) | const |
Queries if a specific dof is a boundary condition or not.
dof | The requested dof |
|
virtual |
Check if this state is numerically valid.
http://steve.hollasch.net/cgindex/coding/ieeefloat.html We use the IEEE754 standard stipulating that any arithmetic operation with a NaN operand will produce NaN and any sum of +-INF with a finite number or +-INF will produce +-INF. Therefore, testing if a vector contains only finite numbers can be achieve easily by summing all the values and testing if the result is a finite number or not.
bool SurgSim::Math::OdeState::operator!= | ( | const OdeState & | state | ) | const |
Comparison operator (difference test)
state | The state to compare it to |
bool SurgSim::Math::OdeState::operator== | ( | const OdeState & | state | ) | const |
Comparison operator (equality test)
state | The state to compare it to |
|
virtual |
Resets the state.
void SurgSim::Math::OdeState::setBoundaryConditionsStaticDof | ( | const std::vector< std::pair< size_t, double >> & | staticDof | ) |
Set all boundary conditions on static dofs.
staticDof | The vector of static dof that must be set |
SurgSim::Framework::AssertionFailure | if a an item in staticDof does not have a valid nodeId (entry.first) |
|
virtual |
Allocates the state for a given number of degrees of freedom.
numDofPerNode | The number of degrees of freedom per node to account for |
numNodes | The number of nodes to account for |