HG-MD  1
Chute.h
Go to the documentation of this file.
00001 #ifndef CHUTE_H
00002 #define CHUTE_H
00003 #include "HGRID_3D.h"
00004 
00009 class Chute : public HGRID_3D { 
00010 public:
00011         
00013         Chute()
00014         {
00015                 constructor();
00016                 #ifdef CONSTUCTOR_OUTPUT
00017                         cerr << "Chute() finished" << endl;
00018                 #endif          
00019         }
00020         
00022         //The copy-constructor of MD has to be called because the link from MD to HGRID_base is virtual
00023         Chute(MD& other) : MD(other), HGRID_3D(other)
00024                 {
00025                 constructor();
00026                 #ifdef CONSTUCTOR_OUTPUT
00027                         cerr << "Chute(MD& other) finished" << endl;
00028                 #endif          
00029         }
00030         Chute(HGRID_base& other) : MD(other), HGRID_3D(other)
00031                 {
00032                 constructor();
00033                 #ifdef CONSTUCTOR_OUTPUT
00034                         cerr << "Chute(HGRID_base& other)  finished" << endl;
00035                 #endif          
00036         }
00037         Chute(HGRID_3D& other) : MD(other), HGRID_3D(other)
00038                 {
00039                 constructor();
00040                 #ifdef CONSTUCTOR_OUTPUT
00041                         cerr << "Chute(HGRID_3D& other) finished" << endl;
00042                 #endif          
00043         }
00044         
00046         void constructor();
00047         
00049         void make_chute_periodic(){is_periodic=true;}
00050         
00052         bool get_IsPeriodic() {return is_periodic;}
00053         
00055         void setup_particles_initial_conditions();
00056         
00058         void read(std::istream& is);
00059 
00061         void write(std::ostream& os);
00062         
00064         void print(std::ostream& os, bool print_all=false);
00065 
00067         void set_FixedParticleRadius(Mdouble new_){if (new_ >= 0.0) FixedParticleRadius=new_; else cerr << "WARNING : Fixed particle radius must be greater than or equal to zero" << endl;}
00069         Mdouble get_FixedParticleRadius(){return FixedParticleRadius;}
00070         
00072         void set_RandomizedBottom(int new_){RandomizedBottom = new_;}
00074         int get_RandomizedBottom(){return RandomizedBottom;}
00075         
00077         void set_ChuteAngle(Mdouble new_){Mdouble gravity = get_gravity().GetLength(); if (gravity==0) {cerr<<"WARNING: zero gravity";} set_ChuteAngle(new_, gravity);}
00079         void set_ChuteAngle(Mdouble new_, Mdouble gravity){if (new_>=0.0&&new_<=90.0) {ChuteAngle = new_*constants::pi/180.0; set_gravity(Vec3D(sin(ChuteAngle), 0.0, -cos(ChuteAngle))*gravity);} else cerr << "WARNING : Chute angle must be within [0,90]" << endl;}
00080         //void set_ChuteAngle(Mdouble new_, Mdouble gravity){if (new_>=0.0&&new_<=90.0) {ChuteAngle = new_; set_gravity(Vec3D(sin(ChuteAngle*pi/180.0), 0.0, -cos(ChuteAngle*pi/180.0))*gravity);} else cerr << "WARNING : Chute angle must be within [0,90]" << endl;}
00083         Mdouble get_ChuteAngle(){return ChuteAngle;}
00084         Mdouble get_ChuteAngleDegrees(){return ChuteAngle*180./constants::pi;}
00085 
00087         void set_max_failed(unsigned int new_){max_failed = new_;}
00089         unsigned int get_max_failed(){return max_failed;}
00090         
00092         void set_InflowParticleRadius(Mdouble new_){
00093                 if (new_>=0.0) {MinInflowParticleRadius=MaxInflowParticleRadius=new_;} else cerr << "WARNING : Inflow particle must be greater than or equal to zero" << endl;
00094         }
00096         void set_InflowParticleRadius(Mdouble new_min, Mdouble new_max){
00097                 if (new_min>=0.0)     {MinInflowParticleRadius=new_min;} else cerr << "WARNING : Min. inflow particle radius must be nonnegative" << endl;
00098                 if (new_max>=new_min) {MaxInflowParticleRadius=new_max;} else cerr << "WARNING : Max. inflow particle radius must be >= min. inflow particle radius" << endl;
00099         }
00100         void set_MinInflowParticleRadius(Mdouble new_min){
00101                 if (new_min<=MaxInflowParticleRadius) {MinInflowParticleRadius=new_min;} else cerr << "WARNING : Max. inflow particle radius must be >= min. inflow particle radius" << endl;
00102         }
00103         void set_MaxInflowParticleRadius(Mdouble new_max){
00104                 if (new_max>=MinInflowParticleRadius) {MaxInflowParticleRadius=new_max;} else cerr << "WARNING : Max. inflow particle radius must be >= min. inflow particle radius" << endl;
00105         }
00107         Mdouble get_InflowParticleRadius(){return 0.5*(MinInflowParticleRadius+MaxInflowParticleRadius);}
00109         Mdouble get_MinInflowParticleRadius(){return MinInflowParticleRadius;}
00111         Mdouble get_MaxInflowParticleRadius(){return MaxInflowParticleRadius;}
00112 
00114         void set_InflowHeight(Mdouble new_){
00115                 if (new_ >= MinInflowParticleRadius+MaxInflowParticleRadius)  { InflowHeight=new_; set_zmax(1.2*InflowHeight); } else cerr << "WARNING : Inflow height not changed to " << new_ << ", value must be greater than or equal to diameter of inflow particle" << endl;
00116         }
00118         Mdouble get_InflowHeight(){return InflowHeight;}
00119         
00121         void set_InflowVelocity(Mdouble new_){
00122                 if (new_ >= 0.0) InflowVelocity=new_; else cerr << "WARNING : Inflow velocity not changed, value must be greater than or equal to zero" << endl;
00123         }
00125         Mdouble get_InflowVelocity(){return InflowVelocity;}
00126 
00128         void set_InflowVelocityVariance(Mdouble new_){
00129                 if (new_>=0.0&&new_<=1.0) InflowVelocityVariance=new_; else cerr << "WARNING : Inflow velocity variance not changed, value must be within [0,1]" << endl;
00130         }
00132         Mdouble get_InflowVelocityVariance(){return InflowVelocityVariance;}
00133 
00134         void set_InitialHeight(Mdouble new_){
00135                 cerr << "WARNING : set_InitialHeight(Mdouble) is a deprecated function, use set_InflowHeight(Mdouble) instead." << endl;
00136                 set_InflowHeight(new_);
00137         }
00138         Mdouble get_InitialHeight(){
00139                 cerr << "WARNING : get_InitialHeight(Mdouble) is a deprecated function, use get_InflowHeight(Mdouble) instead." << endl;
00140                 return get_InflowHeight();
00141         }
00142         void set_InitialVelocity(Mdouble new_){
00143                 cerr << "WARNING : set_InitialVelocity(Mdouble) is a deprecated function, use set_InflowVelocity(Mdouble) instead." << endl;
00144                 set_InflowVelocity(new_);
00145         }
00146         Mdouble get_InitialVelocity(){
00147                 cerr << "WARNING : get_InitialVelocity(Mdouble) is a deprecated function, use get_InflowVelocity(Mdouble) instead." << endl;
00148                 return get_InflowVelocity();
00149         }
00150         void set_InitialVelocityVariance(Mdouble new_){
00151                 cerr << "WARNING : set_InitialVelocityVariance(Mdouble) is a deprecated function, use set_InflowVelocityVariance(Mdouble) instead." << endl;
00152                 set_InflowVelocityVariance(new_);
00153         }
00154         Mdouble get_InitialVelocityVariance(){
00155                 cerr << "WARNING : get_InitialVelocityVariance(Mdouble) is a deprecated function, use get_InflowVelocityVariance(Mdouble) instead." << endl;
00156                 return get_InflowVelocityVariance();
00157         }
00158         
00160         void set_ChuteWidth(Mdouble new_){set_ymax(new_);}
00161         Mdouble get_ChuteWidth(){return get_ymax();}
00162         virtual void set_ChuteLength(Mdouble new_){set_xmax(new_);}
00163         Mdouble get_ChuteLength(){return get_xmax();}
00164 
00165         int readNextArgument(unsigned int& i, unsigned int argc, char *argv[]);
00166 
00168         void set_collision_time_and_restitution_coefficient(Mdouble tc, Mdouble eps);
00169         
00171         Mdouble get_collision_time();
00172         
00174         Mdouble get_restitution_coefficient();
00175 
00177         void set_dt(){cout<<"Chute set_dt"<<endl;set_dt(.02 * get_collision_time());}
00179         void set_dt(Mdouble dt){MD::set_dt(dt);}
00180         
00182         Particle* get_SmallestParticle();
00183         
00184         Particle* get_LargestParticle();
00185         
00187         Mdouble get_radius_of_smallest_particle();
00188 
00189 protected:
00190         
00192         virtual bool IsInsertable(Particle &P);
00193         
00195         void add_particle(Particle &P);
00196         
00197         void actions_before_time_step();
00198 
00200         virtual void add_particles();
00201         
00203         void clean_chute();
00204         
00206         void initialize_inflow_particle();
00207         
00209         virtual void create_inflow_particle();
00210         
00212         virtual void create_bottom();
00213         
00214         void cout_time();
00215 
00216 
00217         Mdouble get_radius_of_largest_particle(){
00218                 Mdouble max_rad=max(FixedParticleRadius,MaxInflowParticleRadius);
00219                 for (vector<Particle*>::iterator it = get_ParticleHandler().begin(); it!=get_ParticleHandler().end(); ++it)
00220                         max_rad=max(max_rad,(*it)->get_Radius());
00221                 return max_rad;
00222 
00223         }
00224 
00225 protected:
00226         
00227         Mdouble FixedParticleRadius; //<radius of the fixed particles at the bottom
00228         int RandomizedBottom; //<distinguishes between grid-like (0), one-layer randomized (1), and thick random dense (2) bottom
00229         Mdouble ChuteAngle; //<chute angle in degrees
00230 
00231         Mdouble MinInflowParticleRadius; //<minimal radius of inflowing particles
00232         Mdouble MaxInflowParticleRadius; //<maximal radius of inflowing particles
00233         Mdouble InflowVelocity; //<Average inflow velocity in x-direction
00234         Mdouble InflowVelocityVariance; //Inflow velocity variance in x-direction
00235         Mdouble InflowHeight; //<Height of inflow
00236         int max_failed;//indicates how many attempts are undertake to insert a new particle before each timestep
00237         int num_created;//internal variable; increases by one for each particle inserted
00238         Particle P0; //<standard particle used for the inflow
00239 
00240 private:
00241 
00242         bool is_periodic;
00243                 
00244 };
00245 
00246 
00247 
00248 
00249 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines