00001 #ifndef OPENTISSUE_DYNAMICS_SPH_SOLVERS_SPH_GRAVITY_H 00002 #define OPENTISSUE_DYNAMICS_SPH_SOLVERS_SPH_GRAVITY_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 #include <OpenTissue/dynamics/sph/sph_particle.h> 00014 00015 namespace OpenTissue 00016 { 00017 namespace sph 00018 { 00019 00023 template< typename Types > 00024 class Gravity : Solver< Types, typename Types::vector > 00025 { 00026 public: 00027 typedef Solver<Types, typename Types::vector> base_type; 00028 typedef typename base_type::value value; 00029 typedef typename Types::vector vector; 00030 typedef typename Types::particle particle; 00031 00032 typedef typename Types::particle_cptr_container::const_iterator particle_cptr_container_citerator; 00033 00034 public: 00039 Gravity(vector const & gravity) 00040 : base_type() 00041 , m_g(gravity) 00042 { 00043 } 00044 00045 ~Gravity(){} 00046 00050 Gravity& operator=(Gravity const &) 00051 { 00052 return *this; 00053 } 00054 00055 public: 00061 virtual value apply(const particle& par, particle_cptr_container_citerator, particle_cptr_container_citerator) const 00062 { 00063 return value(m_g*par.density()); 00064 } 00065 00071 value apply(const particle& par, const particle&) const 00072 { 00073 return value(m_g*par.density()); 00074 } 00075 00076 private: 00077 const vector m_g; 00078 00079 }; // End class Gravity 00080 00081 } // namespace sph 00082 } // namespace OpenTissue 00083 00084 // OPENTISSUE_DYNAMICS_SPH_SOLVERS_SPH_GRAVITY_H 00085 #endif