opensurgsim
|
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 <OdeSolver.h>
Public Member Functions | |
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< LinearSparseSolveAndInverse > | getLinearSolver () const |
Gets the specialized linear solver used with this Ode solver. More... | |
virtual void | solve (double dt, const OdeState ¤tState, OdeState *newState, bool computeCompliance=true)=0 |
Solves the equation. 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 | |
virtual void | assembleLinearSystem (double dt, const OdeState &state, const OdeState &newState, bool computeRHS=true)=0 |
Assemble the linear system (A.x=b) to be solved for the state and new states (useful for certain ode solver). More... | |
void | computeComplianceMatrixFromSystemMatrix (const OdeState &state) |
Helper method computing the compliance matrix from the system matrix and setting the boundary conditions. More... | |
Protected Attributes | |
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) | |
std::shared_ptr< LinearSparseSolveAndInverse > | m_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. | |
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))\).
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) \]
|
explicit |
Constructor.
equation | The ode equation to be solved |
|
protectedpure virtual |
Assemble the linear system (A.x=b) to be solved for the state and new states (useful for certain ode solver).
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 |
Implemented in SurgSim::Math::OdeSolverEulerExplicit, SurgSim::Math::OdeSolverRungeKutta4, SurgSim::Math::OdeSolverEulerExplicitModified, SurgSim::Math::MockOdeSolver, SurgSim::Math::OdeSolverEulerImplicit, and SurgSim::Math::OdeSolverStatic.
|
protected |
Helper method computing the compliance matrix from the system matrix and setting the boundary conditions.
state | The state describing the boundary conditions |
void SurgSim::Math::OdeSolver::computeMatrices | ( | double | dt, |
const OdeState & | state, | ||
bool | computeCompliance = true |
||
) |
Computes the system and compliance matrices for a given state.
dt | The time step |
state | The state to compute the system and compliance matrices for |
computeCompliance | True to explicitly compute the compliance matrix, False otherwise |
Compute the system matrix (and discard the RHS calculation)
Compute the compliance matrix
const Matrix & SurgSim::Math::OdeSolver::getComplianceMatrix | ( | ) | const |
std::shared_ptr< LinearSparseSolveAndInverse > SurgSim::Math::OdeSolver::getLinearSolver | ( | ) | const |
Gets the specialized linear solver used with this Ode solver.
const std::string SurgSim::Math::OdeSolver::getName | ( | ) | const |
Gets the solver's name.
const SparseMatrix & SurgSim::Math::OdeSolver::getSystemMatrix | ( | ) | const |
Queries the current system matrix.
void SurgSim::Math::OdeSolver::setLinearSolver | ( | std::shared_ptr< LinearSparseSolveAndInverse > | linearSolver | ) |
Sets the specialized linear solver to use with this Ode solver.
linearSolver | the linear solver to use when solving the ode equation |
|
pure virtual |
Solves the equation.
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 |
Implemented in SurgSim::Math::OdeSolverEulerExplicit, SurgSim::Math::OdeSolverRungeKutta4, SurgSim::Math::OdeSolverEulerExplicitModified, SurgSim::Math::MockOdeSolver, SurgSim::Math::OdeSolverEulerImplicit, SurgSim::Math::OdeSolverLinearEulerImplicit, SurgSim::Math::OdeSolverStatic, SurgSim::Math::OdeSolverLinearEulerExplicit, SurgSim::Math::OdeSolverLinearEulerExplicitModified, SurgSim::Math::OdeSolverLinearRungeKutta4, and SurgSim::Math::OdeSolverLinearStatic.
|
protected |
Name for this solver.
|
protected |
Linear system matrix (can be M, K, combination of MDK depending on the solver), including boundary conditions.