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");
155 for (
unsigned int level = startLevel; level < hgrid->
getNumberOfLevels(); occupiedLevelsMask >>= 1, level++)
158 if (occupiedLevelsMask == 0)
164 if ((occupiedLevelsMask & 1) == 0)
169 if (level == startLevel)
188 for (
int x = xs; x <= xe; ++x)
190 for (
int y = ys; y <= ye; ++y)
202 for (
unsigned int level = 0; level <= startLevel; occupiedLevelsMask >>= 1, level++)
205 if (occupiedLevelsMask == 0)
211 if ((occupiedLevelsMask & 1) == 0)
216 if (level == startLevel)
235 for (
int x = xs; x <= xe; ++x)
237 for (
int y = ys; y <= ye; ++y)
261 int x =
static_cast<int>(std::floor(obj->
getPosition().
X * inv_size));
262 int y =
static_cast<int>(std::floor(obj->
getPosition().
Y * inv_size));
264 #ifdef CONTACT_LIST_HGRID
273 getPossibleContactList().remove_ParticlePosibleContacts(obj);
286 InsertObjAgainstGrid(obj);
314 if (hGrid !=
nullptr)
384 logger(
INFO,
"HGrid needs rebuilding for \"bool Mercury2D::hGridHasParticleContacts(BaseParticle *obj)\"");
394 if (occupiedLevelsMask == 0)
396 logger(
VERBOSE,
"Level % and higher levels are empty.", level);
401 if ((occupiedLevelsMask & 1) == 0)
414 logger(
VERBOSE,
"Level % grid cells [%,%] x [%,%]", level, xs, xe, ys, ye);
415 for (
int x = xs; x <= xe; ++x)
417 for (
int y = ys; y <= ye; ++y)
430 #ifdef CONTACT_LIST_HGRID
437 void Mercury2D::InsertCell(
int x,
int y,
unsigned int l,
BaseParticle* obj)
447 getPossibleContactList().add_PossibleContact(obj, p);
474 if (occupiedLevelsMask_ == 0)
480 if ((occupiedLevelsMask_ & 1) == 0)
491 xs =
static_cast<int>(std::floor(ownXMin * inv_size - 0.5));
492 xe =
static_cast<int>(std::floor(ownXMax * inv_size + 0.5));
493 ys =
static_cast<int>(std::floor(ownYMin * inv_size - 0.5));
494 ye =
static_cast<int>(std::floor(ownYMax * inv_size + 0.5));
496 for(
int x = xs; x <= xe; ++x)
498 for(
int y = ys; y <= ye; ++y)
500 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.
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.
void hGridRemoveParticle(BaseParticle *obj) override
Removes a BaseParticle to the HGrid.