Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

ParticleSystem.h

Go to the documentation of this file.
00001 // Copyright (C) 2004 Johan Hoffman and Anders Logg.
00002 // Licensed under the GNU GPL Version 2.
00003 
00004 #ifndef __PARTICLE_SYSTEM
00005 #define __PARTICLE_SYSTEM
00006 
00007 #include <dolfin/constants.h>
00008 #include <dolfin/ODE.h>
00009 
00010 namespace dolfin
00011 {
00012 
00026 
00027   class ParticleSystem : public ODE
00028   {
00029   public:
00030 
00032     ParticleSystem(unsigned int n, unsigned int dim = 3);
00033 
00035     ~ParticleSystem();
00036 
00038     virtual real x0(unsigned int i);
00039 
00041     virtual real y0(unsigned int i);
00042 
00044     virtual real z0(unsigned int i);
00045 
00047     virtual real vx0(unsigned int i);
00048 
00050     virtual real vy0(unsigned int i);
00051 
00053     virtual real vz0(unsigned int i);
00054     
00056     virtual real Fx(unsigned int i, real t);
00057 
00059     virtual real Fy(unsigned int i, real t);
00060 
00062     virtual real Fz(unsigned int i, real t);
00063 
00065     virtual real mass(unsigned int i, real t);
00066 
00068     real u0(unsigned int i);
00069 
00071     real f(const Vector& u, real t, unsigned int i);
00072 
00073   protected:
00074 
00075     // Return x-component of current position (inline optimized)
00076     real x(unsigned int i) const { return (*u)(dim*i); }
00077     // Return y-component of current position (inline optimized)
00078     real y(unsigned int i) const { return (*u)(dim*i + 1); }
00079     // Return z-component of current position (inline optimized)
00080     real z(unsigned int i) const { return (*u)(dim*i + 2); }
00081     // Return x-component of current velocity (inline optimized)
00082     real vx(unsigned int i) const { return (*u)(offset + dim*i); }
00083     // Return y-component of current velocity (inline optimized)
00084     real vy(unsigned int i) const { return (*u)(offset + dim*i + 1); }
00085     // Return z-component of current velocity (inline optimized)
00086     real vz(unsigned int i) const { return (*u)(offset + dim*i + 2); }
00087 
00088     // Return distance between to particles
00089     real dist(unsigned int i, unsigned int j) const;
00090 
00091     // Number of particles
00092     unsigned int n;
00093 
00094     // Number of dimensions
00095     unsigned int dim;
00096 
00097     // Half the number of components in the ODE system
00098     unsigned int offset;
00099 
00100     // Pointer to solution vector
00101     const Vector* u;
00102 
00103   };
00104 
00105 }
00106 
00107 #endif


Documentation automatically generated with Doxygen on 10 Sep 2004.