RungeKutta2Solver.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SOFA_COMPONENT_ODESOLVER_RUNGEKUTTA2SOLVER_H
00026 #define SOFA_COMPONENT_ODESOLVER_RUNGEKUTTA2SOLVER_H
00027
00028 #include <sofa/core/componentmodel/behavior/OdeSolver.h>
00029 #include <sofa/simulation/common/OdeSolverImpl.h>
00030
00031 namespace sofa
00032 {
00033
00034 namespace component
00035 {
00036
00037 namespace odesolver
00038 {
00039
00041 class RungeKutta2Solver : public sofa::simulation::OdeSolverImpl
00042 {
00043 public:
00044 void solve (double dt);
00045
00048 virtual double getIntegrationFactor(int inputDerivative, int outputDerivative) const
00049 {
00050 const double dt = getContext()->getDt();
00051 double matrix[3][3] = {
00052 { 1, dt/2, 0},
00053 { 0, 1, dt/2},
00054 { 0, 0, 0}};
00055 if (inputDerivative >= 3 || outputDerivative >= 3)
00056 return 0;
00057 else
00058 return matrix[outputDerivative][inputDerivative];
00059 }
00060
00064 virtual double getSolutionIntegrationFactor(int outputDerivative) const
00065 {
00066 const double dt = getContext()->getDt();
00067 double vect[3] = { 0.0, dt/2, 1};
00068 if (outputDerivative >= 3)
00069 return 0;
00070 else
00071 return vect[outputDerivative];
00072 }
00073 };
00074
00075 }
00076
00077 }
00078
00079 }
00080
00081 #endif