• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

/home/hauberg/Dokumenter/Capture/humim-tracker-0.1/src/OpenTissue/OpenTissue/dynamics/sph/solvers/sph_density.h

Go to the documentation of this file.
00001 #ifndef OPENTISSUE_DYNAMICS_SPH_SOLVERS_SPH_DENSITY_H
00002 #define OPENTISSUE_DYNAMICS_SPH_SOLVERS_SPH_DENSITY_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 Density : Solver< Types, typename Types::real_type >
00024     {
00025     public:
00026       typedef Solver<Types, typename Types::real_type>  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       Density() : base_type()
00037       {
00038       }
00039 
00043       ~Density()
00044       {
00045       }
00046 
00050       Density& operator=(const Density&)
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);
00064 #if 0
00065         static long last = -1;
00066         long cnt = 0;
00067         typename particle_cptr_container::const_iterator end = pars.end();
00068         for (typename particle_cptr_container::const_iterator p_ = pars.begin(); p_ != end; ++p_) {
00069           const particle* p = *p_;
00070           cnt += m_W.checkRange(par.position()-p->position())?1:0;
00071           res += p->mass()*m_W.evaluate(par.position()-p->position());
00072         }
00073         if (last >= 0) {
00074           if (last != cnt)
00075             std::cout << last << " vs " << cnt << "/" << pars.size() << std::endl;
00076           last = -1;
00077         }
00078         else
00079           last = cnt;
00080 #else
00081         for (particle_cptr_container_citerator p_ = begin; p_ != end; ++p_) {
00082           const particle* p = *p_;
00083           res += p->mass()*m_W.evaluate(par.position()-p->position());
00084         }
00085 #endif
00086         return value(res);
00087       }
00088 
00089 
00095       value apply(const particle& par, const particle& p) const
00096       {
00097         return value(p.mass()*m_W.evaluate(par.position()-p.position()));
00098       }
00099 
00100     private:
00101       const smoothing_kernel  m_W;  
00102 
00103     }; // End class Density
00104 
00105   } // namespace sph
00106 } // namespace OpenTissue
00107 
00108 // OPENTISSUE_DYNAMICS_SPH_SOLVERS_SPH_DENSITY_H
00109 #endif

Generated on Thu Dec 1 2011 12:53:11 for HUMIM Tracker by  doxygen 1.7.1