• 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/sph_material.h

Go to the documentation of this file.
00001 #ifndef OPENTISSUE_DYNAMICS_SPH_SPH_MATERIAL_H
00002 #define OPENTISSUE_DYNAMICS_SPH_SPH_MATERIAL_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_idealgas.h>
00013 #include <OpenTissue/core/math/math_constants.h>
00014 
00015 namespace OpenTissue
00016 {
00017   namespace sph
00018   {
00019 
00023     template< typename Types >
00024     class Material : public IdealGas<typename Types::real_type>
00025     {
00026     public:
00027       typedef IdealGas<typename Types::real_type>  base_type;
00028       typedef typename Types::real_type  real_type;
00029       typedef typename Types::vector  vector;
00030 
00031     public:
00035       Material()
00036         : m_name("n/a")
00037         , m_volume(0)
00038         , m_density(1000)
00039         , m_particles(0)
00040         , m_kernel_particles(10)
00041         , m_particle_mass(0)
00042         , m_pressure(1)
00043         , m_tension(0)
00044         , m_buoyancy(0)
00045         , m_viscosity(0)
00046         , m_restitution(0)
00047         , m_tempature(293.15)       
00048         , m_gas_stiffness(8.3144)
00049         , m_threshold(1)
00050         , m_red(0.8)
00051         , m_green(0.8)
00052         , m_blue(0.8)
00053         , m_timestep(0.01)
00054       {
00055       }
00056 
00060       virtual ~Material()
00061       {
00062       }
00063 
00064     public:
00065 
00071       virtual real_type radius(const real_type& X) const
00072       {
00073         assert(X > 0);
00074         assert(m_particles);
00075         //--- Say we want a kernel size, such that at least X other particles are within the kernel distance of a particle!!!
00076         //---
00077         //--- The density of particles is
00078         //---
00079         //---   sigma  =  N / V
00080         //---
00081         //--- If we want X particles inside a kernel then
00082         //---
00083         //---
00084         //---    X = sigma (4/3) pi r^3   =>
00085         //---
00086         //---    3 X V  =  4 N pi r^3
00087         //---
00088         //---   So
00089         //---
00090         //---    r =  pow ( (3 X V) / (4 N pi) , 1/3);
00091         //---
00092         const real_type radius = std::pow(((3.*X*m_volume)/(4.*m_particles*math::detail::pi<real_type>())), 1./3.);
00093 #if defined(_DEBUG)
00094         std::cout << "Suggested radius (with " << X << " particles) = " << radius << "m" << std::endl;
00095 #endif
00096         return radius;
00097       }
00098 
00099     public:
00100 
00101       const std::string & name() const { return m_name; }
00102       size_t const & particles() const { return m_particles; }
00103       size_t       & particles()       { return m_particles; }
00104 
00105       real_type const & volume() const {return m_volume;}
00106       
00107       void volume(real_type const & vol)
00108       {
00109         assert(vol > 0);
00110         assert(m_particles);
00111         m_volume = vol;
00112         m_particle_mass = m_density*m_volume/m_particles;
00113       }
00114 
00115       real_type const & particle_mass() const {return m_particle_mass;}
00116       
00117       void particle_mass(real_type const & mass)
00118       {
00119         assert(mass > 0);
00120         m_particle_mass = mass;
00121         m_volume = m_particles*m_particle_mass/m_density;
00122       }
00123 
00124       const real_type& threshold() const {return m_threshold;}
00125       real_type& threshold() {return m_threshold;}
00126 
00127       const real_type& kernel_particles() const {return m_kernel_particles;}
00128 
00129       const real_type& tension() const {return m_tension;}
00130 
00131       const real_type& buoyancy() const {return m_buoyancy;}
00132 
00133       const real_type& viscosity() const {return m_viscosity;}
00134 
00135       const real_type& density() const {return m_density;}
00136 
00137       const real_type& tempature() const {return m_tempature;}
00138 
00139       const real_type& gas_stiffness() const {return m_gas_stiffness;}
00140 
00141       const real_type& timestep() const {return m_timestep;}
00142 
00143       const real_type& restitution() const {return m_restitution;}
00144 
00145       const real_type& red() const {return m_red;}
00146 
00147       const real_type& green() const {return m_green;}
00148 
00149       const real_type& blue() const {return m_blue;}
00150 
00151     protected:
00152 
00153       std::string       m_name;     
00154       real_type    m_volume;        
00155       real_type    m_density;       
00156       size_t        m_particles;     
00157       real_type    m_kernel_particles;  
00158       real_type    m_particle_mass; 
00159       real_type    m_pressure;      
00160       real_type    m_tension;       
00161       real_type    m_buoyancy;      
00162       real_type    m_viscosity;     
00163       real_type    m_restitution;   
00164       real_type    m_tempature;     
00165       real_type    m_gas_stiffness; 
00166       real_type    m_threshold;     
00167       real_type    m_red;           
00168       real_type    m_green;         
00169       real_type    m_blue;          
00170       real_type    m_timestep;      
00171 
00172     }; // End class Material
00173 
00174   } // namespace sph
00175 } // namespace OpenTissue
00176 
00177 // OPENTISSUE_DYNAMICS_SPH_SPH_MATERIAL_H
00178 #endif

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