EulerSolver.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_EULERSOLVER_H
00026 #define SOFA_COMPONENT_ODESOLVER_EULERSOLVER_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
00045 class EulerSolver : public sofa::simulation::OdeSolverImpl
00046 {
00047 public:
00048 EulerSolver();
00049 void solve (double dt);
00050 Data<bool> symplectic;
00051
00054 virtual double getIntegrationFactor(int inputDerivative, int outputDerivative) const
00055 {
00056 const double dt = getContext()->getDt();
00057 double matrix[3][3] = {
00058 { 1, dt, ((symplectic.getValue())?dt*dt:0.0)},
00059 { 0, 1, dt},
00060 { 0, 0, 0}};
00061 if (inputDerivative >= 3 || outputDerivative >= 3)
00062 return 0;
00063 else
00064 return matrix[outputDerivative][inputDerivative];
00065 }
00066
00070 virtual double getSolutionIntegrationFactor(int outputDerivative) const
00071 {
00072 const double dt = getContext()->getDt();
00073 double vect[3] = { ((symplectic.getValue())?dt*dt:0.0), dt, 1};
00074 if (outputDerivative >= 3)
00075 return 0;
00076 else
00077 return vect[outputDerivative];
00078 }
00079 };
00080
00081 }
00082
00083 }
00084
00085 }
00086
00087 #endif