opensurgsim
Public Member Functions | Protected Member Functions | List of all members
SurgSim::Math::OdeSolverEulerExplicit Class Reference

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 <OdeSolverEulerExplicit.h>

Inheritance diagram for SurgSim::Math::OdeSolverEulerExplicit:
SurgSim::Math::OdeSolver SurgSim::Math::OdeSolverLinearEulerExplicit

Public Member Functions

 OdeSolverEulerExplicit (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.
 
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< LinearSparseSolveAndInversegetLinearSolver () 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 SparseMatrixgetSystemMatrix () const
 Queries the current system matrix. More...
 
const MatrixgetComplianceMatrix () 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...
 
OdeEquationm_equation
 The ode equation (API providing the necessary evaluation methods and the initial state)
 
std::shared_ptr< LinearSparseSolveAndInversem_linearSolver
 The specialized linear solver to use when solving the ode equation.
 
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)
 
Vector m_rhs
 
Matrix m_complianceMatrix
 Compliance matrix which is the inverse of the system matrix, including boundary conditions.
 

Detailed Description

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
Euler explicit uses a rectangular numerical integration on the left to evaluate this integral, leading to \( \int_t^{t+dt} f(t,y) dt \simeq dt.f(t, y(t))\), therefore:

\[ \begin{array}{ccc} y(t+dt) - y(t) = dt.f(t, y(t)) & \Leftrightarrow & \left\{ \begin{array}{ccccl} x(t+dt) &=& x(t) &+& dt.v(t) \\ v(t+dt) &=& v(t) &+& dt.a(t) \end{array} \right. \end{array} \]

Euler Explicit is also known as forward Euler as it uses a forward evaluation of the derivative \(y' = (y(t+dt) - y(t)) / dt\) which leads to the same result.

Constructor & Destructor Documentation

§ OdeSolverEulerExplicit()

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

Constructor.

Parameters
equationThe ode equation to be solved

Member Function Documentation

§ assembleLinearSystem()

void SurgSim::Math::OdeSolverEulerExplicit::assembleLinearSystem ( double  dt,
const OdeState state,
const OdeState newState,
bool  computeRHS = true 
)
overrideprotectedvirtual

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

Parameters
dtThe time step used in the system
state,newStateThe state and newState to be used to evaluate the system
computeRHSTrue 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::OdeSolverEulerExplicit::solve ( double  dt,
const OdeState currentState,
OdeState newState,
bool  computeCompliance = true 
)
overridevirtual

Solves the equation.

Parameters
dtThe time step
currentStateState at time t
[out]newStateState at time t+dt
computeComplianceTrue to explicitly compute the compliance matrix, False otherwise

Implements SurgSim::Math::OdeSolver.

Reimplemented in SurgSim::Math::OdeSolverLinearEulerExplicit.


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