MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Chute.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 #include "Chute.h"
27 #include "ChuteBottom.h"
28 #include "Particles/BaseParticle.h"
31 #include "Walls/InfiniteWall.h"
32 #include <string>
33 #include <cstring>
34 #include <iomanip>
36 
37 #include <Logger.h>
38 
43 {
44  constructor();
45  logger(DEBUG, "[Chute::Chute()] constructor finished");
46 }
47 
55 Chute::Chute(const DPMBase& other)
56  : DPMBase(other), Mercury3D(other)
57 {
58  constructor();
59  logger(DEBUG, "[Chute::Chute(const DPMBase& other)] copy constructor finished");
60 }
61 
70  : DPMBase(other), Mercury3D(other)
71 {
72  constructor();
73  logger(DEBUG, "[Chute::Chute(const MercuryBase& other)] copy constructor finished");
74 }
75 
83 Chute::Chute(const Mercury3D& other)
84  : DPMBase(other), Mercury3D(other)
85 {
86  constructor();
87  logger(DEBUG, "[Chute::Chute(const Mercury3D& other) copy constructor finished");
88 }
89 
96 Chute::Chute(const Chute& other)
97  : DPMBase(other), Mercury3D(other),
98  chuteAngle_(other.chuteAngle_),
99  fixedParticleRadius_(other.fixedParticleRadius_),
100  minInflowParticleRadius_(other.minInflowParticleRadius_),
101  maxInflowParticleRadius_(other.maxInflowParticleRadius_),
102  inflowVelocity_(other.inflowVelocity_),
103  inflowVelocityVariance_(other.inflowVelocityVariance_),
104  inflowHeight_(other.inflowHeight_),
105  roughBottomType_(other.roughBottomType_),
106  maxFailed_(other.maxFailed_),
107  insertionBoundary_(other.insertionBoundary_),
108  isChutePeriodic_(other.isChutePeriodic_)
109 {
110  logger(DEBUG, "[Chute::Chute(const Chute& other)] copy constructor finished");
111 }
112 
119 {
120  insertionBoundary_ = nullptr;
121  isChutePeriodic_ = false;
122  setFixedParticleRadius(0.001);
124  setChuteAngle(0.0);
125 
126  setMaxFailed(1);
128  setInflowVelocity(0.1);
130  setInflowHeight(0.02);
131 }
132 
139 void Chute::read(std::istream& is, ReadOptions opt)
140 {
141  MercuryBase::read(is, opt);
142  //read out the full line first, so if there is an error it does not affect
143  //the read of the next line
144  std::string line_string;
145  std::getline(is, line_string);
146  std::cout << "Chuteline=" << line_string << std::endl;
147  std::stringstream line;
148  line << line_string;
149 
150  if (getRestartVersion() != "1") //Other versions..
151  {
152  std::string dummy;
153  unsigned int roughBottomType;
154  line >> fixedParticleRadius_
155  >> roughBottomType >> chuteAngle_
158  >> maxFailed_
159  >> dummy
160  >> inflowVelocity_
162  >> inflowHeight_;
163  setRoughBottomType(static_cast<RoughBottomType>(roughBottomType));
164  //if the Chute Angle is given in degrees, move to radians;
165  if (chuteAngle_ > 1.0)
166  {
167  logger(WARN, "Restartfile angle converted into radians from degrees! (% rad -> % deg)", chuteAngle_,
168  chuteAngle_ * constants::pi / 180.);
169  chuteAngle_ *= constants::pi / 180.;
170 
171  }
172  }
173  else //Version 1
174  {
175  std::string dummy;
176  unsigned int roughBottomType;
177  line >> dummy >> fixedParticleRadius_
178  >> dummy >> minInflowParticleRadius_
179  >> dummy >> maxInflowParticleRadius_
180  >> dummy >> roughBottomType
181  >> dummy >> chuteAngle_
182  >> dummy >> maxFailed_
183  >> dummy >> dummy
184  >> dummy >> inflowVelocity_
185  >> dummy >> inflowVelocityVariance_
186  >> dummy >> inflowHeight_;
187  setRoughBottomType(static_cast<RoughBottomType>(roughBottomType));
188  //This version always writes radians
189  }
190 
191 }
192 
206 void Chute::write(std::ostream& os, bool writeAllParticles) const
207 {
208  MercuryBase::write(os, writeAllParticles);
209  os << "FixedParticleRadius " << fixedParticleRadius_
210  << " MinInflowParticleRadius " << minInflowParticleRadius_
211  << " MaxInflowParticleRadius " << maxInflowParticleRadius_
212  << " RoughBottomType " << roughBottomType_
213  << " ChuteAngle " << chuteAngle_
214  << " MaxFailed " << maxFailed_
216  << " InflowVelocity " << inflowVelocity_
217  << " InflowVelocityVariance " << inflowVelocityVariance_
218  << " InflowHeight " << inflowHeight_ << std::endl;
219 }
220 
226 {
227  cleanChute();
228 }
229 
235 void Chute::printTime() const
236 {
237  std::cout << "\rt=" << std::setprecision(3) << std::left << std::setw(6)
238  << getTime()
239  << ", tmax=" << std::setprecision(3) << std::left << std::setw(6) << getTimeMax()
240  << ", N=" << std::setprecision(3) << std::left << std::setw(6)
242  << std::endl;
243  std::cout.flush();
244 }
245 
250 {
252  {
253  logger(FATAL, "[Chute::setupInitialConditions()] Chute % cannot "
254  "complete because no species have been defined.", getName());
255  }
256 
257  // create the chute's side walls in Y-direction
258  // (which are solid if the chute is not periodic)
259  setupSideWalls();
260 
261  // create a particle of which (altered) copies will fill the chute insertion
262  // boundary
263 
264 
265 
266  SphericalParticle* particleToInsert = new SphericalParticle;
267  // by default, insert particles of species 0
268  particleToInsert->setSpecies(speciesHandler.getObject(0));
270  {
271  particleToInsert->setSpecies(speciesHandler.getObject(0));
272  }
273  else
274  {
275  std::cerr << "There is not yet a species defined" << std::endl;
276  }
277 
278  // set up the insertion boundary and add to handler
280  b1.set(particleToInsert, maxFailed_,
281  Vec3D(getXMin(), getYMin(), getZMin()),
282  Vec3D(getXMax(), getYMax(), getZMax()),
285  );
287 
288  //creates the bottom of the chute
289  createBottom();
290 }
291 
297 {
298  // check if walls should be periodic or solid
299  if (isChutePeriodic_)
300  {
301  // create a periodic boundary with walls at yMin_ and yMax_.
302  PeriodicBoundary b0;
303  b0.set(Vec3D(0.0, 1.0, 0.0), getYMin(), getYMax());
305  }
306  else
307  {
308  // create two infinite solid walls; one at yMin_...
309  InfiniteWall w0;
311  w0.set(Vec3D(0.0, -1.0, 0.0), Vec3D(0, getYMin(), 0));
313  // ... and one at yMax_.
314  w0.set(Vec3D(0.0, 1.0, 0.0), Vec3D(0, getYMax(), 0));
316  }
317 }
318 
332 {
333  // smooth bottom:
334  if (fabs(getFixedParticleRadius()) < 1e-12 || roughBottomType_ == FLAT)
335  {
336  // flat wall as bottom
337  logger(INFO, "[Chute::createBottom()] create perfectly flat chute bottom");
338 
339  //bottom wall
340  InfiniteWall w0;
342  w0.set(Vec3D(0.0, 0.0, -1.0), Vec3D(0, 0, getZMin()));
344  }
345  else //rough bottom
346  {
347  // Define standard fixed particle
357  F0.setPosition(Vec3D(0.0, 0.0, 0.0));
358  F0.setVelocity(Vec3D(0.0, 0.0, 0.0));
359 
361  {
362  // grid-like fixed-particle bottom
363  logger(INFO, "[Chute::createBottom()] create monolayered, ordered rough chute bottom");
364 
365  // allowed space for each particle in each direction
366  Mdouble dx = 2.0 * F0.getRadius();
367  Mdouble dy = 2.0 * F0.getRadius();
368 
369  // number of particles that fit in each direction
370  unsigned int nx = static_cast<unsigned int>(std::max(1, static_cast<int>(std::floor(
371  (getXMax() - getXMin()) / dx))));
372  unsigned int ny = static_cast<unsigned int>(std::max(1, static_cast<int>(std::floor(
373  (getYMax() - getYMin()) / dy))));
374 
375  // adjust particle spacing (in case total space available in given direction
376  // is not a multiple of 2*F0.getRadius() )
377  dx = (getXMax() - getXMin()) / nx;
378  dy = (getYMax() - getYMin()) / ny;
379 
380  for (unsigned int i = 0; i < nx; i++)
381  {
382  for (unsigned int j = 0; j < ny; j++)
383  {
384  // placing of particles on rectangular grid points
385  F0.setPosition(Vec3D(F0.getRadius() + dx * i, F0.getRadius() + dy * j, 0.0));
387  }
388  }
389 
390  //bottom wall, to make sure no particles will fall through the gaps
391  InfiniteWall w0;
393  w0.set(Vec3D(0.0, 0.0, -1.0), Vec3D(0, 0, getZMin() - dx));
395  }
397  {
398  // random fixed-particle bottom
399  logger(INFO, "[Chute::createBottom()] create monolayered disordered rough chute bottom");
400 
401  Vec3D position;
402  position.X = random.getRandomNumber(F0.getRadius(), getXMax() - F0.getRadius());
403  position.Y = random.getRandomNumber(getYMin() + F0.getRadius(), getYMax() - F0.getRadius());
404  F0.setPosition(position);
406 
409 
410  //now add more particles
411  int failed = 0;
412  while (failed < 500)
413  {
414  //The position components are first stored in a Vec3D, because
415  //if you pass them directly into setPosition the compiler is
416  //allowed to change the order in which the numbers are generated
417  position.X = random.getRandomNumber(F0.getRadius(), getXMax() - F0.getRadius());
418  position.Y = random.getRandomNumber(getYMin() + F0.getRadius(), getYMax() - F0.getRadius());
419  F0.setPosition(position);
421  {
423  failed = 0;
424  }
425  else
426  {
427  failed++;
428  }
429  }
430 
431  //bottom wall (create after particle creation, as
432  //checkParticleForInteraction also checks against walls)
433  InfiniteWall w0;
435  w0.set(Vec3D(0.0, 0.0, -1.0), Vec3D(0, 0, getZMin() - .5 * F0.getRadius()));
437  }
438  else //if (roughBottomType_ == MULTILAYER)
439  {
440  // multilayered particle bottom
441  logger(INFO, "[Chute::createBottom()] create multilayered rough chute bottom");
442 
443  //'this' points to the current Chute object, the class of which is inherited
444  // by the ChuteBottom class. I.e., the bottom is created with the particle
445  // properties from the current class.
446  // ChuteBottom::makeRoughBottom() creates a randomly filled, multilayered
447  // chute bottom.
448  ChuteBottom bottom(*this);
450  bottom.makeRoughBottom(*this);
451 
452  //bottom wall
453  InfiniteWall w0;
455  w0.set(Vec3D(0.0, 0.0, -1.0), Vec3D(0, 0, getZMin() - bottom.getThickness()));
457  }
458  //finally, fix particles to the bottom
459  for (BaseParticle* const p : particleHandler)
460  {
461  p->fixParticle();
462  }
463  }
464 }
465 
473 {
474  //clean outflow every 100 time steps
475  static int count = 0, maxcount = 100; // please note: static variables are only initialised once, and their values
476  // are stored even after the method returns. I.e., next time the method is
477  // called, the initialisation is ignored and the previously assigned value is used.
478  if (count > maxcount)
479  {
480  // reset counter
481  count = 0;
482 
483  // check all particles
484  for (unsigned int i = 0; i < particleHandler.getNumberOfObjects();)
485  {
486  // check if particle is outside the problem window
489  getXMin()) //||particleHandler.getObject(i)->Position.Z+particleHandler.getObject(i)->Radius<zMin_)
490  {
491  // if so, delete the particle
492  logger(DEBUG, "[Chute::cleanChute()] erased: %", particleHandler.getObject(i));
494  }
495  else
496  {
497  i++;
498  }
499  }
500  }
501  else
502  {
503  count++;
504  }
505 }
506 
518 bool Chute::readNextArgument(int& i, int argc, char* argv[])
519 {
520  if (!strcmp(argv[i], "-inflowHeight"))
521  {
522  setInflowHeight(atof(argv[i + 1]));
523  setZMax(atof(argv[i + 1]));
524  }
525  else if (!strcmp(argv[i], "-inflowVelocity"))
526  {
527  setInflowVelocity(atof(argv[i + 1]));
528  }
529  else if (!strcmp(argv[i], "-chuteAngle"))
530  {
531  setChuteAngle(atof(argv[i + 1]));
532  }
533  else if (!strcmp(argv[i], "-chuteLength"))
534  {
535  setChuteLength(atof(argv[i + 1]));
536  }
537  else if (!strcmp(argv[i], "-chuteWidth"))
538  {
539  setChuteWidth(atof(argv[i + 1]));
540  }
541  else if (!strcmp(argv[i], "-fixedParticleRadius"))
542  {
543  setFixedParticleRadius(atof(argv[i + 1]));
544  }
545  else if (!strcmp(argv[i], "-max_failed"))
546  {
547  setMaxFailed(static_cast<unsigned int>(atoi(argv[i + 1])));
548  }
549  else if (!strcmp(argv[i], "-inflowParticleRadiusRange"))
550  {
551  setInflowParticleRadius(atof(argv[i + 1]), atof(argv[i + 2]));
552  i++;
553  }
554  else if (!strcmp(argv[i], "-inflowParticleRadius"))
555  {
556  setInflowParticleRadius(atof(argv[i + 1]));
557  }
558  else if (!strcmp(argv[i], "-roughBottomType"))
559  {
560  std::string str(argv[i + 1]);
561  setRoughBottomType(str);
562  }
563 // else if (!strcmp(argv[i], "-k_eps"))
564 // {
565 // Mdouble Mass = getLightestParticleMass();
566 // //~ Mdouble Mass = particleHandler.get_LightestParticle()->getMass();
567 // speciesHandler.getObject(0)->setStiffnessAndRestitutionCoefficient(atof(argv[i + 1]), atof(argv[i + 2]), Mass);
568 // std::cout << "reset contact properties of lightest Particle (mass=" << Mass << ") to k=" << speciesHandler.getObject(0)->getStiffness() << " and dissipation_=" << speciesHandler.getObject(0)->getDissipation() << std::endl;
569 // i += 1;
570 // }
571 // else if (!strcmp(argv[i], "-tc_eps"))
572 // {
573 // Mdouble Mass = getLightestParticleMass();
574 // speciesHandler.getObject(0)->setCollisionTimeAndRestitutionCoefficient(atof(argv[i + 1]), atof(argv[i + 2]), Mass);
575 // std::cout << "reset contact properties of lightest Particle (mass=" << Mass << ") to k=" << speciesHandler.getObject(0)->getStiffness() << " and dissipation_=" << speciesHandler.getObject(0)->getDissipation() << std::endl;
576 // i += 1;
577 // }
578 // else if (!strcmp(argv[i], "-tc_eps_beta"))
579 // {
580 // Mdouble Mass = getLightestParticleMass();
581 // FrictionalSpecies* S = dynamic_cast<FrictionalSpecies*>(speciesHandler.getObject(0));
582 // S->setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(atof(argv[i + 1]), atof(argv[i + 2]), atof(argv[i + 3]), Mass);
583 // std::cout << "reset contact properties of lightest Particle (mass=" << Mass << ") to k=" << S->getStiffness() << ", dissipation_=" << S->getDissipation() << ", kt=" << S->getSlidingStiffness() << " and dispt=" << S->getSlidingDissipation() << std::endl;
584 // i += 2;
585 // }
586  else
587  return Mercury3D::readNextArgument(i, argc, argv); //if argv[i] is not found, check the commands in Mercury3D
588  return true; //returns true if argv[i] is found
589 }
590 
596 {
597  isChutePeriodic_ = true;
598 }
599 
606 {
607  return isChutePeriodic_;
608 }
609 
616 void Chute::setFixedParticleRadius(Mdouble fixedParticleRadius)
617 {
618  if (fixedParticleRadius >= 0.0)
619  {
620  fixedParticleRadius_ = fixedParticleRadius;
621  }
622  else
623  {
624  logger(WARN, "[Chute::setFixedParticleRadius()] Fixed particle radius "
625  "must be greater than or equal to zero.");
626  }
627 }
628 
635 {
636  return fixedParticleRadius_;
637 }
638 
650 {
651  roughBottomType_ = roughBottomType;
652 }
653 
658 void Chute::setRoughBottomType(std::string roughBottomTypeString)
659 {
660  if (!roughBottomTypeString.compare("MONOLAYER_ORDERED"))
661  {
663  }
664  else if (!roughBottomTypeString.compare("MONOLAYER_DISORDERED"))
665  {
667  }
668  else if (!roughBottomTypeString.compare("MULTILAYER"))
669  {
671  }
672  else if (roughBottomTypeString == "FLAT")
673  {
675  }
676  else
677  {
678  logger(FATAL, "[Chute::setRoughBottomType(std::string)] Invalid "
679  "argument in setRoughBottomType. Given: %",
680  roughBottomTypeString);
681  }
682 }
683 
690 {
691  return roughBottomType_;
692 }
693 
704 {
705  // retrieve the magnitude of gravity
706  Mdouble gravity = getGravity().getLength();
707  if (gravity == 0)
708  {
709  logger(WARN, "[Chute::setChuteAngle()] zero gravity");
710  }
711 
712  // reset the gravity vector, with the given angle
713  setChuteAngleAndMagnitudeOfGravity(chuteAngle, gravity);
714 }
715 
725 {
726  if (chuteAngle >= -90.0 && chuteAngle <= 90.0)
727  {
728  chuteAngle_ = chuteAngle * constants::pi / 180.0;
729  setGravity(Vec3D(sin(chuteAngle_), 0.0, -cos(chuteAngle_)) * gravity);
730  }
731  else
732  {
733  logger(WARN, "[Chute::setChuteAngleAndMagnitudeOfGravity()] Chute "
734  "angle must be within [-90,90]");
735  }
736 }
737 
743 {
744  return chuteAngle_;
745 }
746 
752 {
753  return chuteAngle_ * 180.0 / constants::pi;
754 }
755 
762 void Chute::setMaxFailed(unsigned int maxFailed)
763 {
764  maxFailed_ = maxFailed;
765 }
766 
772 unsigned int Chute::getMaxFailed() const
773 {
774  return maxFailed_;
775 }
776 
783 void Chute::setInflowParticleRadius(Mdouble inflowParticleRadius)
784 {
785  if (inflowParticleRadius >= 0.0)
786  {
787  minInflowParticleRadius_ = inflowParticleRadius;
788  maxInflowParticleRadius_ = inflowParticleRadius;
789  }
790  else
791  {
792  logger(WARN, "[Chute::setInflowParticleRadius(Mdouble)] Inflow "
793  "particle must be greater than or equal to zero");
794  }
795 }
796 
802 void Chute::setInflowParticleRadius(Mdouble minInflowParticleRadius,
803  Mdouble maxInflowParticleRadius)
804 {
805  if (minInflowParticleRadius >= 0.0)
806  {
807  minInflowParticleRadius_ = minInflowParticleRadius;
808  }
809  else
810  {
811  logger(WARN, "[Chute::setInflowParticleRadius(Mdouble,Mdouble)] Min."
812  "inflow particle radius must be nonnegative");
813  }
814  if (maxInflowParticleRadius >= minInflowParticleRadius)
815  {
816  maxInflowParticleRadius_ = maxInflowParticleRadius;
817  }
818  else
819  {
820  logger(WARN, "[Chute::setInflowParticleRadius(Mdouble,Mdouble)] Max."
821  " inflow particle radius must be >= min. inflow particle "
822  "radius");
823  }
824 }
825 
830 void Chute::setMinInflowParticleRadius(Mdouble minInflowParticleRadius)
831 {
832  if (minInflowParticleRadius <= maxInflowParticleRadius_)
833  {
834  minInflowParticleRadius_ = minInflowParticleRadius;
835  }
836  else
837  {
838  logger(WARN, "[Chute::setMinInflowParticleRadius()] Min. inflow particle"
839  " radius must be <= max. inflow particle radius");
840  }
841 }
842 
847 void Chute::setMaxInflowParticleRadius(Mdouble maxInflowParticleRadius)
848 {
849  if (maxInflowParticleRadius >= minInflowParticleRadius_)
850  {
851  maxInflowParticleRadius_ = maxInflowParticleRadius;
852  }
853  else
854  {
855  logger(WARN, "[Chute::setMaxInflowParticleRadius()] Max. inflow particle"
856  " radius must be >= min. inflow particle radius");
857  }
858 }
859 
865 {
867 }
868 
874 {
876 }
877 
883 {
885 }
886 
892 void Chute::setInflowHeight(Mdouble inflowHeight)
893 {
894  //if (inflowHeight >= minInflowParticleRadius_ + maxInflowParticleRadius_)
895  {
896  inflowHeight_ = inflowHeight;
897  setZMax(1.2 * inflowHeight_);
898  }
899 // else
900 // {
901 // std::cerr << "WARNING : Inflow height not changed to " << inflowHeight << ", value must be greater than or equal to diameter of inflow particle" << std::endl;
902 // }
903 }
904 
910 {
911  return inflowHeight_;
912 }
913 
918 void Chute::setInflowVelocity(Mdouble inflowVelocity)
919 {
920  if (inflowVelocity >= 0.0)
921  {
922  inflowVelocity_ = inflowVelocity;
923  }
924  else
925  {
926  logger(WARN, "[Chute::setInflowVelocity()] Inflow velocity not changed, "
927  "value must be greater than or equal to zero");
928  }
929 }
930 
936 {
937  return inflowVelocity_;
938 }
939 
945 void Chute::setInflowVelocityVariance(Mdouble inflowVelocityVariance)
946 {
947  if (inflowVelocityVariance >= 0.0 && inflowVelocityVariance <= 1.0)
948  {
949  inflowVelocityVariance_ = inflowVelocityVariance;
950  }
951  else
952  {
953  logger(ERROR, "[Chute::setInflowVelocityVariance()] Inflow velocity "
954  "variance not changed, value must be within [0,1]");
955  exit(-1);
956  }
957 }
958 
965 {
967 }
968 
975 {
976  setYMax(chuteWidth);
977 }
978 
985 {
986  return getYMax();
987 }
988 
995 {
996  setXMax(chuteLength);
997 }
998 
1005 {
1006  return getXMax();
1007 }
1008 
1014 {
1015  insertionBoundary_ = insertionBoundary;
1016 }
1017 
1019 {
1020  logger(INFO, "Adding flowing particles");
1024  setZMax(1.2 * getInflowHeight());
1025  while (particleHandler.getSize() < N)
1026  {
1029  {
1031  }
1032  else
1033  {
1035  }
1036  }
1037  logger(DEBUG, "InflowHeight = %", getInflowHeight());
1038 }
1039 
1041 {
1042  SphericalParticle p0;
1048  getInflowHeight())));
1049  p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
1050  return p0;
1051 }
void setInflowVelocity(Mdouble inflowVelocity)
Sets the average inflow velocity.
Definition: Chute.cc:918
void setInflowHeight(Mdouble inflowHeight)
Sets maximum inflow height (Z-direction)
Definition: Chute.cc:892
void actionsBeforeTimeStep() override
Calls Chute::cleanChute().
Definition: Chute.cc:225
RoughBottomType
enum for determining the type of rough bottom (if any) of the chute. Either of the enum options can b...
Definition: Chute.h:51
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
virtual SphericalParticle createFlowParticle()
Definition: Chute.cc:1040
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction. ...
Definition: DPMBase.cc:1126
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:72
Mdouble X
the vector components
Definition: Vector.h:65
void removeObject(unsigned int index) override
Removes a BaseParticle from the ParticleHandler.
void setChuteAngleAndMagnitudeOfGravity(Mdouble chuteAngle, Mdouble gravity)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.cc:724
A basic particle.
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
unsigned int maxFailed_
indicates how many attempts are made to insert a new particle into the insertion boundary before the ...
Definition: Chute.h:352
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
void setChuteWidth(Mdouble chuteWidth)
Sets the chute width (Y-direction)
Definition: Chute.cc:974
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
Mdouble minInflowParticleRadius_
minimal radius of inflowing particles
Definition: Chute.h:326
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:617
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:586
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this BaseHandler.
Definition: BaseHandler.h:669
bool isChutePeriodic_
Determines whether the chute has periodic (TRUE) or solid (FALSE) walls in the Y-direction.
Definition: Chute.h:361
void setMaxFailed(unsigned int maxFailed)
Sets the number of times a particle will be tried to be added to the insertion boundary.
Definition: Chute.cc:762
Mdouble getInflowVelocityVariance() const
Returns the inflow velocity variance.
Definition: Chute.cc:964
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
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.h:599
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:389
bool readNextArgument(int &i, int argc, char *argv[]) override
This method can be used for reading object properties from a string.
Definition: Chute.cc:518
void setMaxInflowParticleRadius(Mdouble maxInflowParticleRadius)
Sets the maximum radius of inflow particles.
Definition: Chute.cc:847
Mdouble getChuteLength() const
Returns the chute length (X-direction)
Definition: Chute.cc:1004
void setZMax(Mdouble newZMax)
Sets the value of ZMax, the upper bound of the problem domain in the z-direction. ...
Definition: DPMBase.cc:1178
void setChuteAngle(Mdouble chuteAngle)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.cc:703
void setSpecies(const ParticleSpecies *species)
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:113
void hGridActionsBeforeTimeStep() override
Performs all necessary actions before a time-step, like updating the particles and resetting all the ...
Definition: MercuryBase.cc:317
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1343
Definition: Chute.h:53
Boundary structure for boundaries used for insertion of particles.
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:331
void setRoughBottomType(RoughBottomType roughBottomType)
Sets the type of rough bottom of the chute.
Definition: Chute.cc:649
Mdouble getChuteAngleDegrees() const
Returns the chute angle (in degrees)
Definition: Chute.cc:751
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
Defines a pair of periodic walls. Inherits from BaseBoundary.
Mdouble getInflowVelocity() const
Returns the average inflow velocity.
Definition: Chute.cc:935
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:593
Mdouble getInflowParticleRadius() const
Returns the average radius of inflow particles.
Definition: Chute.cc:864
RoughBottomType getRoughBottomType() const
Returns the type of (rough) bottom of the chute.
Definition: Chute.cc:689
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction. ...
Definition: DPMBase.cc:1152
bool checkParticleForInteraction(const BaseParticle &P) final
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
Definition: MercuryBase.cc:588
Creates chutes with different bottoms. Inherits from Mercury3D (-> MercuryBase -> DPMBase)...
Definition: Chute.h:64
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
Definition: MercuryBase.h:125
Mdouble getMaxInflowParticleRadius() const
Returns the maximum radius of inflow particles.
Definition: Chute.cc:882
void setupInitialConditions() override
Creates bottom, side walls and a particle insertion boundary.
Definition: Chute.cc:249
void makeRoughBottom(Chute &chute)
Makes a multilayered rough bottom with thickness thickness_.
Definition: ChuteBottom.cc:139
bool getIsPeriodic() const
Returns whether the chute is periodic in Y.
Definition: Chute.cc:605
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44
void write(std::ostream &os, bool writeAllParticles=true) const override
Writes the MercuryBase to an output stream, for example a restart file.
Definition: MercuryBase.cc:146
const Mdouble pi
Definition: ExtendedMath.h:45
virtual void addFlowParticlesCompactly()
Add initial flow particles in a dense packing.
Definition: Chute.cc:1018
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1344
Mdouble getChuteWidth() const
Returns the chute width (Y-direction)
Definition: Chute.cc:984
Mdouble getFixedParticleRadius() const
Returns the particle radius of the fixed particles which constitute the (rough) chute bottom...
Definition: Chute.cc:634
Mdouble getThickness() const
Returns the thickness of the multilayer rough bottom.
Definition: ChuteBottom.cc:343
unsigned int getNumberOfParticlesInserted() const
Gets the number of particles inserted by the boundary.
void setupSideWalls()
Creates chute side walls (either solid or periodic)
Definition: Chute.cc:296
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:36
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
bool readNextArgument(int &i, int argc, char *argv[]) override
Reads the next command line argument.
Definition: MercuryBase.cc:396
RoughBottomType roughBottomType_
Determines the type of rough bottom created (if any). See also the enum RoughBottomType at the beginn...
Definition: Chute.h:347
Vec3D getGravity() const
Returns the gravitational acceleration.
Definition: DPMBase.cc:1351
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
void read(std::istream &is, ReadOptions opt=ReadOptions::ReadAll) override
Reads all chute properties from an istream.
Definition: Chute.cc:139
void setInsertionBoundary(InsertionBoundary *insertionBoundary)
Sets the chute insertion boundary.
Definition: Chute.cc:1013
void setInflowParticleRadius(Mdouble inflowParticleRadius)
Sets the radius of the inflow particles to a single one (i.e. ensures a monodisperse inflow)...
Definition: Chute.cc:783
void setInflowVelocityVariance(Mdouble inflowVelocityVariance)
Sets the inflow velocity variance.
Definition: Chute.cc:945
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:345
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles) ...
Definition: BaseHandler.h:648
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
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:94
void constructor()
This is the actual constructor METHOD; it is called by all constructors above (except the default cop...
Definition: Chute.cc:118
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:605
Mdouble Y
Definition: Vector.h:65
Mdouble getChuteAngle() const
Returns the chute angle (in radians)
Definition: Chute.cc:742
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1339
void setFixedParticleRadius(Mdouble fixedParticleRadius)
Sets the particle radius of the fixed particles which constitute the (rough) chute bottom...
Definition: Chute.cc:616
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1324
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:331
void cleanChute()
Deletes all outflow particles once every 100 time steps.
Definition: Chute.cc:472
void setMinInflowParticleRadius(Mdouble minInflowParticleRadius)
sets the minimum radius of inflow particles
Definition: Chute.cc:830
Chute()
This is the default constructor. All it does is set sensible defaults.
Definition: Chute.cc:42
Mdouble getMinInflowParticleRadius() const
returns the minimum radius of inflow particles
Definition: Chute.cc:873
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...
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:611
void write(std::ostream &os, bool writeAllParticles=true) const override
This function writes the Chute properties to an ostream, and adds the properties of ALL chute particl...
Definition: Chute.cc:206
virtual void setChuteLength(Mdouble chuteLength)
Sets the chute length (X-direction)
Definition: Chute.cc:994
Mdouble inflowVelocity_
Average inflow velocity in x-direction.
Definition: Chute.h:334
Used for modeling chute inflow. Inherits from InsertionBoundary.
This is a class defining walls.
Definition: InfiniteWall.h:47
Mdouble inflowHeight_
Height of inflow.
Definition: Chute.h:342
Definition: Vector.h:49
InsertionBoundary * insertionBoundary_
(Pointer to) the Chute's insertion boundary
Definition: Chute.h:356
Mdouble chuteAngle_
chute angle in degrees
Definition: Chute.h:318
void read(std::istream &is, ReadOptions opt=ReadOptions::ReadAll) override
Reads the MercuryBase from an input stream, for example a restart file.
Definition: MercuryBase.cc:104
void set(BaseParticle *particleToCopy, unsigned int maxFailed, Vec3D posMin, Vec3D posMax, double radMin, double radMax, double fixedParticleRadius, double inflowVelocity, double inflowVelocityVariance)
Sets all boundary properties at once.
void printTime() const override
prints time, max time and number of particles
Definition: Chute.cc:235
Mdouble fixedParticleRadius_
radius of the fixed particles at the bottom
Definition: Chute.h:322
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:797
Mdouble inflowVelocityVariance_
Inflow velocity variance in x-direction (in ratio of inflowVelocity_)
Definition: Chute.h:338
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:855
void makeChutePeriodic()
This makes the chute periodic in Y.
Definition: Chute.cc:595
Mdouble getInflowHeight() const
Returns the maximum inflow height (Z-direction)
Definition: Chute.cc:909
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:171
ReadOptions
Definition: DPMBase.h:240
unsigned int getMaxFailed() const
Returns the number of times a particle will be tried to be added to the insertion boundary...
Definition: Chute.cc:772
std::string getRestartVersion() const
This is to take into account for different Mercury versions. Returns the version of the restart file...
Definition: DPMBase.cc:1435
Mdouble maxInflowParticleRadius_
maximal radius of inflowing particles
Definition: Chute.h:330