ESyS-Particle  4.0.1
Damping.h
00001 
00002 //                                                         //
00003 // Copyright (c) 2003-2011 by The University of Queensland //
00004 // Earth Systems Science Computational Centre (ESSCC)      //
00005 // http://www.uq.edu.au/esscc                              //
00006 //                                                         //
00007 // Primary Business: Brisbane, Queensland, Australia       //
00008 // Licensed under the Open Software License version 3.0    //
00009 // http://www.opensource.org/licenses/osl-3.0.php          //
00010 //                                                         //
00012 
00013 #ifndef MODEL_DAMPING_H
00014 #define MODEL_DAMPING_H
00015 
00016 // -- project includes --
00017 #include "Model/DampingIGP.h"
00018 #include "Foundation/vec3.h"
00019 #include "Foundation/quintuple.h"
00020 
00021 class CVarMPIBuffer;
00022 class AMPIBuffer;
00023 
00028 template <class T>
00029 class CDamping
00030 {
00031 protected:
00032   T *m_p; 
00033   Vec3 m_vref; 
00034   double m_visc; 
00035   double m_dt;   
00036   int m_maxiter;   
00037   double m_E_diss; 
00038   Vec3 m_force;   
00039 
00040   static double s_limit2; 
00041   static int s_flops;       
00042 
00043 public:
00044   typedef CDampingIGP ParameterType;
00045 
00046   typedef double (CDamping::* ScalarFieldFunction)() const;
00047   typedef pair<bool,double> (CDamping::* CheckedScalarFieldFunction)() const;
00048   typedef Vec3 (CDamping::* VectorFieldFunction)() const;
00049 
00050   static ScalarFieldFunction getScalarFieldFunction(const string&);
00051   static CheckedScalarFieldFunction getCheckedScalarFieldFunction(const string&);
00052   static VectorFieldFunction getVectorFieldFunction(const string&);
00053 
00054   CDamping(T*,const Vec3&,double,double,int); // to be obsoleted
00055   CDamping(T*,const CDampingIGP&);
00056   CDamping(T*,CDampingIGP*);
00057   virtual ~CDamping();
00058 
00059   inline void setLimit(double limit){s_limit2=limit*limit;};
00060   void setTimeStepSize(double dt);
00061   virtual void calcForces();
00062   virtual bool hasTag(int,int) const;
00063   virtual Vec3 getPosFirst() const {return m_p->getPos();};
00064   virtual Vec3 getPosSecond() const {return Vec3(0.0,0.0,0.0);};
00065   virtual Vec3 getPos() const {return m_p->getPos();};
00066   vector<int> getAllID() const;
00067   esys::lsm::quintuple<Vec3,double,Vec3,double,Vec3> getRaw2Data() const
00068   {
00069     return 
00070       esys::lsm::quintuple<Vec3,double,Vec3,double,Vec3>(
00071         m_p->getPos(),
00072         m_p->getRad(),
00073         Vec3::ZERO,
00074         0,
00075         getPos()
00076       );
00077   }
00078 
00079   static void zeroFlops(){s_flops=0;};
00080   static int Flops(){return s_flops;};
00081 
00082   double getDissipatedEnergy() const;
00083   Vec3   getForce() const;
00084 };
00085 
00086 #include "Model/Damping.hpp"
00087 
00088 #endif //__DAMPING_H