AnimaL |
Tutorial |
Documentation |
#include <odeSolver.h>
Inheritance diagram for animal::OdeSolver< t_Positions, t_Vector, t_Real >:
Solves an ODE over a time step. Four explicit integration schemes are available. To derive your own ode solver from this class, you must overload the pure virtual method computeAcceleration( Vector&, const Positions&, const Vector&).
Choose the integration scheme using method setMethod( int ) with one of the following parameters:
Definition at line 23 of file odeSolver.h.
Public Types | |
typedef t_Positions | Positions |
Vector of positions. | |
typedef t_Vector | Vector |
velocities, forces, accelerations | |
typedef t_Real | Real |
time and other scalar values | |
Public Member Functions | |
OdeSolver () | |
Constructor. | |
virtual | ~OdeSolver () |
Destructor. | |
virtual void | solveODE (Positions &pos, Vector &vel, Real dt) |
Update positions and velocities by solving an ODE over time step dt. | |
void | setMethod (int m) |
Set the method. | |
int | method () const |
Get the method. | |
void | setMMIDsteps (int n) |
Set the number of internal time steps in the modified midpoint method. | |
int | MMIDsteps () const |
The number of internal time steps in the modified midpoint method. | |
Public Attributes | |
int | _method |
current integration method | |
int | _MMIDsteps |
Number of substeps in MMID. | |
Static Public Attributes | |
const int | EULER = 0 |
Symbol of explicit Euler integration. | |
const int | RK2 = 1 |
Symbol of second-order Runge-Kutta integration. | |
const int | RK4 = 2 |
Symbol of fourth-order Runge-Kutta integration. | |
const int | MODMID = 3 |
Symbol of modified midpoint integration. | |
const int | VVERLET = 4 |
Symbol of velocity Verlet integration. | |
Protected Types | |
typedef Derivs< Vector, Vector > | Der |
Derivs. | |
typedef States< Positions, Vector > | Sta |
States. | |
Protected Member Functions | |
virtual void | computeAccelerations (Vector &acceleration, const Positions &pos, const Vector &vel)=0 |
Compute the acceleration for given positions and velocities. | |
void | computeDerivative (Der &d, const Sta &s, Real) |
Compute the derivative(velocity, acceleration) of a given state(positions, velocities). | |
void | euler (Positions &pos, Vector &vel, Real h, Real t=0) |
Apply euler time integration. | |
void | rk2 (Positions &pos, Vector &vel, Real h, Real t=0) |
Apply second-order Runge-Kutta time integration. | |
void | rk4 (Positions &pos, Vector &vel, Real h, Real t=0) |
Apply fourth-order Runge-Kutta time integration. | |
void | modmid (Positions &pos, Vector &vel, Real h, int n, Real t=0) |
Apply modified midpoint time integration. | |
void | velocityVerlet (Positions &pos, Vector &vel, Real h) |
Apply velocity Verlet time integration. | |
void | integrate_euler (Sta &s, Real h, Real t, Der &d) |
Perform one Euler integration step: x += h*x'(x). | |
void | integrate_rk2 (Sta &s, Real h, Real t, Der &d, Sta &s1) |
Perform one second-order Runge-Kutta integration step. | |
void | integrate_rk4 (Sta &s, Real h, Real t, Der &d1, Der &d2, Der &d3, Der &d4, Sta &s1) |
Perform one fourth-order Runge-Kutta integration step. | |
void | integrate_modmid (Sta &s, Real h, Real t, int n, Der &d1, Sta &s1, Sta &s2, Sta &s3) |
Perform one modified midpoint integration step. | |
void | integrate_VVerlet (Sta &s, Real h, Der &d) |
Protected Attributes | |
Vector | dv1 |
Auxiliary value to store a derivative (velocity). | |
Vector | da1 |
Auxiliary value to store a derivative (acceleration). | |
Der | d1 |
Auxiliary value to store a derivative (velocity,acceleration). | |
Vector | dv2 |
Auxiliary value to store a derivative (velocity). | |
Vector | da2 |
Auxiliary value to store a derivative (acceleration). | |
Der | d2 |
Auxiliary value to store a derivative (velocity,acceleration). | |
Vector | dv3 |
Auxiliary value to store a derivative (velocity). | |
Vector | da3 |
Auxiliary value to store a derivative (acceleration). | |
Der | d3 |
Auxiliary value to store a derivative (velocity,acceleration). | |
Vector | dv4 |
Auxiliary value to store a derivative (velocity). | |
Vector | da4 |
Auxiliary value to store a derivative (acceleration). | |
Der | d4 |
Auxiliary value to store a derivative (velocity,acceleration). | |
Positions | sp1 |
Auxiliary value to store a state (positions). | |
Vector | sv1 |
Auxiliary value to store a state (velocities). | |
Sta | s1 |
Auxiliary value to store a state (positions, velocities). | |
Positions | sp2 |
Auxiliary value to store a state (positions). | |
Vector | sv2 |
Auxiliary value to store a state (velocities). | |
Sta | s2 |
Auxiliary value to store a state (positions, velocities). | |
Positions | sp3 |
Auxiliary value to store a state (positions). | |
Vector | sv3 |
Auxiliary value to store a state (velocities). | |
Sta | s3 |
Auxiliary value to store a state (positions, velocities). | |
Vector | velHalf |
|
Definition at line 68 of file odeSolver.h. |
|
|
|
Definition at line 87 of file odeSolver.h. |
|
|
Constructor.
Definition at line 14 of file odeSolver.inl. |
|
Destructor.
Definition at line 39 of file odeSolver.h. |
|
|
Compute the derivative(velocity, acceleration) of a given state(positions, velocities).
Definition at line 84 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::computeAccelerations(), and animal::v_eq(). |
|
Apply euler time integration. Class States is a container with entry type equal or compatible with State.
Definition at line 102 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::integrate_euler(), and animal::size(). Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Perform one Euler integration step: x += h*x'(x).
Definition at line 184 of file odeSolver.inl. References animal::v_eq_euler_step(). Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::euler(). |
|
Perform one modified midpoint integration step.
Definition at line 245 of file odeSolver.inl. References animal::v_eq(), animal::v_eq_ab(), animal::v_eq_euler_step(), and animal::v_peq(). Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::modmid(). |
|
Perform one second-order Runge-Kutta integration step.
Definition at line 197 of file odeSolver.inl. References animal::v_eq_euler_step(). Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::rk2(). |
|
Perform one fourth-order Runge-Kutta integration step.
Definition at line 214 of file odeSolver.inl. References animal::v_eq_euler_step(), animal::v_peq(), and animal::v_teq(). Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::rk4(). |
|
Definition at line 289 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::computeAccelerations(), animal::v_eq(), and animal::OdeSolver< t_Positions, t_Vector, t_Real >::velHalf. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::velocityVerlet(). |
|
Get the method.
Definition at line 66 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::_method. |
|
The number of internal time steps in the modified midpoint method.
Definition at line 54 of file odeSolver.h. Referenced by X3DTK::Qt::MassSpringEngineQt::MassSpringEngineQt(). |
|
Apply modified midpoint time integration. Class States is a container with entry type equal or compatible with State.
Definition at line 152 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::integrate_modmid(), and animal::size(). Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Apply second-order Runge-Kutta time integration. Class States is a container with entry type equal or compatible with State.
Definition at line 118 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::integrate_rk2(), and animal::size(). Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Apply fourth-order Runge-Kutta time integration. Class States is a container with entry type equal or compatible with State.
Definition at line 133 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::integrate_rk4(), and animal::size(). Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Set the method.
Reimplemented in animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >, animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings >, and animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 >. Definition at line 60 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::_method. |
|
Set the number of internal time steps in the modified midpoint method.
Definition at line 51 of file odeSolver.h. Referenced by X3DTK::Qt::MassSpringEngineQt::setMmidSubsteps(). |
|
Update positions and velocities by solving an ODE over time step dt.
Reimplemented in animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >, animal::OdeImplicitSolver< t_Positions, t_Vector, t_Real >, animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >, animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings >, animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 >, animal::OdeImplicitSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, value_type< X3DTK::MFFloat >::type >, animal::OdeImplicitSolver< Points, Velocities, value_type< SpringStiffness >::type >, and animal::OdeImplicitSolver< t_Positions, t_Vector, value_type< t_VecReal >::type >. Definition at line 27 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::_method, animal::OdeSolver< t_Positions, t_Vector, t_Real >::_MMIDsteps, animal::OdeSolver< t_Positions, t_Vector, t_Real >::euler(), animal::OdeSolver< t_Positions, t_Vector, t_Real >::EULER, animal::OdeSolver< t_Positions, t_Vector, t_Real >::modmid(), animal::OdeSolver< t_Positions, t_Vector, t_Real >::MODMID, animal::OdeSolver< t_Positions, t_Vector, t_Real >::rk2(), animal::OdeSolver< t_Positions, t_Vector, t_Real >::RK2, animal::OdeSolver< t_Positions, t_Vector, t_Real >::rk4(), animal::OdeSolver< t_Positions, t_Vector, t_Real >::RK4, animal::OdeSolver< t_Positions, t_Vector, t_Real >::velocityVerlet(), and animal::OdeSolver< t_Positions, t_Vector, t_Real >::VVERLET. |
|
Apply velocity Verlet time integration.
Definition at line 169 of file odeSolver.inl. References animal::OdeSolver< t_Positions, t_Vector, t_Real >::integrate_VVerlet(), animal::size(), and animal::OdeSolver< t_Positions, t_Vector, t_Real >::velHalf. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
current integration method
Definition at line 56 of file odeSolver.h. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::method(), animal::OdeSolver< t_Positions, t_Vector, t_Real >::setMethod(), and animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Number of substeps in MMID.
Definition at line 57 of file odeSolver.h. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Auxiliary value to store a derivative (velocity,acceleration).
Definition at line 72 of file odeSolver.h. |
|
Auxiliary value to store a derivative (velocity,acceleration).
Definition at line 76 of file odeSolver.h. |
|
Auxiliary value to store a derivative (velocity,acceleration).
Definition at line 80 of file odeSolver.h. |
|
Auxiliary value to store a derivative (velocity,acceleration).
Definition at line 84 of file odeSolver.h. |
|
Auxiliary value to store a derivative (acceleration).
Definition at line 71 of file odeSolver.h. |
|
Auxiliary value to store a derivative (acceleration).
Definition at line 75 of file odeSolver.h. |
|
Auxiliary value to store a derivative (acceleration).
Definition at line 79 of file odeSolver.h. |
|
Auxiliary value to store a derivative (acceleration).
Definition at line 83 of file odeSolver.h. |
|
Auxiliary value to store a derivative (velocity).
Definition at line 70 of file odeSolver.h. |
|
Auxiliary value to store a derivative (velocity).
Definition at line 74 of file odeSolver.h. |
|
Auxiliary value to store a derivative (velocity).
Definition at line 78 of file odeSolver.h. |
|
Auxiliary value to store a derivative (velocity).
Definition at line 82 of file odeSolver.h. |
|
Symbol of explicit Euler integration.
Definition at line 29 of file odeSolver.h. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Symbol of modified midpoint integration.
Definition at line 32 of file odeSolver.h. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Symbol of second-order Runge-Kutta integration.
Definition at line 30 of file odeSolver.h. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Symbol of fourth-order Runge-Kutta integration.
Definition at line 31 of file odeSolver.h. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |
|
Auxiliary value to store a state (positions, velocities).
Definition at line 91 of file odeSolver.h. |
|
Auxiliary value to store a state (positions, velocities).
Definition at line 95 of file odeSolver.h. |
|
Auxiliary value to store a state (positions, velocities).
Definition at line 99 of file odeSolver.h. |
|
Auxiliary value to store a state (positions).
Definition at line 89 of file odeSolver.h. |
|
Auxiliary value to store a state (positions).
Definition at line 93 of file odeSolver.h. |
|
Auxiliary value to store a state (positions).
Definition at line 97 of file odeSolver.h. |
|
Auxiliary value to store a state (velocities).
Definition at line 90 of file odeSolver.h. |
|
Auxiliary value to store a state (velocities).
Definition at line 94 of file odeSolver.h. |
|
Auxiliary value to store a state (velocities).
Definition at line 98 of file odeSolver.h. |
|
Definition at line 101 of file odeSolver.h. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::integrate_VVerlet(), and animal::OdeSolver< t_Positions, t_Vector, t_Real >::velocityVerlet(). |
|
Symbol of velocity Verlet integration.
Definition at line 33 of file odeSolver.h. Referenced by animal::OdeSolver< t_Positions, t_Vector, t_Real >::solveODE(). |