Mass.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
00026
00027 #ifndef SOFA_CORE_COMPONENTMODEL_BEHAVIOR_MASS_H
00028 #define SOFA_CORE_COMPONENTMODEL_BEHAVIOR_MASS_H
00029
00030 #include <sofa/core/componentmodel/behavior/BaseMass.h>
00031 #include <sofa/core/componentmodel/behavior/ForceField.h>
00032 #include <sofa/core/componentmodel/behavior/MechanicalState.h>
00033 #include <sofa/defaulttype/Vec.h>
00034 namespace sofa
00035 {
00036
00037 namespace core
00038 {
00039
00040 namespace componentmodel
00041 {
00042
00043 namespace behavior
00044 {
00045
00055 template<class DataTypes>
00056 class Mass : virtual public ForceField<DataTypes>, public BaseMass
00057 {
00058 public:
00059 typedef typename DataTypes::VecCoord VecCoord;
00060 typedef typename DataTypes::VecDeriv VecDeriv;
00061 typedef typename DataTypes::Coord Coord;
00062 typedef typename DataTypes::Deriv Deriv;
00063
00064 Mass(MechanicalState<DataTypes> *mm = NULL);
00065
00066 virtual ~Mass();
00067
00070
00075 virtual void addMDx(double factor = 1.0);
00076
00081 virtual void accFromF();
00082
00086 virtual void addMDx(VecDeriv& f, const VecDeriv& dx, double factor = 1.0) = 0;
00087
00091 virtual void accFromF(VecDeriv& a, const VecDeriv& f) = 0;
00092
00094 virtual void addDForce(VecDeriv& , const VecDeriv& , double , double )
00095 {}
00096
00101 virtual double getKineticEnergy();
00102
00103
00104
00108 virtual double getKineticEnergy( const VecDeriv& v )=0;
00109
00120 virtual void addMBKdx(double mFactor, double bFactor, double kFactor);
00121
00132 virtual void addMBKv(double mFactor, double bFactor, double kFactor);
00133
00141 virtual void addMBKToMatrix(sofa::defaulttype::BaseMatrix * matrix, double mFact, double bFact, double kFact, unsigned int &offset);
00142
00144 virtual void initGnuplot(const std::string path);
00145
00147 virtual void exportGnuplot(double time);
00148
00150 virtual void addGravityToV(double dt)=0;
00151
00152
00153 protected:
00155 std::ofstream* m_gnuplotFileEnergy;
00156
00158 };
00159
00168 template<class Coord, class Deriv, class Vec, class M, class SV>
00169 Deriv inertiaForce( const SV& , const Vec& , const M& , const Coord& , const Deriv& )
00170 {
00171 return Deriv();
00172
00173
00174 }
00175
00176 }
00177
00178 }
00179
00180 }
00181
00182 }
00183
00184 #endif