00001 #ifndef OPENTISSUE_DYNAMICS_SPH_EMITTERS_SPH_CIRCLE_H 00002 #define OPENTISSUE_DYNAMICS_SPH_EMITTERS_SPH_CIRCLE_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 #include <OpenTissue/dynamics/sph/sph_emitter.h> 00013 #include <OpenTissue/core/math/math_constants.h> 00014 00015 namespace OpenTissue 00016 { 00017 namespace sph 00018 { 00019 00020 // TODO: Missing some stuff about circle orientation. 00021 // The velocity vector could be used, and the circle is just on z = 0 if v = 0. 00022 00026 template< typename Types > 00027 class CircleEmitter : public Emitter<Types> 00028 { 00029 public: 00030 typedef Emitter<Types> base_type; 00031 typedef typename Types::real_type real_type; 00032 typedef typename Types::vector vector; 00033 typedef typename Types::particle particle; 00034 typedef typename Types::particle_ptr_container particle_ptr_container; 00035 00036 public: 00037 00038 CircleEmitter(vector const & center, real_type const & radius, vector const & velocity = 0) 00039 : base_type() 00040 , m_c(center) 00041 , m_r(radius) 00042 , m_v(velocity) 00043 {} 00044 00045 ~CircleEmitter() 00046 {} 00047 00048 public: 00049 vector const & center() const { return m_c; } 00050 00051 private: 00052 00056 bool init() 00057 { 00058 const real_type Dt = 2.*math::detail::pi<real_type>()/base_type::m_batch; 00059 real_type t = 0; 00060 typename particle_ptr_container::iterator end = base_type::m_pars.end(); 00061 for (typename particle_ptr_container::iterator par = base_type::m_pars.begin(); par != end; ++par) { 00062 particle* p = *par; 00063 p->velocity() = m_v; 00064 vector disp; 00065 random(disp,-0.001, 0.001); 00066 p->position() = m_c+disp+m_r*vector(cos(t), sin(t), 0); 00067 t += Dt; 00068 } 00069 return true; 00070 } 00071 00072 protected: 00073 00074 vector m_c; 00075 real_type m_r; 00076 vector m_v; 00077 00078 }; // End class PointEmitter 00079 00080 } // namespace sph 00081 } // namespace OpenTissue 00082 00083 // OPENTISSUE_DYNAMICS_SPH_EMITTERS_SPH_CIRCLE_H 00084 #endif