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

Base class for all solvers of ode equation of order 2 of the form M(x(t), v(t)).a(t) = f(t, x(t), v(t)) More...

#include <SurgSim/Math/OdeSolver.h>

Inheritance diagram for SurgSim::Math::OdeSolver:
Inheritance graph
[legend]
Collaboration diagram for SurgSim::Math::OdeSolver:
Collaboration graph
[legend]

Public Member Functions

 OdeSolver (OdeEquation *equation)
 Constructor. More...
 
virtual ~OdeSolver ()
 Virtual destructor. More...
 
const std::string getName () const
 Gets the solver's name. More...
 
void setLinearSolver (std::shared_ptr< LinearSolveAndInverse > linearSolver)
 Sets the specialized linear solver to use with this Ode solver. More...
 
std::shared_ptr
< LinearSolveAndInverse
getLinearSolver () const
 Gets the specialized linear solver used with this Ode solver. More...
 
virtual void solve (double dt, const OdeState &currentState, OdeState *newState)=0
 Solves the equation. More...
 
const MatrixgetSystemMatrix () const
 Queries the current system matrix. More...
 
const MatrixgetCompliance () const
 Queries the current compliance matrix. More...
 

Protected Member Functions

void allocate (size_t size)
 Allocates the system and compliance matrices. More...
 

Protected Attributes

std::string m_name
 Name for this solver. More...
 
OdeEquationm_equation
 The ode equation (API providing the necessary evaluation methods and the initial state) More...
 
std::shared_ptr
< LinearSolveAndInverse
m_linearSolver
 The specialized linear solver to use when solving the ode equation. More...
 
Matrix m_systemMatrix
 System matrix (can be M, K, combination of MDK depending on the solver) A static solver will have K for system matrix A dynamic explicit solver will have M for system matrix A dynamic implicit solver will have a combination of M, D and K for system matrix. More...
 
Matrix m_compliance
 Compliance matrix which is the inverse of the system matrix. More...
 

Detailed Description

Base class for all solvers of ode equation of order 2 of the form M(x(t), v(t)).a(t) = f(t, x(t), v(t))

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) )
To allow the use of explicit and implicit solver, we need to be able to evaluate
M(x(t), v(t))
f(t, x(t), v(t)) but also
K = -df/dx(x(t), v(t))
D = -df/dv(x(t), v(t))
Models wanting the use of implicit solvers will need to compute these Jacobian matrices.
Matrices all have dense storage, but a specialized linear solver can be set per solver.

Constructor & Destructor Documentation

SurgSim::Math::OdeSolver::OdeSolver ( OdeEquation equation)
explicit

Constructor.

Parameters
equationThe ode equation to be solved
virtual SurgSim::Math::OdeSolver::~OdeSolver ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

void SurgSim::Math::OdeSolver::allocate ( size_t  size)
protected

Allocates the system and compliance matrices.

Parameters
sizeThe size to account for in the data structure
const Matrix & SurgSim::Math::OdeSolver::getCompliance ( ) const

Queries the current compliance matrix.

Returns
The latest compliance matrix calculated
std::shared_ptr< LinearSolveAndInverse > SurgSim::Math::OdeSolver::getLinearSolver ( ) const

Gets the specialized linear solver used with this Ode solver.

Returns
The linear solver used when solving the ode equation
const std::string SurgSim::Math::OdeSolver::getName ( ) const

Gets the solver's name.

Returns
The solver name
const Matrix & SurgSim::Math::OdeSolver::getSystemMatrix ( ) const

Queries the current system matrix.

Returns
The latest system matrix calculated
void SurgSim::Math::OdeSolver::setLinearSolver ( std::shared_ptr< LinearSolveAndInverse linearSolver)

Sets the specialized linear solver to use with this Ode solver.

Parameters
linearSolverthe linear solver to use when solving the ode equation
virtual void SurgSim::Math::OdeSolver::solve ( double  dt,
const OdeState currentState,
OdeState newState 
)
pure virtual

Member Data Documentation

Matrix SurgSim::Math::OdeSolver::m_compliance
protected

Compliance matrix which is the inverse of the system matrix.

OdeEquation& SurgSim::Math::OdeSolver::m_equation
protected

The ode equation (API providing the necessary evaluation methods and the initial state)

std::shared_ptr<LinearSolveAndInverse> SurgSim::Math::OdeSolver::m_linearSolver
protected

The specialized linear solver to use when solving the ode equation.

std::string SurgSim::Math::OdeSolver::m_name
protected

Name for this solver.

Note
MUST be set by the derived classes
Matrix SurgSim::Math::OdeSolver::m_systemMatrix
protected

System matrix (can be M, K, combination of MDK depending on the solver) A static solver will have K for system matrix A dynamic explicit solver will have M for system matrix A dynamic implicit solver will have a combination of M, D and K for system matrix.


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