32 logger(
DEBUG,
"Mercury2D::Mercury2D() constructor finished");
43 logger(
DEBUG,
"Mercury2D::Mercury2D(Mercury2D& other) copy constructor finished");
56 logger(
DEBUG,
"Mercury2D::Mercury2D(DPMBase& other) finished");
156 for (
unsigned int level = startLevel; level < hgrid->
getNumberOfLevels(); occupiedLevelsMask >>= 1, level++)
159 if (occupiedLevelsMask == 0)
165 if ((occupiedLevelsMask & 1) == 0)
170 if (level == startLevel)
189 for (
int x = xs; x <= xe; ++x)
191 for (
int y = ys; y <= ye; ++y)
203 for (
unsigned int level = 0; level <= startLevel; occupiedLevelsMask >>= 1, level++)
206 if (occupiedLevelsMask == 0)
212 if ((occupiedLevelsMask & 1) == 0)
217 if (level == startLevel)
236 for (
int x = xs; x <= xe; ++x)
238 for (
int y = ys; y <= ye; ++y)
262 int x =
static_cast<int>(std::floor(obj->
getPosition().
X * inv_size));
263 int y =
static_cast<int>(std::floor(obj->
getPosition().
Y * inv_size));
265 #ifdef CONTACT_LIST_HGRID
274 getPossibleContactList().remove_ParticlePosibleContacts(obj);
287 InsertObjAgainstGrid(obj);
315 if (hGrid !=
nullptr)
385 logger(
INFO,
"HGrid needs rebuilding for \"bool Mercury2D::hGridHasParticleContacts(BaseParticle *obj)\"");
395 if (occupiedLevelsMask == 0)
397 logger(
VERBOSE,
"Level % and higher levels are empty.", level);
402 if ((occupiedLevelsMask & 1) == 0)
415 logger(
VERBOSE,
"Level % grid cells [%,%] x [%,%]", level, xs, xe, ys, ye);
416 for (
int x = xs; x <= xe; ++x)
418 for (
int y = ys; y <= ye; ++y)
431 #ifdef CONTACT_LIST_HGRID
438 void Mercury2D::InsertCell(
int x,
int y,
unsigned int l,
BaseParticle* obj)
448 getPossibleContactList().add_PossibleContact(obj, p);
475 if (occupiedLevelsMask_ == 0)
481 if ((occupiedLevelsMask_ & 1) == 0)
492 xs =
static_cast<int>(std::floor(ownXMin * inv_size - 0.5));
493 xe =
static_cast<int>(std::floor(ownXMax * inv_size + 0.5));
494 ys =
static_cast<int>(std::floor(ownYMin * inv_size - 0.5));
495 ye =
static_cast<int>(std::floor(ownYMax * inv_size + 0.5));
497 for(
int x = xs; x <= xe; ++x)
499 for(
int y = ys; y <= ye; ++y)
501 InsertCell(x, y, level, obj);
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Mdouble X
the vector components
bool hGridHasParticleContacts(const BaseParticle *obj) override
Test if a BaseParticle has any contacts in the HGrid.
bool areInContact(const BaseParticle *pI, const BaseParticle *pJ) const
Checks if two particle are in contact or is there any positive overlap.
virtual void hGridFindContactsWithTargetCell(int x, int y, unsigned int l, BaseParticle *obj)
Finds contacts between given BaseParticle and the BaseParticle in the target cell.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void hGridUpdateParticle(BaseParticle *obj) override
Updates the cell (not the level) of a BaseParticle.
virtual void computeInternalForces(BaseParticle *i)
Computes the forces between particles (internal in the sense that the sum over all these forces is ze...
virtual void hGridFindContactsWithinTargetCell(int x, int y, unsigned int l)
Finds contacts between particles the in the target cell.
void setHGridY(const int y)
Sets the particle's HGrid cell Y-coordinate.
void setHGridNextObject(BaseParticle *p)
Sets the pointer to the next object in the particle's HGrid cell & level.
void setParticleDimensions(unsigned int particleDimensions)
Allows the dimension of the particle (f.e. for mass) to be changed. e.g. discs or spheres...
HGridMethod getHGridMethod() const
Gets whether the HGrid in this MercuryBase is BOTTOMUP or TOPDOWN.
void hGridRemoveParticle(BaseParticle *obj)
Removes a BaseParticle to the HGrid.
int getHGridY() const
Returns particle's HGrid cell Y-coordinate.
void constructor()
Function that sets the ParticleDimensions and SystemDimensions to 2.
void setSystemDimensions(unsigned int newDim)
Allows for the dimension of the simulation to be changed.
void setHGridX(const int x)
Sets the particle's HGrid cell X-coordinate.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
int getOccupiedLevelsMask() const
Gets the integer that represents which levels are occupied.
unsigned int getNumberOfLevels() const
Gets the number of levels of this HGrid.
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
In the HGrid class, here all information about the HGrid is stored.
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.
void setFirstBaseParticleInBucket(unsigned int i, BaseParticle *p)
Sets the first particle in bucket i to be the given BaseParticle.
void setBucketIsChecked(unsigned int i)
Sets that the bucket with the given index is checked to true.
const BaseParticle * getFirstBaseParticleInBucket(unsigned int i) const
Gets the first BaseParticle in the given bucket, const version.
void hGridRebuild()
This sets up the parameters required for the contact model.
double getCellSize(unsigned int i) const
Gets the size of the cells at the given level.
Mercury2D()
This is the default constructor. All it does is set sensible defaults.
void hGridFindOneSidedContacts(BaseParticle *obj) override
Finds contacts with the BaseParticle; avoids multiple checks.
void setHGridPrevObject(BaseParticle *p)
Sets the pointer to the previous object in the particle's HGrid cell & level.
BaseParticle * getHGridPrevObject() const
Returns pointer to previous object in particle's HGrid level & cell.
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.
BaseParticle * getHGridNextObject() const
Returns pointer to next object in particle's HGrid level & cell.
unsigned int getHGridLevel() const
Returns particle's HGrid level.
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.
bool getBucketIsChecked(unsigned int i) const
Gets whether or not the bucket with index i is checked.
double getInvCellSize(unsigned int i) const
Gets 1/cellSize for the cells on level i.
This adds on the hierarchical grid code for 2D problems.
int getHGridX() const
Returns particle's HGrid cell X-coordinate.