RungeKutta4Solver.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_RUNGEKUTTA4SOLVER_H
00026 #define SOFA_COMPONENT_ODESOLVER_RUNGEKUTTA4SOLVER_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 RungeKutta4Solver : public sofa::simulation::OdeSolverImpl
00042 {
00043 public:
00044 void solve (double dt);
00045
00046
00050 virtual double getIntegrationFactor(int inputDerivative, int outputDerivative) const
00051 {
00052 const double dt = getContext()->getDt();
00053 double matrix[3][3] = {
00054 { 1, dt/2, 0},
00055 { 0, 1, dt/2},
00056 { 0, 0, 0}};
00057 if (inputDerivative >= 3 || outputDerivative >= 3)
00058 return 0;
00059 else
00060 return matrix[outputDerivative][inputDerivative];
00061 }
00062
00066 virtual double getSolutionIntegrationFactor(int outputDerivative) const
00067 {
00068 const double dt = getContext()->getDt();
00069 double vect[3] = { 0.0, dt/2, 1};
00070 if (outputDerivative >= 3)
00071 return 0;
00072 else
00073 return vect[outputDerivative];
00074 }
00075
00076 };
00077
00078 }
00079
00080 }
00081
00082 }
00083
00084 #endif