MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MercuryBase.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 #include <limits>
27 #include <string.h>
28 
29 #include "MercuryBase.h"
30 #include "Math/Helpers.h"
31 #include "Particles/BaseParticle.h"
32 #include "Walls/BaseWall.h"
33 
35 {
36  constructor();
37  logger(DEBUG, "MercuryBase::MercuryBase() constructor finished");
38 }
39 
41 {
42  if (grid != nullptr)
43  {
44  delete grid;
45  grid = nullptr;
46  }
47  logger(DEBUG, "MercuryBase::~MercuryBase() destructor finished.");
48 }
49 
59 {
60  grid = nullptr;
61  gridNeedsUpdate_ = true;
62 
63  hGridMethod_ = mercuryBase.hGridMethod_;
65 
68 
70  hGridMaxLevels_ = mercuryBase.hGridMaxLevels_;
72 
73  logger(DEBUG, "HGRID_base(HGrid_base& other) constructor finished.");
74 }
75 
81 {
82  grid = nullptr;
83  gridNeedsUpdate_ = true;
84  hGridMaxLevels_ = 3;
86  updateEachTimeStep_ = true;
89 }
90 
96 {
97 }
98 
105 void MercuryBase::read(std::istream& is)
106 {
107  DPMBase::read(is);
108 
109  std::stringstream line(std::stringstream::in | std::stringstream::out);
111 
112  std::string dummy;
113 
114  line >> dummy >> dummy
115  >> dummy >> hGridMaxLevels_
116  >> dummy >> hGridCellOverSizeRatio_;
117 }
118 
132 void MercuryBase::write(std::ostream& os, bool writeAllParticles) const
133 {
134  DPMBase::write(os, writeAllParticles);
135  if (grid != nullptr)
136  {
137  os << "NUM_BUCKETS " << grid->getNumberOfBuckets() << " "
138  << "hGridMaxLevels " << getHGridMaxLevels() << " "
139  << "cellOverSizeRatio " << getHGridCellOverSizeRatio() << std::endl;
140  }
141  else
142  {
143  os << "NUM_BUCKETS " << 0.0 << " "
144  << "hGridMaxLevels " << getHGridMaxLevels() << " "
145  << "cellOverSizeRatio " << getHGridCellOverSizeRatio() << std::endl;
146  }
147 }
148 
155 {
157 }
158 
164 {
166 }
167 
172 void MercuryBase::setHGridUpdateEachTimeStep(bool updateEachTimeStep)
173 {
174  updateEachTimeStep_ = updateEachTimeStep;
175 }
176 
181 {
182  return updateEachTimeStep_;
183 }
184 
200 void
202 {
203 
204  std::vector<Mdouble> cellSizes;
205 
206  const Mdouble minParticleInteractionRadius = getHGridTargetMinInteractionRadius();
207  const Mdouble maxParticleInteractionRadius = getHGridTargetMaxInteractionRadius();
208  if(minParticleInteractionRadius == 0.0 || minParticleInteractionRadius == maxParticleInteractionRadius)
209  {
210  //this case is executed if the particleHandler is empty (minParticleInteractionRadius == 0)
211  //or if the particle distribution is monodispersed.
212  //nextafter(d,std::numeric_limits<Mdouble>::max()) chooses the smallest
213  // Mdouble that is bigger than d.
214  const Mdouble maxCellSize = nextafter(2.0 * maxParticleInteractionRadius * getHGridCellOverSizeRatio(), std::numeric_limits<Mdouble>::max());
215  cellSizes.push_back(maxCellSize);
216  if(getHGridMaxLevels() != 1)
217  {
218  logger(DEBUG, "While rebuilding the hgrid: the number of levels was "
219  "set to one, as the particle distribution is monodispersed");
220  }
221  }
222  else
223  {
224  switch(getHGridDistribution())
225  {
226  case LINEAR:
227  {
228  const Mdouble minCellSize = nextafter(2.0 * minParticleInteractionRadius * getHGridCellOverSizeRatio(), 0.0);
229  const Mdouble maxCellSize = nextafter(2.0 * maxParticleInteractionRadius * getHGridCellOverSizeRatio(), std::numeric_limits<Mdouble>::max());
230  //std::cout << "HGrid: using a linear cell size distribution from " << minCellSize << " to " << maxCellSize << " over " << getHGridMaxLevels() << " levels" << std::endl;
231  for(unsigned int i = 0; i + 1 < getHGridMaxLevels(); i++)
232  {
233  cellSizes.push_back(minCellSize + (maxCellSize - minCellSize)
234  * (static_cast<Mdouble>(i + 1)) / getHGridMaxLevels());
235  }
236  //The last cell is added separately because in some cases accuracy was lost when calculating it.
237  cellSizes.push_back(maxCellSize);
238  break;
239  }
240  case EXPONENTIAL:
241  {
242  const Mdouble minCellSize = nextafter(2.0 * minParticleInteractionRadius * getHGridCellOverSizeRatio(), 0.0);
243  const Mdouble maxCellSize = nextafter(2.0 * maxParticleInteractionRadius * getHGridCellOverSizeRatio(), std::numeric_limits<Mdouble>::max());
244  //std::cout << "HGrid: using an exponential cell size distribution from " << minCellSize << " to " << maxCellSize << " over " << getHGridMaxLevels() << " levels" << std::endl;
245  for(unsigned int i = 0; i + 1 < getHGridMaxLevels(); i++)
246  {
247  cellSizes.push_back(minCellSize
248  * std::pow(maxCellSize / minCellSize, static_cast<Mdouble>(i + 1)
249  / getHGridMaxLevels()));
250  }
251  //The last cell is added separately because in some cases accuracy was lost when calculating it.
252  cellSizes.push_back(maxCellSize);
253  break;
254  }
255  case USER:
256  {
257  for(unsigned int i = 0; i < getHGridMaxLevels(); i++)
258  {
259  cellSizes.push_back(userHGridCellSize(i));
260  }
261  break;
262  }
263  case OLDHGRID:
264  {
265  const Mdouble minCellSize = nextafter(2.0 * minParticleInteractionRadius * getHGridCellOverSizeRatio(), 0.0);
266 
267  //std::cout<<"HGrid: using the old HGrid cell size distribution starting from " <<minCellSize<<std::endl;
268  for(unsigned int i = 0; i < getHGridMaxLevels(); i++)
269  {
270  cellSizes.push_back(minCellSize * std::pow(2, i));
271  }
272  break;
273  }
274  }
275  }
276 
277  if(grid != nullptr)
278  {
279  delete grid;
280  }
281 
283 
284  for(BaseParticle* const p: particleHandler)
285  {
287  //\todo{This is really ugly fix to force the particle to update}
288  (p)->setHGridX(9999);
290  }
291  gridNeedsUpdate_ = false;
292 }
293 
298 {
299  if (grid != nullptr)
300  {
302  }
303 }
304 
305 #ifdef CONTACT_LIST_HGRID
307 {
308 }
309 #else
310 
315 {
317 }
318 #endif
319 
325 {
327  static int stepsBeforeUpdate = 0;
328  if (hGridNeedsRebuilding())
329  {
330  logger(VERBOSE, "HGrid needs rebuilding for void HGRID_base::hGridActionsBeforeTimeStep()");
331  hGridRebuild();
334  stepsBeforeUpdate = 0;
335  }
336  else
337  {
338 #ifndef CONTACT_LIST_HGRID
340 #endif
342  {
343 #ifndef CONTACT_LIST_HGRID
345 #endif
347  for (BaseParticle* const p : particleHandler)
348  {
350  }
351  stepsBeforeUpdate = 0;
352  }
353  else
354  {
355  stepsBeforeUpdate++;
356  }
357  }
358 
359 }
360 
368 {
369  const Mdouble currentRelativeDisplacement = move / (getHGrid()->getCellSize(iP->getHGridLevel()));
370  if (currentRelativeDisplacement > currentMaxRelativeDisplacement_)
371  {
372  currentMaxRelativeDisplacement_ = currentRelativeDisplacement;
373  }
374 }
375 
377 {
379 }
380 
382 {
384 }
385 
390 {
391  return grid;
392 }
393 
398 {
399  return grid;
400 }
401 
407 {
408  logger(WARN, "In Mdouble MercuryBase::userHGridCellSize(unsigned int level) with level= %", level);
409  logger(WARN, "If you want to use user defined HGrid cell sizes, this function should be redefined");
410  return 0.0;
411 }
412 
419 bool MercuryBase::readNextArgument(int& i, int argc, char *argv[])
420 {
421  if (!strcmp(argv[i], "-hGridMaxLevels"))
422  {
423  setHGridMaxLevels(static_cast<unsigned int>(atoi(argv[i + 1])));
424  }
425  else if (!strcmp(argv[i], "-cellOverSizeRatio"))
426  {
427  setHGridCellOverSizeRatio(atof(argv[i + 1]));
428  }
429  else
430  {
431  return DPMBase::readNextArgument(i, argc, argv); //if argv[i] is not found, check the commands in MD
432  }
433  return true; //returns true if argv[i] is found
434 }
435 
440 {
441  return hGridMethod_;
442 }
443 
448 {
449  hGridMethod_ = hGridMethod;
450 }
451 
456 {
457  return hGridDistribution_;
458 }
459 
465 {
466  if (hGridDistribution_ != hGridDistribution)
467  {
468  gridNeedsUpdate_ = true;
469  hGridDistribution_ = hGridDistribution;
470  }
471 }
472 
478 {
480 }
481 
488 {
489  //If the hGridCellOverSizeRatio changes significantly, assign the given parameter.
490  if (mathsFunc::isEqual(hGridCellOverSizeRatio_, hGridCellOverSizeRatio, 1e-10))
491  {
492  gridNeedsUpdate_ = true;
493  hGridCellOverSizeRatio_ = hGridCellOverSizeRatio;
494  }
495 }
496 
500 void MercuryBase::setHGridMaxLevels(unsigned int hGridMaxLevels)
501 {
502  if (hGridMaxLevels_ != hGridMaxLevels)
503  {
504  gridNeedsUpdate_ = true;
505  hGridMaxLevels_ = hGridMaxLevels;
506  }
507 }
508 
512 unsigned int MercuryBase::getHGridMaxLevels() const
513 {
514  return hGridMaxLevels_;
515 }
516 
521 {
522  if (grid == nullptr)
523  {
524  logger(VERBOSE, "HGrid needs updating, because there is no grid.");
525  return true;
526  }
527  else if (gridNeedsUpdate_)
528  {
529  logger(VERBOSE, "HGrid needs updating, because some of its initialisation parameters have changed.");
530  return true;
531  }
532  else if (grid->getNeedsRebuilding())
533  {
534  logger(VERBOSE, "HGrid needs updating, because said so by the grid itself");
535  return true;
536  }
537  else if (getHGrid()->getNumberOfBuckets() > 10 * getHGridTargetNumberOfBuckets() || 10 * getHGrid()->getNumberOfBuckets() < getHGridTargetNumberOfBuckets())
538  {
539  logger(VERBOSE, "HGrid needs updating, because of number of buckets, current = %, target = %.", grid->getNumberOfBuckets(), particleHandler.getNumberOfObjects());
540  return true;
541  }
543  {
544  logger(VERBOSE, "HGrid needs updating, because of maximum cell size, current = %, required = %.", grid->getCellSizes().back() * hGridCellOverSizeRatio_, particleHandler.getLargestParticle()->getInteractionRadius());
545  return true;
546  }
547  else
548  {
549  //std::cout<<"HGrid does not need updating, because of number of buckets, current="<<grid->NUM_BUCKETS<<" target="<<particleHandler.getNumberOfObjects()<<std::endl;
550  //std::cout<<"HGrid does not need updating, because of maximum cell size, current="<<grid->cellSizes_.back()*grid->cellOverSizeRatio_<<" required="<<2.0*particleHandler.getLargestParticle()->getInteractionRadius()<<std::endl;
551  return false;
552  }
553 }
554 
559 {
560  const unsigned int nParticles = particleHandler.getNumberOfObjects();
561  if (nParticles > 10)
562  {
563  return nParticles;
564  }
565  else
566  {
567  return 10;
568  }
569 }
570 
576 {
578  {
579  return 0.0;
580  }
581  else
582  {
584  }
585 }
586 
592 {
594  {
595  return 0.0;
596  }
597  else
598  {
600  }
601 }
610 {
611 #ifdef MERCURY_USE_MPI
612  int localInteraction = checkParticleForInteractionLocal(p);
613 
614  MPIContainer& communicator = MPIContainer::Instance();
615  int numberOfProcessors = communicator.getNumberOfProcessors();
616 
617  //The root gathers all values and computes the global value
618  int *interactionList = nullptr;
619  if (communicator.getProcessorID() == 0)
620  {
621  interactionList = new int [numberOfProcessors];
622  }
623 
624  //Gather all local values
625  communicator.gather(localInteraction,interactionList);
626 
627  //Compute the global value
628  int globalInteraction = 1;
629  if (communicator.getProcessorID() == 0)
630  {
631  for (int i = 0; i<numberOfProcessors; i++)
632  {
633  if (interactionList[i] == 0)
634  {
635  globalInteraction = 0;
636  break;
637  }
638  }
639  }
640  //The root now tells the other processors what the global value for the interaction is
641  communicator.broadcast(globalInteraction);
642 
643  //Convert the result back to bool
644  bool interaction = globalInteraction;
645 #else
646  bool interaction = checkParticleForInteractionLocalPeriodic(p);
647 #endif
648  return interaction;
649 }
650 
659 {
660  Mdouble distance;
661  Vec3D normal;
662 
663  //Check if it has no collision with walls
664  for (BaseWall* w :wallHandler)
665  {
666  if (w->getDistanceAndNormal(p, distance, normal))
667  {
668  logger(VERBOSE, "Collision with wall %.", *w);
669  return false;
670  }
671  else
672  {
673  logger(VERBOSE, "No collision with wall %.", *w);
674  }
675  }
676 
677  //Check if it has no collision with other particles
678  if (hGridHasParticleContacts(&p))
679  {
680  logger(VERBOSE, "Collision with particle.");
681  return false;
682  }
683  else
684  {
685  logger(VERBOSE, "No collision with particles.");
686  }
687  return true;
688 }
689 
690 
692 {
693  logger(INFO,"hGrid parameters:" );
694  logger(INFO, " method %", hGridMethod_);
695  logger(INFO, " distribution %", hGridDistribution_);
696  logger(VERBOSE, "Mdouble currentMaxRelativeDisplacement_=%", currentMaxRelativeDisplacement_);
697  logger(VERBOSE, "Mdouble totalCurrentMaxRelativeDisplacement_=%", totalCurrentMaxRelativeDisplacement_);
699  logger(INFO," needsUpdate %", gridNeedsUpdate_);
700  logger(INFO," updateEachTimeStep %", updateEachTimeStep_);
701  logger(INFO, " maxLevels %", hGridMaxLevels_);
702  logger(INFO, " cellOverSizeRatio %", hGridCellOverSizeRatio_);
703  std::cout << "hGrid parameters:" << std::endl;
704  std::cout << " method " << hGridMethod_ << std::endl;
705  std::cout << " distribution " << hGridDistribution_ << std::endl;
706  if (grid != nullptr)
707  {
708  grid->info();
709  }
710  else
711  {
712  logger(INFO," grid does not exist yet");
713  }
714 }
BaseParticle * getLargestParticle() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
const std::vector< double > & getCellSizes() const
Gets the sizes of the cells at all levels as a vector.
Definition: HGrid.cc:176
virtual void hGridFindOneSidedContacts(BaseParticle *obj)=0
This is a purely virtual function that checks if an object is in the grid, this code is dimension dep...
virtual void write(std::ostream &os, bool writeAllParticles=true) const
Loads all MD data and plots statistics for all timesteps in the .data file.
Definition: DPMBase.cc:1897
virtual void hGridUpdateParticle(BaseParticle *obj UNUSED)
no implementation but can be overidden in its derived classes.
Definition: DPMBase.cc:757
bool checkParticleForInteraction(const BaseParticle &P) override
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
Definition: MercuryBase.cc:609
bool hGridNeedsRebuilding()
Gets if the HGrid needs rebuilding before anything else happens.
Definition: MercuryBase.cc:520
Mdouble totalCurrentMaxRelativeDisplacement_
After each time step, this Mdouble is increased by 2*currentMaxRelativeDisplacement_.
Definition: MercuryBase.h:367
Mdouble getHGridCellOverSizeRatio() const
Gets the ratio of the smallest cell over the smallest particle.
Definition: MercuryBase.cc:477
HGrid * grid
A pointer to the HGrid associated with this MercuryBase.
Definition: MercuryBase.h:335
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Mdouble getHGridCurrentMaxRelativeDisplacement() const
Returns hGridCurrentMaxRelativeDisplacement_.
Definition: MercuryBase.cc:154
void insertParticleToHgrid(BaseParticle *obj)
Inserts the given BaseParticle in to the HGrid.
Definition: HGrid.cc:89
virtual unsigned int getHGridTargetNumberOfBuckets() const
Gets the desired number of buckets, which is the maximum of the number of particles and 10...
Definition: MercuryBase.cc:558
void setHGridUpdateEachTimeStep(bool updateEachTimeStep)
Sets whether or not the HGrid must be updated every time step.
Definition: MercuryBase.cc:172
void info() const
Displays the member variables of the hGrid object. This function is intended for debugging the hGrid...
Definition: HGrid.cc:292
void clearFirstBaseParticleInBucket()
For all buckets, it removes the pointer to the first BaseParticle in it, practically emptying the buc...
Definition: HGrid.cc:189
virtual Mdouble getHGridTargetMinInteractionRadius() const
Gets the desired size of the smallest cells of the HGrid.
Definition: MercuryBase.cc:575
HGridDistribution hGridDistribution_
Indicator for the distribution of the sizes of the cells of different levels of the HGrid...
Definition: MercuryBase.h:353
double Mdouble
unsigned int hGridMaxLevels_
Unsigned integer that indicates the maximum number of levels of the HGrid.
Definition: MercuryBase.h:395
HGridMethod getHGridMethod() const
Gets whether the HGrid in this MercuryBase is BOTTOMUP or TOPDOWN.
Definition: MercuryBase.cc:439
Mdouble getCellOverSizeRatio() const
Gets the maximum ratio of the cell to a particle it contains.
Definition: HGrid.cc:278
void hGridUpdateMove(BaseParticle *iP, Mdouble move) override
Computes the relative displacement of the given BaseParticle and updates the currentMaxRelativeDispla...
Definition: MercuryBase.cc:367
Mdouble hGridCellOverSizeRatio_
The maximum ratio between the size of the cells and the BaseParticle they contain.
Definition: MercuryBase.h:403
unsigned int getHGridMaxLevels() const
Gets the maximum number of levels of the HGrid in this MercuryBase.
Definition: MercuryBase.cc:512
void hGridActionsBeforeTimeStep() override
Performs all necessary actions before a time-step, like updating the particles and resetting all the ...
Definition: MercuryBase.cc:324
void hGridInfo() const
Writes the info of the HGrid to the screen in a nice format.
Definition: MercuryBase.cc:691
bool isEqual(Mdouble v1, Mdouble v2, Mdouble absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
virtual Mdouble getHGridTargetMaxInteractionRadius() const
Gets the desired size of the largest cells of the HGrid.
Definition: MercuryBase.cc:591
HGridMethod
Enum class that indicates how particles in different levels (cross level checking) of the HGrid are c...
Definition: MercuryBase.h:45
void setHGridMethod(HGridMethod hGridMethod)
Sets the HGridMethod to either BOTTOMUP or TOPDOWN.
Definition: MercuryBase.cc:447
HGridMethod hGridMethod_
Indicator of which way the interactions between different levels are tested.
Definition: MercuryBase.h:347
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
Definition: MercuryBase.h:127
Mdouble getHGridTotalCurrentMaxRelativeDisplacement() const
Returns hGridTotalCurrentMaxRelativeDisplacement_.
Definition: MercuryBase.cc:163
void hGridActionsAfterIntegration() override
Sets the totalCurrentMaxRelativeDisplacement_ as 2*currentMaxRelativeDisplacement_.
Definition: MercuryBase.cc:381
BaseParticle * getSmallestParticle() const
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
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:132
virtual bool readNextArgument(int &i, int argc, char *argv[])
Interprets the i^th command-line argument.
Definition: DPMBase.cc:2349
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
Definition: Helpers.cc:396
In the HGrid class, here all information about the HGrid is stored.
Definition: HGrid.h:41
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1001
bool readNextArgument(int &i, int argc, char *argv[]) override
Reads the next command line argument.
Definition: MercuryBase.cc:419
void hGridInsertParticle(BaseParticle *obj) override
Inserts a single Particle to current grid.
Definition: MercuryBase.cc:297
void clearBucketIsChecked()
Sets all buckets to not-checked.
Definition: HGrid.cc:165
~MercuryBase()
This is the default destructor.
Definition: MercuryBase.cc:40
bool checkParticleForInteractionLocal(const BaseParticle &P) override
Definition: MercuryBase.cc:658
#define UNUSED
Definition: GeneralDefine.h:39
void setHGridCellOverSizeRatio(Mdouble cellOverSizeRatio)
Sets the ratio of the smallest cell over the smallest particle.
Definition: MercuryBase.cc:487
HGridDistribution
Enum that indicates what the ratio of the size of the cells in different levels is.
Definition: MercuryBase.h:85
bool updateEachTimeStep_
Boolean which indicates whether or not the cell in which a particle is must be updated every timestep...
Definition: MercuryBase.h:381
Basic class for walls.
Definition: BaseWall.h:44
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:487
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
MercuryBase()
This is the default constructor. It sets sensible defaults.
Definition: MercuryBase.cc:34
void hGridRebuild()
This sets up the parameters required for the contact model.
Definition: MercuryBase.cc:201
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1006
double getCellSize(unsigned int i) const
Gets the size of the cells at the given level.
Definition: HGrid.cc:253
virtual bool hGridHasParticleContacts(const BaseParticle *obj)=0
Purely virtual function that checks if the given particle has a possible contact with any other BaseP...
HGridDistribution getHGridDistribution() const
Gets how the sizes of the cells of different levels are distributed.
Definition: MercuryBase.cc:455
void constructor()
This is the actual constructor, it is called do both constructors above.
Definition: MercuryBase.cc:80
bool gridNeedsUpdate_
Boolean that indicates whether or not the grid needs to be updated.
Definition: MercuryBase.h:375
bool checkParticleForInteractionLocalPeriodic(const BaseParticle &P)
Definition: DPMBase.cc:2680
void read(std::istream &is) override
Reads the MercuryBase from an input stream, for example a restart file.
Definition: MercuryBase.cc:105
bool getNeedsRebuilding() const
Gets whether or not the grid needs to be rebuilt before something else is done with it...
Definition: HGrid.cc:270
bool getHGridUpdateEachTimeStep() const override
Gets whether or not the HGrid is updated every time step.
Definition: MercuryBase.cc:180
void broadPhase(BaseParticle *i) override
This checks particles in the HGRID to see if for closer enough for possible contact.
Definition: MercuryBase.cc:314
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual Mdouble userHGridCellSize(unsigned int level)
Virtual function that enables inheriting classes to implement a function to let the user set the cell...
Definition: MercuryBase.cc:406
unsigned int getHGridLevel() const
Returns particle's HGrid level.
void setHGridDistribution(HGridDistribution hGridDistribution)
Sets how the sizes of the cells of different levels are distributed.
Definition: MercuryBase.cc:464
Mdouble getInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
HGrid * getHGrid()
Gets the HGrid used by this problem.
Definition: MercuryBase.cc:389
virtual void read(std::istream &is)
Reads all data from a restart file, e.g. domain data and particle data.
Definition: DPMBase.cc:1955
Mdouble currentMaxRelativeDisplacement_
Mdouble that denotes the maximum of the displacement of a particle divided by the cell size of the le...
Definition: MercuryBase.h:361
void hGridActionsBeforeIntegration() override
Resets the currentMaxRelativeDisplacement_ to 0.
Definition: MercuryBase.cc:376
unsigned int getNumberOfBuckets() const
Gets the number of buckets of this HGrid.
Definition: HGrid.cc:160