43 logger(
DEBUG,
"Mercury3D::Mercury3D(Mercury3D& other) copy constructor finished.");
56 logger(
DEBUG,
"Mercury3D::Mercury3D(DPMBase& other) constructor finished");
159 for (
unsigned int level = startLevel; level < hgrid->
getNumberOfLevels(); occupiedLevelsMask >>= 1, level++)
162 if (occupiedLevelsMask == 0)
168 if ((occupiedLevelsMask & 1) == 0)
173 if (level == startLevel)
203 for (
int x = xs; x <= xe; ++x)
205 for (
int y = ys; y <= ye; ++y)
207 for (
int z = zs; z <= ze; ++z)
220 for (
unsigned int level = 0; level <= startLevel; occupiedLevelsMask >>= 1, level++)
223 if (occupiedLevelsMask == 0)
229 if ((occupiedLevelsMask & 1) == 0)
234 if (level == startLevel)
264 for (
int x = xs; x <= xe; ++x)
266 for (
int y = ys; y <= ye; ++y)
268 for (
int z = zs; z <= ze; ++z)
293 int x =
static_cast<int>(std::floor(obj->
getPosition().
X * inv_size));
294 int y =
static_cast<int>(std::floor(obj->
getPosition().
Y * inv_size));
295 int z =
static_cast<int>(std::floor(obj->
getPosition().
Z * inv_size));
297 #ifdef CONTACT_LIST_HGRID
306 getPossibleContactList().remove_ParticlePosibleContacts(obj);
320 InsertObjAgainstGrid(obj);
411 logger(
INFO,
"HGrid needs rebuilding for \"bool Mercury3D::hGridHasParticleContacts(BaseParticle *obj)\"");
420 if (occupiedLevelsMask == 0)
422 logger(
VERBOSE,
"Level % and higher levels are empty", level);
427 if ((occupiedLevelsMask & 1) == 0)
441 logger(
VERBOSE,
"Level = % grid cells [%,%] x [%,%] x [%,%]", level, xs, xe, ys, ye, zs, ze);
442 for (
int x = xs; x <= xe; ++x)
444 for (
int y = ys; y <= ye; ++y)
446 for (
int z = zs; z <= ze; ++z)
460 #ifdef CONTACT_LIST_HGRID
470 void Mercury3D::InsertCell(
int x,
int y,
int z,
unsigned int l,
BaseParticle *obj)
480 getPossibleContactList().add_PossibleContact(obj,p);
510 if (occupiedLevelsMask_ == 0)
516 if ((occupiedLevelsMask_ & 1) == 0)
524 int xs, xe, ys, ye, zs, ze;
525 xs=
static_cast<int>(std::floor(ownXMin * inv_size - 0.5));
526 xe=
static_cast<int>(std::floor(ownXMax * inv_size + 0.5));
527 ys=
static_cast<int>(std::floor(ownYMin * inv_size - 0.5));
528 ye=
static_cast<int>(std::floor(ownYMax * inv_size + 0.5));
529 zs=
static_cast<int>(std::floor(ownZMin * inv_size - 0.5));
530 ze=
static_cast<int>(std::floor(ownZMax * inv_size + 0.5));
532 for(
int x=xs; x<=xe; ++x)
534 for(
int y=ys; y<=ye; ++y)
536 for(
int z=zs; z<=ze; ++z)
538 InsertCell(x, y, z, level, obj);
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Mdouble X
the vector components
void hGridRemoveParticle(BaseParticle *obj) override
Removes a BaseParticle from the HGrid.
bool areInContact(const BaseParticle *pI, const BaseParticle *pJ) const
Checks if two particle are in contact or is there any positive overlap.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
virtual void hGridFindContactsWithinTargetCell(int x, int y, int z, unsigned int l)
Finds contacts between particles in the target cell.
void constructor()
Function that sets the SystemDimension and ParticleDimension to 3.
virtual void computeInternalForces(BaseParticle *i)
Computes the forces between particles (internal in the sense that the sum over all these forces is ze...
void hGridFindOneSidedContacts(BaseParticle *obj) override
Finds contacts with the BaseParticle; avoids multiple checks.
bool hGridHasContactsInTargetCell(int x, int y, int z, unsigned int l, const BaseParticle *obj) const
Tests if the BaseParticle has contacts with other Particles 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 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.
void hGridUpdateParticle(BaseParticle *obj) override
Updates the cell (not the level) of a BaseParticle.
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...
Mercury3D()
This is the default constructor. All it does is set sensible defaults.
In the HGrid class, here all information about the HGrid is stored.
int getHGridZ() const
Returns particle's HGrid cell Z-coordinate.
This adds on the hierarchical grid code for 3D problems.
void setFirstBaseParticleInBucket(unsigned int i, BaseParticle *p)
Sets the first particle in bucket i to be the given BaseParticle.
void setHGridZ(const int z)
Sets the particle's HGrid cell Z-coordinate.
void setBucketIsChecked(unsigned int i)
Sets that the bucket with the given index is checked to true.
bool hGridHasParticleContacts(const BaseParticle *obj) override
Tests if a BaseParticle has any contacts in the HGrid.
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.
virtual void hGridFindContactsWithTargetCell(int x, int y, int z, unsigned int l, BaseParticle *obj)
Finds contacts between the BaseParticle and the target cell.
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.
int getHGridX() const
Returns particle's HGrid cell X-coordinate.