MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Mercury2D.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 "Mercury2D.h"
27 #include "Particles/BaseParticle.h"
28 
30 {
31  constructor();
32  logger(DEBUG, "Mercury2D::Mercury2D() constructor finished");
33 }
34 
41  : DPMBase(other), MercuryBase(other)
42 {
43  logger(DEBUG, "Mercury2D::Mercury2D(Mercury2D& other) copy constructor finished");
44 }
45 
53  : DPMBase(other), MercuryBase()
54 {
55  constructor();
56  logger(DEBUG, "Mercury2D::Mercury2D(DPMBase& other) finished");
57 }
58 
60 {
63 }
64 
72 void Mercury2D::hGridFindContactsWithinTargetCell(int x, int y, unsigned int l)
73 {
74  HGrid* hgrid = getHGrid();
75  unsigned int bucket = hgrid->computeHashBucketIndex(x, y, l);
76 
78  //Check if this function is already applied to this bucket
79  bool bucketIsChecked;
80  #pragma omp critical
81  {
82  bucketIsChecked = hgrid->getBucketIsChecked(bucket);
83  hgrid->setBucketIsChecked(bucket);
84  }
85  if (bucketIsChecked) return;
86 
87  BaseParticle* p1 = hgrid->getFirstBaseParticleInBucket(bucket);
88  while (p1 != nullptr)
89  {
90  BaseParticle* p2 = p1->getHGridNextObject();
91  while (p2 != nullptr)
92  {
95  //Check if the BaseParticle* p1 and BaseParticle* p2 are really in the same cell (i.e. no hashing error has occurred)
96  if (p1->getHGridCell() == p2->getHGridCell())
97  {
98  computeInternalForce(p1, p2);
99  }
100  p2 = p2->getHGridNextObject();
101  }
102  p1 = p1->getHGridNextObject();
103  }
104 }
105 
117 void Mercury2D::hGridFindContactsWithTargetCell(int x, int y, unsigned int l, BaseParticle* obj)
118 {
119  //Check if the object is not in the same cell as being checked, CheckCell_current should handle these cases.
120  logger.assert(!obj->getHGridCell().equals(x, y, l),
121  "hGridFindContactsWithTargetCell should not be called if object is in the same cell");
122 
123  HGrid* const hgrid = getHGrid();
124 
125  // Calculate the bucket
126  const unsigned int bucket = hgrid->computeHashBucketIndex(x, y, l);
127 
128  // Loop through all objects in the bucket to find nearby objects
129  for (BaseParticle* p = hgrid->getFirstBaseParticleInBucket(bucket); p != nullptr; p = p->getHGridNextObject())
130  {
131  //Check if the BaseParticle *p really is in the target cell (i.e. no hashing error has occurred)
132  if (p->getHGridCell().equals(x, y, l))
133  {
134  computeInternalForce(obj, p);
135  }
136  }
137 }
138 
140 void Mercury2D::hGridFindParticlesWithTargetCell(int x, int y, unsigned int l, BaseParticle* obj,
141  std::vector<BaseParticle*>& list)
142 {
143  HGrid* const hgrid = getHGrid();
144 
145  // Calculate the bucket
146  const unsigned int bucket = hgrid->computeHashBucketIndex(x, y, l);
147 
148  // Loop through all objects in the bucket to find nearby objects
149  BaseParticle* p = hgrid->getFirstBaseParticleInBucket(bucket);
150  while (p != nullptr)
151  {
152  if (p->getHGridCell().equals(x, y, l))
153  {
154  list.push_back(p);
155  }
156  p = p->getHGridNextObject();
157  }
158 }
159 
160 //TODO what about
161 void Mercury2D::hGridGetInteractingParticleList(BaseParticle* obj, std::vector<BaseParticle*>& list)
162 {
163  HGrid* const hgrid = getHGrid();
164  int occupiedLevelsMask = hgrid->getOccupiedLevelsMask() >> obj->getHGridLevel();
165  for (unsigned int level = 0; level < hgrid->getNumberOfLevels(); level++)
166  {
167  // If no objects in rest of grid, stop now
168  if (occupiedLevelsMask == 0)
169  {
170  break;
171  }
172 
173  // If no objects at this level, go on to the next level
174  if ((occupiedLevelsMask & 1) == 0)
175  {
176  continue;
177  }
178 
179  const Mdouble inv_size = hgrid->getInvCellSize(level);
180  const int xs = static_cast<int>(std::floor(
181  (obj->getPosition().X - obj->getMaxInteractionRadius()) * inv_size - 0.5));
182  const int xe = static_cast<int>(std::floor(
183  (obj->getPosition().X + obj->getMaxInteractionRadius()) * inv_size + 0.5));
184  const int ys = static_cast<int>(std::floor(
185  (obj->getPosition().Y - obj->getMaxInteractionRadius()) * inv_size - 0.5));
186  const int ye = static_cast<int>(std::floor(
187  (obj->getPosition().Y + obj->getMaxInteractionRadius()) * inv_size + 0.5));
188  for (int x = xs; x <= xe; ++x)
189  {
190  for (int y = ys; y <= ye; ++y)
191  {
192  hGridFindParticlesWithTargetCell(x, y, level, obj, list);
193  }
194  }
195  }
196 }
197 
198 
205 {
206  HGrid* hgrid = getHGrid();
207  unsigned int startLevel = obj->getHGridLevel();
208 
209  switch (getHGridMethod())
210  {
211  case BOTTOMUP:
212  {
213  int occupiedLevelsMask = hgrid->getOccupiedLevelsMask() >> obj->getHGridLevel();
214  for (unsigned int level = startLevel; level < hgrid->getNumberOfLevels(); occupiedLevelsMask >>= 1, level++)
215  {
216  // If no objects in rest of grid, stop now
217  if (occupiedLevelsMask == 0)
218  {
219  break;
220  }
221 
222  // If no objects at this level, go on to the next level
223  if ((occupiedLevelsMask & 1) == 0)
224  {
225  continue;
226  }
227 
228  if (level == startLevel)
229  {
230  int x = obj->getHGridX();
231  int y = obj->getHGridY();
232 
234  hGridFindContactsWithTargetCell(x, y + 1, level, obj);
235  hGridFindContactsWithTargetCell(x + 1, y - 1, level, obj);
236  hGridFindContactsWithTargetCell(x + 1, y, level, obj);
237  hGridFindContactsWithTargetCell(x + 1, y + 1, level, obj);
238  }
239  else
240  {
241  int xs, ys, xe, ye;
242  Mdouble inv_size = hgrid->getInvCellSize(level);
243  xs = static_cast<int>(std::floor(
244  (obj->getPosition().X - obj->getMaxInteractionRadius()) * inv_size - 0.5));
245  xe = static_cast<int>(std::floor(
246  (obj->getPosition().X + obj->getMaxInteractionRadius()) * inv_size + 0.5));
247  ys = static_cast<int>(std::floor(
248  (obj->getPosition().Y - obj->getMaxInteractionRadius()) * inv_size - 0.5));
249  ye = static_cast<int>(std::floor(
250  (obj->getPosition().Y + obj->getMaxInteractionRadius()) * inv_size + 0.5));
251  for (int x = xs; x <= xe; ++x)
252  {
253  for (int y = ys; y <= ye; ++y)
254  {
255  hGridFindContactsWithTargetCell(x, y, level, obj);
256  }
257  }
258  }
259  }
260  break;
261  }
262  case TOPDOWN:
263  {
264  int occupiedLevelsMask = hgrid->getOccupiedLevelsMask();
265  for (unsigned int level = 0; level <= startLevel; occupiedLevelsMask >>= 1, level++)
266  {
267  // If no objects in rest of grid, stop now
268  if (occupiedLevelsMask == 0)
269  {
270  break;
271  }
272 
273  // If no objects at this level, go on to the next level
274  if ((occupiedLevelsMask & 1) == 0)
275  {
276  continue;
277  }
278 
279  if (level == startLevel)
280  {
281  int x = obj->getHGridX();
282  int y = obj->getHGridY();
283 
285  hGridFindContactsWithTargetCell(x, y + 1, level, obj);
286  hGridFindContactsWithTargetCell(x + 1, y - 1, level, obj);
287  hGridFindContactsWithTargetCell(x + 1, y, level, obj);
288  hGridFindContactsWithTargetCell(x + 1, y + 1, level, obj);
289  }
290  else
291  {
292  int xs, ys, xe, ye;
293  Mdouble inv_size = hgrid->getInvCellSize(level);
294  xs = static_cast<int>(std::floor(
295  (obj->getPosition().X - obj->getMaxInteractionRadius()) * inv_size - 0.5));
296  xe = static_cast<int>(std::floor(
297  (obj->getPosition().X + obj->getMaxInteractionRadius()) * inv_size + 0.5));
298  ys = static_cast<int>(std::floor(
299  (obj->getPosition().Y - obj->getMaxInteractionRadius()) * inv_size - 0.5));
300  ye = static_cast<int>(std::floor(
301  (obj->getPosition().Y + obj->getMaxInteractionRadius()) * inv_size + 0.5));
302  for (int x = xs; x <= xe; ++x)
303  {
304  for (int y = ys; y <= ye; ++y)
305  {
306  hGridFindContactsWithTargetCell(x, y, level, obj);
307  }
308  }
309  }
310  }
311  break;
312  }
313  }
314 }
315 
321 {
322  HGrid* hGrid = getHGrid();
323  if (hGrid)
324  {
325  unsigned int l = obj->getHGridLevel();
326  Mdouble inv_size = hGrid->getInvCellSize(l);
327 
328  int x = static_cast<int>(std::floor(obj->getPosition().X * inv_size));
329  int y = static_cast<int>(std::floor(obj->getPosition().Y * inv_size));
330 
331 #ifdef CONTACT_LIST_HGRID
332  if(obj->getHGridX() != x || obj->getHGridY() != y)
333  {
334  int bucket = hGrid->computeHashBucketIndex(x, y, l);
335 
336  //First the object has to be removed
337  hGridRemoveParticle(obj);
338 
339  //Also remove all contact associated with it
340  getPossibleContactList().remove_ParticlePosibleContacts(obj);
341 
342  //And now reinserted
344  obj->setHGridPrevObject(nullptr);
345  if(hGrid->getFirstBaseParticleInBucket(bucket))
346  {
348  }
349  hGrid->setFirstBaseParticleInBucket(bucket,obj);
350 
351  obj->setHGridX(x);
352  obj->setHGridY(y);
353  InsertObjAgainstGrid(obj);
354  }
355 #else
356  unsigned int bucket = hGrid->computeHashBucketIndex(x, y, l);
357 
359  obj->setHGridPrevObject(nullptr);
360  if (hGrid->getFirstBaseParticleInBucket(bucket))
361  {
363  }
364 
365  hGrid->setFirstBaseParticleInBucket(bucket, obj);
366 
367  obj->setHGridX(x);
368  obj->setHGridY(y);
369 #endif
370  }
371 }
372 
379 {
380  HGrid* hGrid = getHGrid();
381  if (hGrid != nullptr)
382  {
383  unsigned int bucket = getHGrid()->computeHashBucketIndex(obj->getHGridX(), obj->getHGridY(),
384  obj->getHGridLevel());
385  if (obj->getHGridPrevObject())
386  {
388  }
389  else
390  {
391  if (getHGrid()->getFirstBaseParticleInBucket(bucket) == obj)
392  {
394  }
395  }
396 
397  if (obj->getHGridNextObject())
398  {
400  }
401  }
402 }
403 
419 bool Mercury2D::hGridHasContactsInTargetCell(int x, int y, unsigned int l, const BaseParticle* obj) const
421 {
422  // Loop through all objects in the bucket to find nearby objects
423  unsigned int bucket = getHGrid()->computeHashBucketIndex(x, y, l);
424 
425  const BaseParticle* p = getHGrid()->getFirstBaseParticleInBucket(bucket);
426  while (p != nullptr)
427  {
428  if (p->getHGridCell().equals(x, y, l))
429  {
430  if (areInContact(obj, p))
431  {
432  return true;
433  }
434  }
435  p = p->getHGridNextObject();
436  }
437  return false;
438 }
439 
449 {
450  if (getHGrid() == nullptr || getHGrid()->getNeedsRebuilding())
451  {
452  logger(INFO, "HGrid needs rebuilding for \"bool Mercury2D::hGridHasParticleContacts(BaseParticle *obj)\"");
453  hGridRebuild();
454  }
455 
456  Mdouble inv_size;
457  int occupiedLevelsMask = getHGrid()->getOccupiedLevelsMask();
458 
459  for (unsigned int level = 0; level < getHGrid()->getNumberOfLevels(); occupiedLevelsMask >>= 1, level++)
460  {
461  // If no objects in rest of grid, stop now
462  if (occupiedLevelsMask == 0)
463  {
464  logger(VERBOSE, "Level % and higher levels are empty.", level);
465  break;
466  }
467 
468  // If no objects at this level, go on to the next level
469  if ((occupiedLevelsMask & 1) == 0)
470  {
471  logger(VERBOSE, "Level % is empty", level);
472  continue;
473  }
474 
475  int xs, ys, xe, ye;
476  inv_size = getHGrid()->getInvCellSize(level);
477  xs = static_cast<int>(std::floor((obj->getPosition().X - obj->getMaxInteractionRadius()) * inv_size - 0.5));
478  xe = static_cast<int>(std::floor((obj->getPosition().X + obj->getMaxInteractionRadius()) * inv_size + 0.5));
479  ys = static_cast<int>(std::floor((obj->getPosition().Y - obj->getMaxInteractionRadius()) * inv_size - 0.5));
480  ye = static_cast<int>(std::floor((obj->getPosition().Y + obj->getMaxInteractionRadius()) * inv_size + 0.5));
481 
482  logger(VERBOSE, "Level % grid cells [%,%] x [%,%]", level, xs, xe, ys, ye);
483  for (int x = xs; x <= xe; ++x)
484  {
485  for (int y = ys; y <= ye; ++y)
486  {
487  if (hGridHasContactsInTargetCell(x, y, level, obj))
488  {
489  return true;
490  }
491  }
492  }
493  } //end for level
494 
495  return false;
496 }
497 
498 std::vector<BaseParticle*> Mercury2D::hGridFindParticleContacts(const BaseParticle* obj)
499 {
500  if (getHGrid() == nullptr || getHGrid()->getNeedsRebuilding())
501  {
502  logger(INFO, "HGrid needs rebuilding for \"bool Mercury2D::hGridHasParticleContacts(BaseParticle *obj)\"");
503  hGridRebuild();
504  }
505 
506  Mdouble inv_size;
507  int occupiedLevelsMask = getHGrid()->getOccupiedLevelsMask();
508 
509  std::vector<BaseParticle*> particlesInContact;
510 
511  for (unsigned int level = 0; level < getHGrid()->getNumberOfLevels(); occupiedLevelsMask >>= 1, level++)
512  {
513  // If no objects in rest of grid, stop now
514  if (occupiedLevelsMask == 0)
515  {
516  logger(VERBOSE, "Level % and higher levels are empty.", level);
517  break;
518  }
519 
520  // If no objects at this level, go on to the next level
521  if ((occupiedLevelsMask & 1) == 0)
522  {
523  logger(VERBOSE, "Level % is empty", level);
524  continue;
525  }
526 
527  int xs, ys, xe, ye;
528  inv_size = getHGrid()->getInvCellSize(level);
529  xs = static_cast<int>(std::floor((obj->getPosition().X - obj->getMaxInteractionRadius()) * inv_size - 0.5));
530  xe = static_cast<int>(std::floor((obj->getPosition().X + obj->getMaxInteractionRadius()) * inv_size + 0.5));
531  ys = static_cast<int>(std::floor((obj->getPosition().Y - obj->getMaxInteractionRadius()) * inv_size - 0.5));
532  ye = static_cast<int>(std::floor((obj->getPosition().Y + obj->getMaxInteractionRadius()) * inv_size + 0.5));
533 
534  logger(VERBOSE, "Level % grid cells [%,%] x [%,%]", level, xs, xe, ys, ye);
535  for (int x = xs; x <= xe; ++x)
536  {
537  for (int y = ys; y <= ye; ++y)
538  {
539  // Loop through all objects in the bucket to find nearby objects
540  const unsigned int bucket = getHGrid()->computeHashBucketIndex(x, y, level);
542  while (p != nullptr)
543  {
544  if (p->getHGridCell().equals(x, y, level))
545  {
546  if (areInContact(obj, p))
547  {
548  particlesInContact.push_back(p);
549  }
550  }
551  p = p->getHGridNextObject();
552  }
553  }
554  }
555  } //end for level
556 
557  return particlesInContact;
558 }
559 
560 #ifdef CONTACT_LIST_HGRID
561 
567 void Mercury2D::InsertCell(int x, int y, unsigned int l, BaseParticle* obj)
568 {
569  // Loop through all objects in the bucket to find nearby objects
570  unsigned int bucket = getHGrid()->computeHashBucketIndex(x,y,l);
572 
573  while (p!=nullptr)
574  {
575  if ((p->getHGridX() == x) && (p->getHGridY() == y) && (p->getHGridLevel() == l) && (obj != p))
576  {
577  getPossibleContactList().add_PossibleContact(obj, p);
578  }
579  p = p->getHGridNextObject();
580  }
581 }
582 
589 void Mercury2D::InsertObjAgainstGrid(BaseParticle* obj)
590 {
591  Mdouble inv_size;
592  int occupiedLevelsMask_ = getHGrid()->getOccupiedLevelsMask();
593 
594  inv_size=getHGrid()->getInvCellSize(obj->getHGridLevel());
595 
596  double ownXMin = (obj->getHGridX()-0.5) * getHGrid()->getCellSize(obj->getHGridLevel());
597  double ownXMax = (obj->getHGridX() + 1.5) * getHGrid()->getCellSize(obj->getHGridLevel());
598  double ownYMin = (obj->getHGridY() - 0.5) * getHGrid()->getCellSize(obj->getHGridLevel());
599  double ownYMax = (obj->getHGridY() + 1.5) * getHGrid()->getCellSize(obj->getHGridLevel());
600 
601  for (int level = 0; level < getHGrid()->getNumberOfLevels(); occupiedLevelsMask_ >>= 1, level++)
602  {
603  // If no objects in rest of grid, stop now
604  if (occupiedLevelsMask_ == 0)
605  {
606  break;
607  }
608 
609  // If no objects at this level, go on to the next level
610  if ((occupiedLevelsMask_ & 1) == 0)
611  {
612  continue;
613  }
614 
615  // Treat level as a third dimension coordinate
616  inv_size = getHGrid()->getInvCellSize(level);
617 
618  //Insert this particle in the list of possible interactions for this level
619  //in the appropriate cells.
620  int xs, xe, ys, ye;
621  xs = static_cast<int>(std::floor(ownXMin * inv_size - 0.5));
622  xe = static_cast<int>(std::floor(ownXMax * inv_size + 0.5));
623  ys = static_cast<int>(std::floor(ownYMin * inv_size - 0.5));
624  ye = static_cast<int>(std::floor(ownYMax * inv_size + 0.5));
625 
626  for(int x = xs; x <= xe; ++x)
627  {
628  for(int y = ys; y <= ye; ++y)
629  {
630  InsertCell(x, y, level, obj);
631  }
632  }
633  } //end for level
634 }
635 #endif
const HGridCell & getHGridCell() const
Definition: BaseParticle.h:645
bool equals(int x, int y, int z, unsigned int level) const
Checks if the given (x,y,z,level) is the same as the ones in this cell.
Definition: HGridCell.h:39
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
static bool areInContact(const BaseParticle *pI, const BaseParticle *pJ)
Checks if two particle are in contact or is there any positive overlap.
Definition: DPMBase.cc:1621
bool hGridHasParticleContacts(const BaseParticle *obj) override
Test if a BaseParticle has any contacts in the HGrid.
Definition: Mercury2D.cc:448
void hGridGetInteractingParticleList(BaseParticle *obj, std::vector< BaseParticle * > &list) override
Obtains all neighbour particles of a given object, obtained from the hgrid.
Definition: Mercury2D.cc:161
virtual void hGridFindContactsWithTargetCell(int x, int y, unsigned int l, BaseParticle *obj)
Finds contacts between given BaseParticle and the BaseParticle in the target cell.
Definition: Mercury2D.cc:117
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
Definition: BaseParticle.h:359
void hGridUpdateParticle(BaseParticle *obj) override
Updates the cell (not the level) of a BaseParticle.
Definition: Mercury2D.cc:320
virtual void hGridFindContactsWithinTargetCell(int x, int y, unsigned int l)
Finds contacts between particles the in the target cell.
Definition: Mercury2D.cc:72
void setHGridY(const int y)
Sets the particle's HGrid cell Y-coordinate.
Definition: BaseParticle.h:454
void setHGridNextObject(BaseParticle *p)
Sets the pointer to the next object in the particle's HGrid cell & level.
Definition: BaseParticle.h:477
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1408
HGridMethod getHGridMethod() const
Gets whether the HGrid in this MercuryBase is BOTTOMUP or TOPDOWN.
Definition: MercuryBase.h:204
virtual void hGridFindParticlesWithTargetCell(int x, int y, unsigned int l, BaseParticle *obj, std::vector< BaseParticle * > &list)
Definition: Mercury2D.cc:140
int getHGridY() const
Returns particle's HGrid cell Y-coordinate.
Definition: BaseParticle.h:272
void constructor()
Function that sets the ParticleDimensions and SystemDimensions to 2.
Definition: Mercury2D.cc:59
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1377
void setHGridX(const int x)
Sets the particle's HGrid cell X-coordinate.
Definition: BaseParticle.h:446
void computeInternalForces(BaseParticle *obj) override
Finds contacts with the BaseParticle; avoids multiple checks.
Definition: Mercury2D.cc:204
int getOccupiedLevelsMask() const
Gets the integer that represents which levels are occupied.
Definition: HGrid.h:213
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
Definition: MercuryBase.h:125
In the HGrid class, here all information about the HGrid is stored.
Definition: HGrid.h:42
bool hGridHasContactsInTargetCell(int x, int y, unsigned int l, const BaseParticle *obj) const
Tests if the BaseParticle has contacts with other Particles in the target cell.
Definition: Mercury2D.cc:420
void setFirstBaseParticleInBucket(unsigned int i, BaseParticle *p)
Sets the first particle in bucket i to be the given BaseParticle.
Definition: HGrid.h:117
void setBucketIsChecked(unsigned int i)
Sets that the bucket with the given index is checked to true.
Definition: HGrid.h:124
Mdouble Y
Definition: Vector.h:65
void hGridRebuild()
This sets up the parameters required for the contact model.
Definition: MercuryBase.cc:203
virtual void computeInternalForce(BaseParticle *, BaseParticle *)
Computes the forces between two particles (internal in the sense that the sum over all these forces i...
Definition: DPMBase.cc:2994
double getCellSize(unsigned int i) const
Gets the size of the cells at the given level.
Definition: HGrid.h:147
BaseParticle * getHGridPrevObject() const
Returns pointer to previous object in particle's HGrid level & cell.
Definition: BaseParticle.h:250
Mercury2D()
This is the default constructor. All it does is set sensible defaults.
Definition: Mercury2D.cc:29
void setHGridPrevObject(BaseParticle *p)
Sets the pointer to the previous object in the particle's HGrid cell & level.
Definition: BaseParticle.h:485
HGrid * getHGrid()
Gets the HGrid used by this problem.
Definition: MercuryBase.h:311
unsigned long getNumberOfLevels() const
Gets the number of levels of this HGrid.
Definition: HGrid.h:206
const BaseParticle * getFirstBaseParticleInBucket(unsigned int i) const
Gets the first BaseParticle in the given bucket, const version.
Definition: HGrid.h:162
std::vector< BaseParticle * > hGridFindParticleContacts(const BaseParticle *obj) override
Returns all particles that have a contact with a given particle.
Definition: Mercury2D.cc:498
unsigned int computeHashBucketIndex(int x, int y, int z, unsigned int l) const
Computes hash bucket index in range [0, NUM_BUCKETS-1] for a 3D domain.
Definition: HGrid.h:76
BaseParticle * getHGridNextObject() const
Returns pointer to next object in particle's HGrid level & cell.
Definition: BaseParticle.h:242
unsigned int getHGridLevel() const
Returns particle's HGrid level.
Definition: BaseParticle.h:234
bool getBucketIsChecked(unsigned int i) const
Gets whether or not the bucket with index i is checked.
Definition: HGrid.h:132
double getInvCellSize(unsigned int i) const
Gets 1/cellSize for the cells on level i.
Definition: HGrid.h:178
This adds on the hierarchical grid code for 2D problems.
Definition: Mercury2D.h:35
int getHGridX() const
Returns particle's HGrid cell X-coordinate.
Definition: BaseParticle.h:265
void hGridRemoveParticle(BaseParticle *obj) override
Removes a BaseParticle to the HGrid.
Definition: Mercury2D.cc:378