opensurgsim
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SurgSim::Math::OdeEquation Class Referenceabstract

Ode equation of 2nd order of the form \(M(x,v).a = F(x, v)\) with \((x0, v0)\) for initial conditions and a set of boundary conditions. More...

#include <OdeEquation.h>

Inheritance diagram for SurgSim::Math::OdeEquation:
SurgSim::Math::MassPoint SurgSim::Math::MassPointsForStatic SurgSim::Math::OdeComplexNonLinear SurgSim::Physics::DeformableRepresentation SurgSim::Physics::FemRepresentation SurgSim::Physics::MassSpringRepresentation SurgSim::Physics::MockDeformableRepresentation SurgSim::Physics::Fem1DRepresentation SurgSim::Physics::Fem2DRepresentation SurgSim::Physics::Fem3DRepresentation SurgSim::Physics::MockFemRepresentation SurgSim::Blocks::MassSpring1DRepresentation SurgSim::Blocks::MassSpring2DRepresentation SurgSim::Blocks::MassSpring3DRepresentation SurgSim::Physics::MockMassSpring DeformableRepresentationTest

Public Member Functions

virtual ~OdeEquation ()
 Virtual destructor.
 
const std::shared_ptr< OdeStategetInitialState () const
 Retrieves the ode initial conditions \((x0, v0)\) (i.e the initial state) More...
 
virtual Matrix applyCompliance (const OdeState &state, const Matrix &b)=0
 Calculate the product \(C.b\) where \(C\) is the compliance matrix with boundary conditions applied. More...
 
virtual void updateFMDK (const OdeState &state, int options)
 Update the OdeEquation (and support data) based on the given state. More...
 
const VectorgetF () const
 
const SparseMatrixgetM () const
 
const SparseMatrixgetD () const
 
const SparseMatrixgetK () const
 
bool hasF () const
 
bool hasM () const
 
bool hasK () const
 
bool hasD () const
 

Protected Member Functions

virtual void computeF (const OdeState &state)=0
 Evaluation of the RHS function \(f(x, v)\) for a given state. More...
 
virtual void computeM (const OdeState &state)=0
 Evaluation of the LHS matrix \(M(x,v)\) for a given state. More...
 
virtual void computeD (const OdeState &state)=0
 Evaluation of \(D = -\frac{\partial f}{\partial v}(x,v)\) for a given state. More...
 
virtual void computeK (const OdeState &state)=0
 Evaluation of \(K = -\frac{\partial f}{\partial x}(x,v)\) for a given state. More...
 
virtual void computeFMDK (const OdeState &state)=0
 Evaluation of \(f(x,v)\), \(M(x,v)\), \(D = -\frac{\partial f}{\partial v}(x,v)\) and \(K = -\frac{\partial f}{\partial x}(x,v)\). More...
 

Protected Attributes

std::shared_ptr< OdeStatem_initialState
 The initial state (which defines the ODE initial conditions \((x0, v0)\)) More...
 
unsigned int m_initState
 
Vector m_f
 The vector containing \(f(x, v)\).
 
SparseMatrix m_M
 The matrix \(M(x,v)\).
 
SparseMatrix m_D
 The The matrix \(D = -\frac{\partial f}{\partial v}(x,v)\).
 
SparseMatrix m_K
 The The matrix \(K = -\frac{\partial f}{\partial x}(x,v)\).
 

Detailed Description

Ode equation of 2nd order of the form \(M(x,v).a = F(x, v)\) with \((x0, v0)\) for initial conditions and a set of boundary conditions.

The problem is called a Boundary Value Problem (BVP). 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(t, x, v) \end{array}\right) \]

Note
To allow the use of explicit and implicit solver, we need to be able to evaluate
\(M(x, v)\), \(f(t, x, v)\) but also \(K = -dF/dx(x, v)\) and \(D = -dF/dv(x, v)\)
Models wanting the use of implicit solvers will need to compute these Jacobian matrices.

Member Function Documentation

§ applyCompliance()

virtual Matrix SurgSim::Math::OdeEquation::applyCompliance ( const OdeState state,
const Matrix b 
)
pure virtual

Calculate the product \(C.b\) where \(C\) is the compliance matrix with boundary conditions applied.

Note that this can be rewritten as \((B^T)(M^{-1})(B.b) = (B^T)((M^{-1})(B.b)) = x\), where \((M^{-1})(B.b) = y\) is simply the solution to \(M.y = B.b\) and \(B^T.y = x\).

Parameters
state\((x, v)\) the current position and velocity to evaluate the various terms with
bThe input matrix
Returns
The matrix \(C.b\)

Implemented in SurgSim::Math::OdeComplexNonLinear, SurgSim::Math::MassPointsForStatic, SurgSim::Physics::FemRepresentation, SurgSim::Physics::DeformableRepresentation, and SurgSim::Math::MassPoint.

§ computeD()

virtual void SurgSim::Math::OdeEquation::computeD ( const OdeState state)
protectedpure virtual

Evaluation of \(D = -\frac{\partial f}{\partial v}(x,v)\) for a given state.

Parameters
state\((x, v)\) the current position and velocity to evaluate the Jacobian matrix with

Implemented in SurgSim::Math::OdeComplexNonLinear, SurgSim::Physics::MockDeformableRepresentation, SurgSim::Physics::FemRepresentation, SurgSim::Math::MassPointsForStatic, SurgSim::Physics::MassSpringRepresentation, and SurgSim::Math::MassPoint.

§ computeF()

virtual void SurgSim::Math::OdeEquation::computeF ( const OdeState state)
protectedpure virtual

Evaluation of the RHS function \(f(x, v)\) for a given state.

Parameters
state\((x, v)\) the current position and velocity to evaluate the function \(f(x,v)\) with

Implemented in SurgSim::Math::OdeComplexNonLinear, SurgSim::Physics::MockDeformableRepresentation, SurgSim::Physics::FemRepresentation, SurgSim::Physics::MassSpringRepresentation, SurgSim::Math::MassPointsForStatic, and SurgSim::Math::MassPoint.

§ computeFMDK()

virtual void SurgSim::Math::OdeEquation::computeFMDK ( const OdeState state)
protectedpure virtual

Evaluation of \(f(x,v)\), \(M(x,v)\), \(D = -\frac{\partial f}{\partial v}(x,v)\) and \(K = -\frac{\partial f}{\partial x}(x,v)\).

When all the terms are needed, this method can perform optimization in evaluating everything together

Parameters
state\((x, v)\) the current position and velocity to evaluate the various terms with
Note
computeF(), computeM(), computeD(), computeK()

Implemented in SurgSim::Math::OdeComplexNonLinear, SurgSim::Math::MassPointsForStatic, SurgSim::Physics::FemRepresentation, SurgSim::Physics::MockDeformableRepresentation, SurgSim::Physics::MassSpringRepresentation, and SurgSim::Math::MassPoint.

§ computeK()

virtual void SurgSim::Math::OdeEquation::computeK ( const OdeState state)
protectedpure virtual

Evaluation of \(K = -\frac{\partial f}{\partial x}(x,v)\) for a given state.

Parameters
state\((x, v)\) the current position and velocity to evaluate the Jacobian matrix with

Implemented in SurgSim::Math::OdeComplexNonLinear, SurgSim::Physics::FemRepresentation, SurgSim::Physics::MockDeformableRepresentation, SurgSim::Math::MassPointsForStatic, SurgSim::Physics::MassSpringRepresentation, and SurgSim::Math::MassPoint.

§ computeM()

virtual void SurgSim::Math::OdeEquation::computeM ( const OdeState state)
protectedpure virtual

Evaluation of the LHS matrix \(M(x,v)\) for a given state.

Parameters
state\((x, v)\) the current position and velocity to evaluate the matrix \(M(x,v)\) with

Implemented in SurgSim::Math::OdeComplexNonLinear, SurgSim::Physics::MockDeformableRepresentation, SurgSim::Physics::FemRepresentation, SurgSim::Physics::MassSpringRepresentation, SurgSim::Math::MassPointsForStatic, and SurgSim::Math::MassPoint.

§ getD()

const SparseMatrix & SurgSim::Math::OdeEquation::getD ( ) const
Returns
The matrix \(D = -\frac{\partial f}{\partial v}(x,v)\)

§ getF()

const Vector & SurgSim::Math::OdeEquation::getF ( ) const
Returns
The vector containing \(f(x, v)\)

§ getInitialState()

const std::shared_ptr< OdeState > SurgSim::Math::OdeEquation::getInitialState ( ) const

Retrieves the ode initial conditions \((x0, v0)\) (i.e the initial state)

Returns
The initial state

§ getK()

const SparseMatrix & SurgSim::Math::OdeEquation::getK ( ) const
Returns
The matrix \(K = -\frac{\partial f}{\partial x}(x,v)\)

§ getM()

const SparseMatrix & SurgSim::Math::OdeEquation::getM ( ) const
Returns
The matrix \(M(x,v)\)

§ updateFMDK()

void SurgSim::Math::OdeEquation::updateFMDK ( const OdeState state,
int  options 
)
virtual

Update the OdeEquation (and support data) based on the given state.

Parameters
state\((x, v)\) the current position and velocity to evaluate the various terms with
optionsFlag to specify which of F, M, D, K needs to be updated.

Reimplemented in SurgSim::Physics::FemRepresentation.

Member Data Documentation

§ m_initialState

std::shared_ptr<OdeState> SurgSim::Math::OdeEquation::m_initialState
protected

The initial state (which defines the ODE initial conditions \((x0, v0)\))

Note
MUST be set by the derived classes

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