ESyS-Particle
4.0.1
|
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 __ROTPARTICLEVI_H 00014 #define __ROTPARTICLEVI_H 00015 00016 // -- project includes -- 00017 #include "Foundation/vec3.h" 00018 #include "Foundation/Matrix3.h" 00019 #include "Model/Particle.h" 00020 #include "Foundation/Quaternion.h" 00021 00022 template <class T> class ParallelParticleArray; 00023 class AMPISGBufferRoot; 00024 class AMPIBuffer; 00025 class AField; 00026 00027 //--- MPIincludes --- 00028 #include <mpi.h> 00029 00030 //--- STL includes --- 00031 #include <map> 00032 #include <vector> 00033 #include <utility> 00034 #include <string> 00035 00036 using std::map; 00037 using std::vector; 00038 using std::pair; 00039 using std::string; 00040 00041 namespace esys 00042 { 00043 namespace lsm 00044 { 00045 class SimpleParticleData; 00046 } 00047 } 00048 00052 class CRotParticleVi : public CParticle 00053 { 00054 public: // types 00055 00056 class exchangeType 00057 { 00058 public: 00059 exchangeType() 00060 : m_pos(), 00061 m_initPos(), 00062 m_vel(), 00063 m_angVel(), 00064 m_angVel_t(), 00065 m_quat() 00066 { 00067 } 00068 00069 exchangeType( 00070 const Vec3 &pos, 00071 const Vec3 &initPos, 00072 const Vec3 &vel, 00073 const Vec3 &AngVel, 00074 const Vec3 &currAngVel, 00075 const Quaternion &quat 00076 ) 00077 : m_pos(pos), 00078 m_initPos(initPos), 00079 m_vel(vel), 00080 m_angVel(AngVel), 00081 m_angVel_t(currAngVel), 00082 m_quat(quat) 00083 { 00084 } 00085 public: 00086 Vec3 m_pos; 00087 Vec3 m_initPos; 00088 Vec3 m_vel; 00089 Vec3 m_angVel; 00090 Vec3 m_angVel_t ; 00091 Quaternion m_quat; 00092 00093 friend class TML_PackedMessageInterface; 00094 }; 00095 typedef double (CRotParticleVi::* ScalarFieldFunction)() const; 00096 typedef Vec3 (CRotParticleVi::* VectorFieldFunction)() const; 00097 00098 protected: 00099 00100 Quaternion m_quat; 00101 Quaternion m_initquat; 00102 Vec3 m_angVel; // ! Angular velocity at time t -0.5*dt 00103 Vec3 m_angVel_t ; 00104 Vec3 m_moment; 00105 double m_inertRot; 00106 double m_div_inertRot; 00107 bool m_is_dynamic; 00108 00109 public: 00110 CRotParticleVi(); 00111 CRotParticleVi(const esys::lsm::SimpleParticleData &particleData); 00112 CRotParticleVi( 00113 double rad, 00114 double mass, 00115 const Vec3& pos, 00116 const Vec3& vel, 00117 const Vec3& force, 00118 int id, 00119 bool is_dyn 00120 ); 00121 CRotParticleVi( 00122 double rad, 00123 double mass, 00124 const Vec3& pos, 00125 const Vec3& vel, 00126 const Vec3& force, 00127 int id, 00128 Quaternion& quat, 00129 double inertRot, 00130 const Vec3& moment, 00131 const Vec3& angvel, 00132 const Vec3& angvel_t 00133 ); 00134 CRotParticleVi( 00135 double rad, 00136 double mass, 00137 const Vec3& pos, 00138 const Vec3& oldpos, 00139 const Vec3& initpos, 00140 const Vec3& vel, 00141 const Vec3& force, 00142 int id, 00143 const Quaternion& quat, 00144 const Quaternion& initquat, 00145 double inertRot, 00146 const Vec3& moment, 00147 const Vec3& angvel, 00148 const Vec3& angvel_t 00149 ); 00150 00151 CRotParticleVi(const CParticle &p); 00152 00153 virtual ~CRotParticleVi(){}; 00154 00155 static int getPackSize(); 00156 static ScalarFieldFunction getScalarFieldFunction(const string&); 00157 static VectorFieldFunction getVectorFieldFunction(const string&); 00158 00159 // Need to define this for template class using forAllParticles call in Parallel/SubLattice.hpp. 00160 Vec3 getDisplacement() const {return CParticle::getDisplacement();}; 00161 void resetDisplacement() {CParticle::resetDisplacement();} 00162 00163 inline const Vec3 &getAngVel () const { return m_angVel;} 00164 inline const Vec3 getAngVel_t () const { return m_angVel_t ;} ; 00165 inline void setAngVel_t (const Vec3 &v) { m_angVel_t = v;} ; 00166 inline Vec3 getAngVelNR () const { return m_angVel_t;} // for field functions 00167 inline void setAngVel(const Vec3 &V) { m_angVel = V;} 00168 inline Quaternion getInitQuat() const { return m_initquat;} 00169 inline Quaternion getQuat() const { return m_quat;} 00170 inline void setQuat(const Quaternion &q) {m_quat = q;} 00171 inline double getInertRot () const { return m_inertRot; } 00172 inline void setInertRot (double inertRot) 00173 { 00174 m_inertRot = inertRot; 00175 m_div_inertRot = 1.0/m_inertRot; 00176 } 00177 inline double getInvInertRot () const { return m_div_inertRot; } 00178 inline Vec3 getMoment() const {return m_moment;} 00179 inline void setMoment(const Vec3 &moment) {m_moment = moment;} 00180 Vec3 getAngVector()const ; 00181 void applyMoment( const Vec3&); 00182 void integrate(double); 00183 void zeroForce(); 00184 00185 //wycnewadded 00186 virtual void zeroHeat(){} ; 00187 virtual void integrateTherm(double){} ; 00188 virtual void setTemperature(double){} ; 00189 virtual void setCp(double){} ; 00190 virtual void setThermExpansion0(double){} ; 00191 virtual void setThermExpansion1(double){} ; 00192 virtual void setThermExpansion2(double){} ; 00193 virtual void thermExpansion(){} ; 00194 virtual double get_y() {return m_pos.Y(); } ; 00195 00196 00197 void rescale(); 00198 void setCircular(const Vec3& cv); 00199 double getAngularKineticEnergy() const {return (0.2*m_mass*m_rad*m_rad)*(m_angVel_t*m_angVel_t);} 00200 double getLinearKineticEnergy() const {return (0.5*m_mass)*(m_vel*m_vel);} 00201 double getKineticEnergy() const {return getLinearKineticEnergy() + getAngularKineticEnergy();} 00202 void writeAsDXLine(ostream&,int slid=0); 00203 virtual void setNonRot() {m_inertRot=0.0;m_div_inertRot=0.0;}; 00204 00205 inline Quaternion getQuatFromRotVec(const Vec3 &vec) const 00206 { 00207 const double angle = vec.norm(); 00208 const double halfAngle = angle/2.0; 00209 if (halfAngle > 0.0) { 00210 return Quaternion(cos(halfAngle), (vec)*(sin(halfAngle)/angle)); 00211 } 00212 return Quaternion(); 00213 } 00214 void rotateBy(const Vec3 &vec) {m_quat = getQuatFromRotVec(vec)*m_quat;} 00215 void rotateTo(const Vec3 &vec) {m_quat = getQuatFromRotVec(vec);} 00216 00217 static map<string,AField*> generateFields(ParallelParticleArray<CRotParticleVi>*); 00218 00219 friend ostream& operator<<(ostream&, const CRotParticleVi&); 00220 void print(){cout << *this << endl << flush;}; 00221 00222 // -- checkpointing -- 00223 virtual void saveSnapShotData(std::ostream& oStream); 00224 virtual void saveCheckPointData(std::ostream& oStream); 00225 virtual void loadCheckPointData(std::istream& iStream); 00226 00227 CRotParticleVi::exchangeType getExchangeValues(); 00228 void setExchangeValues(const CRotParticleVi::exchangeType &e); 00229 00230 // stress 00231 inline double sigma_xx_2D() const {return m_sigma(0,0)/(M_PI*m_rad*m_rad);}; 00232 inline double sigma_xy_2D() const {return m_sigma(0,1)/(M_PI*m_rad*m_rad);}; 00233 inline double sigma_yy_2D() const {return m_sigma(1,1)/(M_PI*m_rad*m_rad);}; 00234 // inline double sigma_d() const; 00235 static void get_type() {cout <<" CRotParticleVi" ;}; 00236 friend class TML_PackedMessageInterface; 00237 00238 template <typename TmplVisitor> 00239 void visit(TmplVisitor &visitor) 00240 { 00241 visitor.visitRotParticleVi(*this); 00242 } 00243 00244 }; 00245 00246 #endif //__ROTPARTICLEVI_H