MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Chute.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef CHUTE_H
27 #define CHUTE_H
28 #include "HGRID_3D.h"
29 
34 class Chute : public HGRID_3D {
35 public:
36 
39  {
40  constructor();
41  #ifdef CONSTUCTOR_OUTPUT
42  std::cerr << "Chute() finished" << std::endl;
43  #endif
44  }
45 
47  //The copy-constructor of MD has to be called because the link from MD to HGRID_base is virtual
48  Chute(MD& other) : MD(other), HGRID_3D(other)
49  {
50  constructor();
51  #ifdef CONSTUCTOR_OUTPUT
52  std::cerr << "Chute(MD& other) finished" << std::endl;
53  #endif
54  }
55  Chute(HGRID_base& other) : MD(other), HGRID_3D(other)
56  {
57  constructor();
58  #ifdef CONSTUCTOR_OUTPUT
59  std::cerr << "Chute(HGRID_base& other) finished" << std::endl;
60  #endif
61  }
62  Chute(HGRID_3D& other) : MD(other), HGRID_3D(other)
63  {
64  constructor();
65  #ifdef CONSTUCTOR_OUTPUT
66  std::cerr << "Chute(HGRID_3D& other) finished" << std::endl;
67  #endif
68  }
69 
71  void constructor();
72 
75 
77  bool get_IsPeriodic() {return is_periodic;}
78 
81 
83  void read(std::istream& is);
84 
86  virtual void write(std::ostream& os);
87 
89  void print(std::ostream& os, bool print_all=false);
90 
92  void set_FixedParticleRadius(Mdouble new_){if (new_ >= 0.0) FixedParticleRadius=new_; else std::cerr << "WARNING : Fixed particle radius must be greater than or equal to zero" << std::endl;}
95 
97  void set_RandomizedBottom(int new_){RandomizedBottom = new_;}
100 
102  void set_ChuteAngle(Mdouble new_){Mdouble gravity = get_gravity().GetLength(); if (gravity==0) {std::cerr<<"WARNING: zero gravity";} set_ChuteAngle(new_, gravity);}
104  void set_ChuteAngle(Mdouble new_, Mdouble gravity){if (new_>=-90.0&&new_<=90.0) {ChuteAngle = new_*constants::pi/180.0; set_gravity(Vec3D(sin(ChuteAngle), 0.0, -cos(ChuteAngle))*gravity);} else std::cerr << "WARNING : Chute angle must be within [-90,90]" << std::endl;}
105  //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 std::cerr << "WARNING : Chute angle must be within [0,90]" << std::endl;}
110 
112  void set_max_failed(unsigned int new_){max_failed = new_;}
114  unsigned int get_max_failed(){return max_failed;}
115 
118  if (new_>=0.0) {MinInflowParticleRadius=MaxInflowParticleRadius=new_;} else std::cerr << "WARNING : Inflow particle must be greater than or equal to zero" << std::endl;
119  }
121  void set_InflowParticleRadius(Mdouble new_min, Mdouble new_max){
122  if (new_min>=0.0) {MinInflowParticleRadius=new_min;} else std::cerr << "WARNING : Min. inflow particle radius must be nonnegative" << std::endl;
123  if (new_max>=new_min) {MaxInflowParticleRadius=new_max;} else std::cerr << "WARNING : Max. inflow particle radius must be >= min. inflow particle radius" << std::endl;
124  }
126  if (new_min<=MaxInflowParticleRadius) {MinInflowParticleRadius=new_min;} else std::cerr << "WARNING : Max. inflow particle radius must be >= min. inflow particle radius" << std::endl;
127  }
129  if (new_max>=MinInflowParticleRadius) {MaxInflowParticleRadius=new_max;} else std::cerr << "WARNING : Max. inflow particle radius must be >= min. inflow particle radius" << std::endl;
130  }
137 
140  if (new_ >= MinInflowParticleRadius+MaxInflowParticleRadius) { InflowHeight=new_; set_zmax(1.2*InflowHeight); } else std::cerr << "WARNING : Inflow height not changed to " << new_ << ", value must be greater than or equal to diameter of inflow particle" << std::endl;
141  }
144 
147  if (new_ >= 0.0) InflowVelocity=new_; else std::cerr << "WARNING : Inflow velocity not changed, value must be greater than or equal to zero" << std::endl;
148  }
151 
154  if (new_>=0.0&&new_<=1.0) InflowVelocityVariance=new_; else std::cerr << "WARNING : Inflow velocity variance not changed, value must be within [0,1]" << std::endl;
155  }
158 
160  std::cerr << "WARNING : set_InitialHeight(Mdouble) is a deprecated function, use set_InflowHeight(Mdouble) instead." << std::endl;
161  set_InflowHeight(new_);
162  }
164  std::cerr << "WARNING : get_InitialHeight(Mdouble) is a deprecated function, use get_InflowHeight(Mdouble) instead." << std::endl;
165  return get_InflowHeight();
166  }
168  std::cerr << "WARNING : set_InitialVelocity(Mdouble) is a deprecated function, use set_InflowVelocity(Mdouble) instead." << std::endl;
169  set_InflowVelocity(new_);
170  }
172  std::cerr << "WARNING : get_InitialVelocity(Mdouble) is a deprecated function, use get_InflowVelocity(Mdouble) instead." << std::endl;
173  return get_InflowVelocity();
174  }
176  std::cerr << "WARNING : set_InitialVelocityVariance(Mdouble) is a deprecated function, use set_InflowVelocityVariance(Mdouble) instead." << std::endl;
178  }
180  std::cerr << "WARNING : get_InitialVelocityVariance(Mdouble) is a deprecated function, use get_InflowVelocityVariance(Mdouble) instead." << std::endl;
182  }
183 
185  void set_ChuteWidth(Mdouble new_){set_ymax(new_);}
187  virtual void set_ChuteLength(Mdouble new_){set_xmax(new_);}
189 
190  int readNextArgument(unsigned int& i, unsigned int argc, char *argv[]);
191 
194 
197 
200 
202  void set_dt(){std::cout<<"Chute set_dt"<<std::endl;set_dt(.02 * get_collision_time());}
205 
208 
210 
211  BaseParticle* get_P0(){return &P0;}
212 
215 
217 
218 protected:
219 
221  virtual bool IsInsertable(BaseParticle &P);
222 
224  void add_particle(BaseParticle &P);
225 
227 
229  virtual void add_particles();
230 
232  void clean_chute();
233 
236 
238  virtual void create_inflow_particle();
239 
241  virtual void create_bottom();
242 
243  void cout_time();
244 
245 
247 
248 protected:
249 
250  Mdouble FixedParticleRadius; //<radius of the fixed particles at the bottom
251  int RandomizedBottom; //<distinguishes between grid-like (0), one-layer randomized (1), and thick random dense (2) bottom
252  Mdouble ChuteAngle; //<chute angle in degrees
253 
254  Mdouble MinInflowParticleRadius; //<minimal radius of inflowing particles
255  Mdouble MaxInflowParticleRadius; //<maximal radius of inflowing particles
256  Mdouble InflowVelocity; //<Average inflow velocity in x-direction
257  Mdouble InflowVelocityVariance; //Inflow velocity variance in x-direction
258  Mdouble InflowHeight; //<Height of inflow
259  int max_failed;//indicates how many attempts are undertake to insert a new particle before each timestep
260  int num_created;//internal variable; increases by one for each particle inserted
262  TangentialSpringParticle P0; //<standard particle used for the inflow
263 
264 private:
265 
267 
268 };
269 
270 
271 
272 
273 #endif
Mdouble InflowVelocity
Definition: Chute.h:256
Mdouble MinInflowParticleRadius
Definition: Chute.h:254
This is the base class for both HGRID_2D and HGRID_3D.
Definition: HGRID_base.h:43
Mdouble get_InitialVelocity()
Definition: Chute.h:171
Mdouble get_LargestParticleInteractionRadius()
Definition: Chute.cc:209
void set_zmax(Mdouble new_zmax)
Sets ymax and walls, assuming the standard definition of walls as in the default constructor.
Definition: MD.h:334
void make_chute_periodic()
This makes the chute periodic, in y.
Definition: Chute.h:74
Chute(HGRID_base &other)
Definition: Chute.h:55
void clean_chute()
Here we define the outflow.
Definition: Chute.cc:364
void set_InitialHeight(Mdouble new_)
Definition: Chute.h:159
Mdouble get_LightestParticleMass()
Returns the radius of the smallest particle.
Definition: Chute.cc:218
virtual void create_inflow_particle()
Sets variable values for particles that are created at the inflow.
Definition: Chute.cc:126
int readNextArgument(unsigned int &i, unsigned int argc, char *argv[])
Definition: Chute.cc:414
void set_InflowVelocity(Mdouble new_)
Changes inflow velocity.
Definition: Chute.h:146
void set_InflowVelocityVariance(Mdouble new_)
Changes inflow velocity variance.
Definition: Chute.h:153
void set_dt()
Sets dt to 1/50-th of the smallest possible collision time.
Definition: MD.h:447
int RandomizedBottom
Definition: Chute.h:251
Chute(HGRID_3D &other)
Definition: Chute.h:62
int max_failed
Definition: Chute.h:259
void actions_before_time_step()
This is action before the time step is started.
Definition: Chute.cc:107
Mdouble get_MinInflowParticleRadius()
Allows radius of inflow particles to be accessed.
Definition: Chute.h:134
Mdouble InflowVelocityVariance
Definition: Chute.h:257
BaseParticle * getLargestParticle()
Returns the smallest particle (by mass) in the system.
Definition: Chute.cc:189
void set_ChuteAngle(Mdouble new_)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.h:102
Mdouble get_restitution_coefficient()
Calculates restitution coefficient of two inflow particles.
Definition: Chute.cc:171
Mdouble get_InflowVelocityVariance()
Accesses inflow velocity variance.
Definition: Chute.h:157
int get_RandomizedBottom()
Accesses RandomizedBottom.
Definition: Chute.h:99
void set_max_failed(unsigned int new_)
Allows radius of fixed particles to be changed.
Definition: Chute.h:112
Mdouble get_InflowHeight()
Accesses inflow height.
Definition: Chute.h:143
void set_InflowHeight(Mdouble new_)
Changes inflow height.
Definition: Chute.h:139
virtual void add_particles()
Here we define the inflow.
Definition: Chute.cc:346
BaseParticle * getSmallestParticle()
Returns the smallest particle (by mass) in the system.
Definition: Chute.cc:178
Mdouble get_ymax()
Gets ymax.
Definition: MD.h:311
bool is_periodic
Definition: Chute.h:266
void set_dt()
Sets dt to 1/50-th of the collision time for two particles of mass P.
Definition: Chute.h:202
Mdouble get_InitialVelocityVariance()
Definition: Chute.h:179
void set_InflowParticleRadius(Mdouble new_min, Mdouble new_max)
Allows radius of inflow particles to be set to a range of values.
Definition: Chute.h:121
unsigned int get_max_failed()
Allows radius of fixed particles to be accessed.
Definition: Chute.h:114
Mdouble get_InflowVelocity()
Accesses inflow velocity.
Definition: Chute.h:150
int num_created
Definition: Chute.h:260
Chute adds three new effects to the HGrid: the gravity direction can be set using the ChuteAngle vari...
Definition: Chute.h:34
Mdouble get_ChuteWidth()
Definition: Chute.h:186
This adds on the hierarchical grid code for 3D problems.
Definition: HGRID_3D.h:35
Mdouble dt
These are numerical constants like the time step size.
Definition: MD.h:671
void set_InitialVelocityVariance(Mdouble new_)
Definition: Chute.h:175
Mdouble get_ChuteLength()
Definition: Chute.h:188
virtual void create_bottom()
Create the bottom of chute out of particles.
Definition: Chute.cc:254
Mdouble get_MaxInflowParticleRadius()
Allows radius of inflow particles to be accessed.
Definition: Chute.h:136
void set_RandomizedBottom(int new_)
Changes RandomizedBottom.
Definition: Chute.h:97
const Mdouble pi
Definition: ExtendedMath.h:54
double Mdouble
Definition: ExtendedMath.h:33
void setup_particles_initial_conditions()
initialize particle position, velocity, radius
Definition: Chute.cc:229
void set_ChuteWidth(Mdouble new_)
Access function that set the width of the chute.
Definition: Chute.h:185
virtual bool IsInsertable(BaseParticle &P)
here, CheckObjects is called; returns true is the particle should be added
Definition: Chute.cc:388
void initialize_inflow_particle()
Sets initial values for particles that are created at the inflow.
Definition: Chute.cc:113
void set_ymax(Mdouble new_ymax)
Sets ymax and walls, assuming the standard definition of walls as in the default constructor.
Definition: MD.h:331
TangentialSpringParticle P0
Definition: Chute.h:262
void set_InitialVelocity(Mdouble new_)
Definition: Chute.h:167
virtual void set_ChuteLength(Mdouble new_)
Definition: Chute.h:187
void add_particle(BaseParticle &P)
adds particle to hgrid
Definition: Chute.cc:96
void print(std::ostream &os, bool print_all=false)
This function std::couts all chute data.
Definition: Chute.cc:88
void constructor()
This is the actual constructor; it is called do both constructors above.
Definition: Chute.cc:30
void set_ChuteAngle(Mdouble new_, Mdouble gravity)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.h:104
Mdouble get_ChuteAngleDegrees()
Definition: Chute.h:109
A class that defines and solves a MD problem.
Definition: MD.h:70
void set_MaxInflowParticleRadius(Mdouble new_max)
Definition: Chute.h:128
void set_dt(Mdouble dt)
Sets dt.
Definition: Chute.h:204
Chute()
This is the default constructor. All it does is set sensible defaults.
Definition: Chute.h:38
void cout_time()
std::couts time
Definition: Chute.cc:148
Mdouble FixedParticleRadius
Definition: Chute.h:250
Mdouble ChuteAngle
Definition: Chute.h:252
Mdouble get_InflowParticleRadius()
Allows radius of inflow particles to be accessed.
Definition: Chute.h:132
Mdouble get_collision_time()
Calculates collision time of two inflow particles.
Definition: Chute.cc:165
Vec3D gravity
Gravitational acceleration.
Definition: MD.h:663
Mdouble MaxInflowParticleRadius
Definition: Chute.h:255
Mdouble InflowHeight
Definition: Chute.h:258
Chute(MD &other)
Copy-constructor for creates an HGRID problem from an existing MD problem.
Definition: Chute.h:48
void read(std::istream &is)
This function reads all chute data.
Definition: Chute.cc:46
Mdouble GetLength() const
Definition: Vector.h:248
bool get_IsPeriodic()
Get wether the chute is periodic.
Definition: Chute.h:77
Mdouble get_SmallestParticleInteractionRadius()
Returns the radius of the smallest particle.
Definition: Chute.cc:200
Mdouble get_xmax()
Get xmax.
Definition: MD.h:307
void set_gravity(Vec3D new_gravity)
Allows the gravitational acceleration to be changed.
Definition: MD.h:362
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:40
Vec3D get_gravity()
Allows the gravitational acceleration to be accessed.
Definition: MD.h:364
BaseParticle * get_P0()
Definition: Chute.h:211
Mdouble get_InitialHeight()
Definition: Chute.h:163
virtual void write(std::ostream &os)
This function writes all chute data.
Definition: Chute.cc:70
void set_FixedParticleRadius(Mdouble new_)
Allows radius of fixed particles to be changed.
Definition: Chute.h:92
void set_collision_time_and_restitution_coefficient(Mdouble tc, Mdouble eps)
Sets k, disp such that it matches a given tc and eps for a collision of two inflow particles...
Definition: Chute.cc:157
void set_InflowParticleRadius(Mdouble new_)
Allows radius of inflow particles to be changed.
Definition: Chute.h:117
void set_MinInflowParticleRadius(Mdouble new_min)
Definition: Chute.h:125
Mdouble get_ChuteAngle()
Gets chute angle (in radians)
Definition: Chute.h:108
void set_xmax(Mdouble new_xmax)
Sets xmax and walls, assuming the standard definition of walls as in the default constructor.
Definition: MD.h:328
Mdouble get_FixedParticleRadius()
Allows radius of fixed particles to be accessed.
Definition: Chute.h:94