SurgSim::Math::OdeSolverEulerExplicitModified Class Reference

Modified Euler Explicit ode solver solves the following \(2^{nd}\) order ode \(M(x(t), v(t)).a(t) = f(t, x(t), v(t))\). More...

`#include <SurgSim/Math/OdeSolverEulerExplicitModified.h>`

Inheritance diagram for SurgSim::Math::OdeSolverEulerExplicitModified:

## Public Member Functions

| OdeSolverEulerExplicitModified (OdeEquation *equation)
| Constructor. More...
void | solve (double dt, const OdeState &currentState, OdeState *newState, bool computeCompliance=true) 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< LinearSparseSolveAndInverse > linearSolver)
| Sets the specialized linear solver to use with this Ode solver. More...
std::shared_ptr< LinearSparseSolveAndInverse > | getLinearSolver () const
| Gets the specialized linear solver used with this Ode solver. More...
void | computeMatrices (double dt, const OdeState &state, bool computeCompliance=true)
| Computes the system and compliance matrices for a given state. More...
const SparseMatrix & | getSystemMatrix () const
| Queries the current system matrix. More...
const Matrix & | getComplianceMatrix () const

## Protected Member Functions

void | assembleLinearSystem (double dt, const OdeState &state, const OdeState &newState, bool computeRHS=true) override
| Assemble the linear system (A.x=b) to be solved for the state and new states (useful for certain ode solver). More...
Protected Member Functions inherited from SurgSim::Math::OdeSolver
void | computeComplianceMatrixFromSystemMatrix (const OdeState &state)
| Helper method computing the compliance matrix from the system matrix and setting the boundary conditions. More...

## Additional Inherited Members

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< LinearSparseSolveAndInverse > | m_linearSolver
| The specialized linear solver to use when solving the ode equation. More...
SparseMatrix | m_systemMatrix
| Linear system matrix (can be M, K, combination of MDK depending on the solver), including boundary conditions. More...
Vector | m_solution
| Linear system solution and rhs vectors (including boundary conditions) More...
Vector | m_rhs
Matrix | m_complianceMatrix
| Compliance matrix which is the inverse of the system matrix, including boundary conditions. More...

## Detailed Description

Modified Euler Explicit ode solver solves the following \(2^{nd}\) order ode \(M(x(t), v(t)).a(t) = f(t, x(t), v(t))\).

This ode 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) = f(t, y) \]

After integrating this equation, we get:

\[ y(t+dt) - y(t) = \int_t^{t+dt} f(t,y) dt \]

Note
  The modified Euler explicit is the same as Euler explicit, but simply using the newly calculated velocity to update the position with instead of using the velocity from the previous time-step.
  This makes this solver explicit on the velocity and implicit on the position, it improves the stability of the method compare to the Euler explicit but is still an explicit method.
  The numerical integration scheme becomes:

  \[ \left\{ \begin{array}{ccccl} x(t+dt) &=& x(t) &+& dt.v(t+dt) \\ v(t+dt) &=& v(t) &+& dt.a(t) \end{array} \right. \]

See also
  OdeSolverEulerExplicit

## Constructor & Destructor Documentation

## OdeSolverEulerExplicitModified()

SurgSim::Math::OdeSolverEulerExplicitModified::OdeSolverEulerExplicitModified | ( | OdeEquation * | equation | ) |

explicit

Constructor.

Parameters

  equation | The ode equation to be solved

## Member Function Documentation

## assembleLinearSystem()

void SurgSim::Math::OdeSolverEulerExplicitModified::assembleLinearSystem | ( | double | dt,
|  | const OdeState & | state,
|  | const OdeState & | newState,
|  | bool | computeRHS = `true`
| ) |  |

override protected virtual

Assemble the linear system (A.x=b) to be solved for the state and new states (useful for certain ode solver).

Parameters

  dt | The time step used in the system
  state,newState | The state and newState to be used to evaluate the system
  computeRHS | True to compute the RHS vector, False otherwise

Note
  The method should fill up the LHS matrix in m_systemMatrix and the RHS vector in m_b (if requested)
  The method should take care of the boundary conditions properly on both the matrix and the vector.
  The method should prepare the linear solver m_linearSolver to be used with the m_systemMatrix

Implements SurgSim::Math::OdeSolver.

## solve()

void SurgSim::Math::OdeSolverEulerExplicitModified::solve | ( | double | dt,
|  | const OdeState & | currentState,
|  | OdeState * | newState,
|  | bool | computeCompliance = `true`
| ) |  |

override virtual

Solves the equation.

Parameters

  | dt | The time step
  | currentState | State at time t
  [out] | newState | State at time t+dt
  | computeCompliance | True to explicitly compute the compliance matrix, False otherwise

Implements SurgSim::Math::OdeSolver.

Reimplemented in SurgSim::Math::OdeSolverLinearEulerExplicitModified.

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

- SurgSim/Math/OdeSolverEulerExplicitModified.h
- SurgSim/Math/OdeSolverEulerExplicitModified.cpp