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