|
Fluid Dynamics Library
|
00001 #ifndef __FDL_PARTICLE_H 00002 #define __FDL_PARTICLE_H 00003 00004 #include <iostream> 00005 #include <iterator> 00006 #include <string> 00007 #include <vector> 00008 #include <cfloat> 00009 #include <cmath> 00010 00011 #include "core/vector.hpp" 00012 00013 #define PARTICLE_MASS 1.0; 00014 00015 namespace fdl { 00016 00017 template<typename scalar_t> 00018 class TParticle { 00019 public: 00021 scalar_t mass; 00022 00024 TVec3<scalar_t> x; 00025 00027 TVec3<scalar_t> v; 00028 00030 TVec3<scalar_t> f; 00031 00033 TVec3<scalar_t> c; 00034 00036 scalar_t rho; 00037 00039 // unsigned int name; 00040 00045 TParticle() 00046 { 00047 timeToLive = 1.0; 00048 x *= 0; 00049 v *= 0; 00050 f *= 0; 00051 // name = -1; 00052 mass = PARTICLE_MASS; 00053 } 00054 00059 TParticle(const TVec3<scalar_t>& x0) 00060 { 00061 timeToLive = 1.0; 00062 x = x0; 00063 // name = -1; 00064 mass = PARTICLE_MASS; 00065 } 00066 00070 TParticle(const scalar_t _x, const scalar_t _y, const scalar_t _z) 00071 { 00072 timeToLive = 1.0; 00073 x.x = _x; 00074 x.y = _y; 00075 x.z = _z; 00076 // name = -1; 00077 mass = PARTICLE_MASS; 00078 } 00079 00080 ~TParticle() {} 00081 00082 // Particle(const Particle& x0) 00083 // { 00084 // x = p.x; 00085 // v = p.v; 00086 // f = p.f; 00087 // c = p.c; 00088 // rho = p.rho; 00089 // m = p.mass; 00090 // } 00091 00092 void reset() 00093 { 00094 timeToLive = 1.0; 00095 x *= 0; 00096 v *= 0; 00097 f *= 0; 00098 mass = PARTICLE_MASS; 00099 } 00100 00104 TParticle& operator=(const TParticle<scalar_t>& p) 00105 { 00106 x = p.x; 00107 v = p.v; 00108 f = p.f; 00109 c = p.c; 00110 rho = p.rho; 00111 mass = p.mass; 00112 return *this; 00113 } 00114 00121 bool isAlive(double deltaT) 00122 { 00123 timeToLive -= deltaT; 00124 if(timeToLive > 0){ 00125 return true; 00126 } 00127 else{ 00128 return false; 00129 } 00130 } 00131 00132 // void draw() 00133 // { 00134 // if(PARTICLE_DISPLAY_LIST < 0) {// MAKE DISPLAY LIST: 00135 // int displayListIndex = glGenLists(1); 00136 // glNewList(displayListIndex, GL_COMPILE); 00137 // drawParticle(0.0, 0.0, 0.0); // for now we translate with a matrix 00138 // glEndList(); 00139 // PARTICLE_DISPLAY_LIST = displayListIndex; 00140 // } 00141 // 00142 // glColor3f(c.x, c.y, c.z); 00143 // 00144 // /// DRAW ORIGIN-CIRCLE TRANSLATED TO "p": 00145 // glLoadName(name); 00146 // glPushMatrix(); 00147 // glTranslated(x.x, x.y, x.z); 00148 // glCallList(PARTICLE_DISPLAY_LIST); 00149 // glPopMatrix(); 00150 // } 00151 00152 private: 00154 scalar_t timeToLive; 00155 00159 // static void drawParticle(float z, float y, float z) 00160 // { 00161 // glPointSize(6); 00162 // glBegin(GL_POINTS); 00163 // glVertex3d(x, y, z); 00164 // glEnd(); 00165 // } 00166 }; 00167 00168 typedef TParticle<double> Particle; 00169 typedef TParticle<float> Particlef; 00170 00171 } // namespace fdl 00172 00173 #endif // __FDL_PARTICLE_H
1.7.4