Classes | Public Member Functions | Protected Attributes | List of all members
SurgSim::Math::OdeSolverRungeKutta4 Class Reference

Runge Kutta 4 ode solver See http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods. More...

#include <SurgSim/Math/OdeSolverRungeKutta4.h>

Inheritance diagram for SurgSim::Math::OdeSolverRungeKutta4:
SurgSim::Math::OdeSolver SurgSim::Math::OdeSolverLinearRungeKutta4

Classes

struct  RungeKuttaDerivedState
 Internal structure to hold the 4 temporary evaluations. More...
 

Public Member Functions

 OdeSolverRungeKutta4 (OdeEquation *equation)
 Constructor. More...
 
virtual void solve (double dt, const OdeState &currentState, OdeState *newState) override
 Solves the equation. More...
 
- Public Member Functions inherited from SurgSim::Math::OdeSolver
 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...
 
const Matrix & getSystemMatrix () const
 Queries the current system matrix. More...
 
const Matrix & getCompliance () const
 Queries the current compliance matrix. More...
 

Protected Attributes

Vector m_force
 Temporary vectors to store the 4 intermediates evaluations. More...
 
RungeKuttaDerivedState m_k1
 Runge kutta 4 intermediate system evaluations. More...
 
RungeKuttaDerivedState m_k2
 
RungeKuttaDerivedState m_k3
 
RungeKuttaDerivedState m_k4
 
- Protected Attributes inherited from SurgSim::Math::OdeSolver
std::string m_name
 Name for this solver. More...
 
OdeEquation & m_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...
 

Additional Inherited Members

- Protected Member Functions inherited from SurgSim::Math::OdeSolver
void allocate (size_t size)
 Allocates the system and compliance matrices. More...
 

Detailed Description

Runge Kutta 4 ode solver See http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods.

Note
M(x(t), v(t)).a(t) = f(t, x(t), v(t))
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) )
y' = f(t, y)
Runge Kutta 4 solves it via 4 dependents evaluation of f at different times
y(n+1) = y(n) + 1/6.dt (k1 + 2*k2 + 2*k3 + k4)
with:
k1 = f(t , y(n))
k2 = f(t+dt/2, y(n) + k1.dt/2)
k3 = f(t+dt/2, y(n) + k2.dt/2)
k4 = f(t+dt , y(n) + k3.dt)

Constructor & Destructor Documentation

SurgSim::Math::OdeSolverRungeKutta4::OdeSolverRungeKutta4 ( OdeEquation *  equation)
explicit

Constructor.

Parameters
equationThe ode equation to be solved

Member Function Documentation

void SurgSim::Math::OdeSolverRungeKutta4::solve ( double  dt,
const OdeState &  currentState,
OdeState *  newState 
)
overridevirtual

Solves the equation.

Parameters
dtThe time step
currentStateState at time t
[out]newStateState at time t+dt

Implements SurgSim::Math::OdeSolver.

Reimplemented in SurgSim::Math::OdeSolverLinearRungeKutta4.

Member Data Documentation

Vector SurgSim::Math::OdeSolverRungeKutta4::m_force
protected

Temporary vectors to store the 4 intermediates evaluations.

RungeKuttaDerivedState SurgSim::Math::OdeSolverRungeKutta4::m_k1
protected

Runge kutta 4 intermediate system evaluations.

RungeKuttaDerivedState SurgSim::Math::OdeSolverRungeKutta4::m_k2
protected
RungeKuttaDerivedState SurgSim::Math::OdeSolverRungeKutta4::m_k3
protected
RungeKuttaDerivedState SurgSim::Math::OdeSolverRungeKutta4::m_k4
protected

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