MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChuteBottom.cc
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 
27 #include "ChuteBottom.h"
31 #include "Walls/InfiniteWall.h"
32 #include <Logger.h>
33 
38 {
39  constructor();
40 }
41 
50 : DPMBase(other), Chute(other)
51 {
52  constructor();
53 }
54 
63 : DPMBase(other), Chute(other)
64 {
65  constructor();
66 }
67 
76 : DPMBase(other), Chute(other)
77 {
78  constructor();
79 }
80 
89 : DPMBase(other), Chute(other)
90 {
91  constructor();
92 }
93 
99  : DPMBase(other), Chute(other),
100  thickness_(other.thickness_), isBottomPeriodic_(other.isBottomPeriodic_)
101 {
102 
103 }
104 
109 {
110  setName("roughbottom");
111  fStatFile.setFileType(FileType::NO_FILE); //set to 0 for no data creation
114  setThickness(2.4);
115  setIsBottomPeriodic(true);
116 }
117 
132 {
133  // set up mini-simulation with particle inflow on the left end and horizontal chute
134  // set all parameters that should be different from the original chute
135  setChuteAngle(0.0);
137  //~ setInflowHeight(45.*getInflowParticleRadius()); note: Changing the Inflow height was an attempt to make the bottom density homogeneous, but it did not have the desired effect
140 
141  auto species = dynamic_cast<LinearViscoelasticNormalSpecies*>(speciesHandler.getObject(0));
142  if (species!=nullptr)
143  {
144  //increase collision time, lower dissipation, increase timestep
146  Mdouble collisionTime= helpers::computeCollisionTimeFromKAndDispAndEffectiveMass(species->getStiffness(),speciesHandler.getObject(0)->getDensity(),effectiveMass);
147  species->setCollisionTimeAndRestitutionCoefficient(10.0*collisionTime,0.2,effectiveMass);
148  setTimeStep(10.0 * 0.02 * helpers::computeCollisionTimeFromKAndDispAndEffectiveMass(species->getStiffness(),speciesHandler.getObject(0)->getDensity(),effectiveMass));
150 // Mdouble effectiveMass = 0.5*speciesHandler.getObject(0)->getMassFromRadius(0.5 * (getMinInflowParticleRadius() + getMaxInflowParticleRadius()));
151 // Mdouble collisionTime = species->getCollisionTime(2.0*effectiveMass);
152 // species->setCollisionTimeAndRestitutionCoefficient(10.0*collisionTime,0.2,2.0*effectiveMass);
153 // setTimeStep(0.2*collisionTime);
154  }
155  else
156  {
157  logger(WARN,"[ChuteBottom::makeRoughBottom()] species type does not allow setting the parameters.");
158  }
159 
160  auto species2 = dynamic_cast<SlidingFrictionSpecies*>(speciesHandler.getObject(0));
161  if (species2 != nullptr)
162  species2->setSlidingFrictionCoefficient(0);
163 
164  // set the simulation to run for 2000 time steps
165  setTimeMax(getTimeStep() * 2e3);
166  //set_number_of_saves(2);
167  setSaveCount(100);
168 
169  // run the simulation
170  solve();
171 
172  //Find the Z-position of the highest particle in the system
173  Mdouble height = 0;
174  for (std::vector<BaseParticle*>::iterator it = particleHandler.begin(); it != particleHandler.end(); it++)
175  {
176  height = std::max(height, (*it)->getPosition().Z);
177  }
178 
179  // Next, all particles are removed from the system, except those with a Z-position s.t.:
180  // hmax = height - maxInflowParticleRadius_;
181  // hmax - thickness_ * maxInflowParticleRadius_ <= Z-position <= hmax
182  logger(INFO,"[ChuteBottom::makeRoughBottom()] Thickness: %",thickness_);
188  for (std::vector<BaseParticle*>::iterator it = particleHandler.begin(); it != particleHandler.end();)
189  {
190  if ((*it)->getPosition().Z < height - (1.0 + thickness_) * getMaxInflowParticleRadius() || (*it)->getPosition().Z > height - getMaxInflowParticleRadius())
191  {
192  //delete particles outside the given range
193  //*it = particleHandler.back();
194  //particleHandler.removeLastObject();
195  particleHandler.removeObject((*it)->getIndex());
196  }
197  else
198  {
199  // Move remaining particles to the floor
200  (*it)->move(Vec3D(0.0, 0.0, getMaxInflowParticleRadius() - height));
201 
202  // fix them to the bottom
203  (*it)->fixParticle();
204  it++;
205  }
206  }
207 
208  //copy the rough bottom over
210  logger(INFO,"[ChuteBottom::makeRoughBottom()] Chute bottom finished, consisting of % particles", particleHandler.getNumberOfObjects());
212 
220  for (BaseParticle* p : chute.particleHandler)
221  {
222  p->setSpecies(chute.speciesHandler.getObject(0));
223  }
224 
225 }
226 
232 {
233 
234  particleHandler.setStorageCapacity(static_cast<unsigned int>(std::min(3.0 * getXMax() * getYMax() * getZMax() / mathsFunc::cubic(2.0*getInflowParticleRadius()), 1e6)));
235 
236  createBottom();
237 
243  wallHandler.clear();
245  if (isBottomPeriodic_)
246  {
247  InfiniteWall w0;
248  w0.set(Vec3D(0.0, 0.0, -1.0), Vec3D(0, 0, getZMin() - getInflowParticleRadius()));
250  PeriodicBoundary b0;
251  b0.set(Vec3D(1.0, 0.0, 0.0), getXMin(), getXMax());
253  b0.set(Vec3D(0.0, 1.0, 0.0), getYMin(), getYMax());
255  }
256  else
257  {
258  InfiniteWall w0;
259  w0.set(Vec3D(0.0, 0.0, -1.0), Vec3D(0, 0, getZMin() - getInflowParticleRadius()));
261  w0.set(Vec3D(-1.0, 0.0, 0.0), Vec3D(getXMin(), 0, 0));
263  w0.set(Vec3D( 1.0, 0.0, 0.0), Vec3D(getXMax(), 0, 0));
265  w0.set(Vec3D(0.0,-1.0, 0.0), Vec3D(0, getYMin(), 0));
267  w0.set(Vec3D(0.0, 1.0, 0.0), Vec3D(0, getYMax(), 0));
269  }
270 
271  // add particles
278  int failed = 0, max_failed = 500;
279  //try max_failed times to find new insertable particle
280 
281  BaseParticle inflowParticle_;
282  inflowParticle_.setHandler(&particleHandler);
283  inflowParticle_.setOrientation(Vec3D(0.0, 0.0, 0.0));
284  inflowParticle_.setAngularVelocity(Vec3D(0.0, 0.0, 0.0));
285  while (failed <= max_failed)
286  {
287  inflowParticle_.setRadius(getFixedParticleRadius());
288  //inflowParticle_.computeMass();
289 
290  // The position components are first stored in a Vec3D, because if you pass
291  // them directly into setPosition the compiler is allowed to change the order
292  // in which the numbers are generated
293  Vec3D position;
294  position.X = random.getRandomNumber(inflowParticle_.getRadius(), getXMax() - inflowParticle_.getRadius());
295  position.Y = random.getRandomNumber(inflowParticle_.getRadius(), getYMax() - inflowParticle_.getRadius());
296  position.Z = random.getRandomNumber(2 * inflowParticle_.getRadius(), getZMax() - inflowParticle_.getRadius());
297  inflowParticle_.setPosition(position);
298  inflowParticle_.setVelocity(Vec3D(0.0, 0.0, 0.0));
299 
300 
301  if (checkParticleForInteraction(inflowParticle_))
302  {
303  particleHandler.copyAndAddObject(inflowParticle_);
304  failed = 0;
305  }
306  else
307  {
308  failed++;
309  }
310  }
311  //set_Nmax(particleHandler.getNumberOfObjects());
312  logger(INFO, "[ChuteBottom::setupInitialConditions()] Number of particles created: %", particleHandler.getNumberOfObjects());
313 
314  //fix hgrid (there is still an issue when particles are polydispersed)
315  //assume 1-2 levels are optimal (which is the case for mono and bidispersed) and set the cell size to min and max
316  // !this is not optimal for polydispersed
317  Mdouble minCell = 2. * std::min(getFixedParticleRadius(), getMinInflowParticleRadius());
318  Mdouble maxCell = 2. * std::max(getFixedParticleRadius(), getMaxInflowParticleRadius());
319  if ((minCell == maxCell) | (minCell == 0.))
321  else
323 // set_HGRID_cell_to_cell_ratio (1.0000000001*maxCell/minCell);
324  //optimize number of buckets
325  //setHGridNumberOfBucketsToPower(particleHandler.getNumberOfObjects() * 1.5);
326  //end: fix hgrid
327 
328  //~ write(std::cout,false);
329 }
330 
337 {
338 }
339 
346 {
347  return thickness_;
348 }
349 
356 {
357  if (new_ > 0.0)
358  thickness_ = new_;
359  else
360  {
361  logger(ERROR,"[ChuteBottom::setThickness()] thickness % negative.", new_);
362  exit(-1);
363  }
364 }
365 
371 {
372  return isBottomPeriodic_;
373 }
374 
379 void ChuteBottom::setIsBottomPeriodic(bool isBottomPeriodic)
380 {
381  isBottomPeriodic_ = isBottomPeriodic;
382 }
void setInflowHeight(Mdouble inflowHeight)
Sets maximum inflow height (Z-direction)
Definition: Chute.cc:799
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a periodic wall.
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
bool checkParticleForInteraction(const BaseParticle &P) override
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
Definition: MercuryBase.cc:609
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:61
Mdouble X
the vector components
Definition: Vector.h:52
ChuteBottom()
This is the default constructor. All it does is set sensible defaults.
Definition: ChuteBottom.cc:37
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
Definition: DPMBase.cc:179
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setOrientation(const Vec3D &orientation)
Sets the orientation of this BaseInteractable.
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.cc:259
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.cc:224
Mdouble getMassFromRadius(const Mdouble radius)
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this BaseHandler.
Definition: BaseHandler.h:476
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: Files.h:219
Used by Chute::createBottom to create an unordered particle layer.
Definition: ChuteBottom.h:39
void setHandler(ParticleHandler *handler)
Sets the pointer to the particle's ParticleHandler.
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.cc:238
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:494
double Mdouble
void setChuteAngle(Mdouble chuteAngle)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.cc:616
void setSpecies(const ParticleSpecies *species)
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
void setRoughBottomType(RoughBottomType roughBottomType)
Sets the type of rough bottom of the chute.
Definition: Chute.cc:567
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:482
Defines a pair of periodic walls. Inherits from BaseBoundary.
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:231
Mdouble getInflowParticleRadius() const
Returns the average radius of inflow particles.
Definition: Chute.cc:771
Mdouble getIsBottomPeriodic()
Returns TRUE if the bottom is periodic in Y.
Definition: ChuteBottom.cc:370
void constructor()
This is the actual constructor METHOD; it is called by all constructors above (except the default cop...
Definition: ChuteBottom.cc:108
Mdouble thickness_
Thickness of the multilayer chute rough bottom. See also documentation of ChuteBottom::makeRoughBotto...
Definition: ChuteBottom.h:122
Creates chutes with different bottoms. Inherits from Mercury3D (-> MercuryBase -> DPMBase)...
Definition: Chute.h:62
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
Definition: MercuryBase.h:74
Mdouble getMaxInflowParticleRadius() const
Returns the maximum radius of inflow particles.
Definition: Chute.cc:789
void makeRoughBottom(Chute &chute)
Makes a multilayered rough bottom with thickness thickness_.
Definition: ChuteBottom.cc:131
void setupInitialConditions()
Sets up initial conditions before running a chute simulation.
Definition: ChuteBottom.cc:231
file will not be created/read
LinearViscoelasticNormalSpecies contains the parameters used to describe a linear elastic-dissipative...
void setIsBottomPeriodic(bool isBottomPeriodic)
Sets whether the bottom should be periodic in Y.
Definition: ChuteBottom.cc:379
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:149
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:268
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:888
Mdouble getFixedParticleRadius() const
Returns the particle radius of the fixed particles which constitute the (rough) chute bottom...
Definition: Chute.cc:552
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
all data will be written into/ read from a single file called name_
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:415
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: Files.h:209
T cubic(T val)
calculates the cube of a number
Definition: ExtendedMath.h:99
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: Files.h:204
void setSlidingFrictionCoefficient(Mdouble new_mu)
Allows the (dynamic) Coulomb friction coefficient to be changed; also sets mu_s by default...
Mdouble getRadius() const
Returns the particle's radius_.
void setHGridMaxLevels(unsigned int HGridMaxLevels)
Sets the maximum number of levels of the HGrid in this MercuryBase.
Definition: MercuryBase.cc:500
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
Definition: BaseHandler.h:464
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
void hGridActionsBeforeTimeLoop() override
This sets up the broad phase information, has to be done at this stage because it requires the partic...
Definition: MercuryBase.cc:95
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:245
Mdouble Y
Definition: Vector.h:52
SlidingFrictionSpecies contains the parameters used to describe sliding friction. ...
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:209
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:883
void setFixedParticleRadius(Mdouble fixedParticleRadius)
Sets the particle radius of the fixed particles which constitute the (rough) chute bottom...
Definition: Chute.cc:540
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:873
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
virtual void createBottom()
Creates the chute bottom, which can be either flat or one of three flavours of rough.
Definition: Chute.cc:288
Mdouble getMinInflowParticleRadius() const
returns the minimum radius of inflow particles
Definition: Chute.cc:780
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
Definition: InfiniteWall.cc:70
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.cc:252
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
Definition: DPMBase.cc:353
This is a class defining walls.
Definition: InfiniteWall.h:43
Mdouble getThickness()
Returns the thickness of the multilayer rough bottom.
Definition: ChuteBottom.cc:345
Mdouble getDensity() const
Allows the density to be accessed.
void setThickness(Mdouble thickness)
Sets the thickness of the multilayer rough bottom.
Definition: ChuteBottom.cc:355
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
MERCURY_DEPRECATED Mdouble computeCollisionTimeFromKAndDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass)
Calculates the collision time for a given stiffness, dissipation, and effective mass.
Definition: Helpers.cc:41
Mdouble getTimeStep() const
Allows the time step dt to be accessed.
Definition: DPMBase.cc:368
Mdouble Z
Definition: Vector.h:52
void setAngularVelocity(const Vec3D &angularVelocity)
set the angular velocity of the BaseInteractble.
bool isBottomPeriodic_
TRUE if the bottom is periodic in Y.
Definition: ChuteBottom.h:127
virtual void removeObject(unsigned const int id)
Removes a BaseParticle from the ParticleHandler.
Mdouble getRandomNumber(Mdouble min, Mdouble max)
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:69
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
Definition: BaseHandler.h:360
void actionsBeforeTimeStep()
Performs all necessary actions before the start of a time step (none in this case) ...
Definition: ChuteBottom.cc:336