00001 #ifndef OPENTISSUE_DYNAMICS_SPH_SOLVERS_SPH_COLOR_H 00002 #define OPENTISSUE_DYNAMICS_SPH_SOLVERS_SPH_COLOR_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 00013 #include <OpenTissue/dynamics/sph/sph_solver.h> 00014 00015 namespace OpenTissue 00016 { 00017 namespace sph 00018 { 00019 00023 template< typename Types, typename KernelPolicy > 00024 class ColorField : Solver< Types, typename Types::real_type > 00025 { 00026 public: 00027 typedef Solver<Types, typename Types::real_type> base_type; 00028 typedef KernelPolicy smoothing_kernel; 00029 typedef typename base_type::value value; 00030 typedef typename Types::particle particle; 00031 typedef typename Types::particle_cptr_container::const_iterator particle_cptr_container_citerator; 00032 00033 public: 00037 ColorField() : base_type() 00038 { 00039 } 00040 00044 ~ColorField() 00045 { 00046 } 00047 00051 ColorField& operator=(const ColorField&) 00052 { 00053 return *this; 00054 } 00055 00056 public: 00062 virtual value apply(const particle& par, particle_cptr_container_citerator begin, particle_cptr_container_citerator end) const 00063 { 00064 value res(0); 00065 for (particle_cptr_container_citerator p_ = begin; p_ != end; ++p_) { 00066 const particle* p = *p_; 00067 res += (p->mass()/p->density())*m_W.evaluate(par.position()-p->position()); 00068 } 00069 return value(res); 00070 } 00071 00072 00078 value apply(const particle& par, const particle& p) const 00079 { 00080 return value((p.mass()/p.density())*m_W.evaluate(par.position()-p.position())); 00081 } 00082 00083 private: 00084 const smoothing_kernel m_W; 00085 00086 }; // End class ColorField 00087 00088 } // namespace sph 00089 } // namespace OpenTissue 00090 00091 // OPENTISSUE_DYNAMICS_SPH_SOLVERS_SPH_COLOR_H 00092 #endif