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)
196 int xs, ys, zs, xe, ye, ze;
204 for (
int x = xs; x <= xe; ++x)
206 for (
int y = ys; y <= ye; ++y)
208 for (
int z = zs; z <= ze; ++z)
221 for (
unsigned int level = 0; level <= startLevel; occupiedLevelsMask >>= 1, level++)
224 if (occupiedLevelsMask == 0)
230 if ((occupiedLevelsMask & 1) == 0)
235 if (level == startLevel)
258 int xs, ys, zs, xe, ye, ze;
266 for (
int x = xs; x <= xe; ++x)
268 for (
int y = ys; y <= ye; ++y)
270 for (
int z = zs; z <= ze; ++z)
295 int x =
static_cast<int>(std::floor(obj->
getPosition().
X * inv_size));
296 int y =
static_cast<int>(std::floor(obj->
getPosition().
Y * inv_size));
297 int z =
static_cast<int>(std::floor(obj->
getPosition().
Z * inv_size));
299 #ifdef CONTACT_LIST_HGRID
308 getPossibleContactList().remove_ParticlePosibleContacts(obj);
322 InsertObjAgainstGrid(obj);
413 logger(
INFO,
"HGrid needs rebuilding for \"bool Mercury3D::hGridHasParticleContacts(BaseParticle *obj)\"");
423 if (occupiedLevelsMask == 0)
425 logger(
VERBOSE,
"Level % and higher levels are empty", level);
430 if ((occupiedLevelsMask & 1) == 0)
436 int xs, ys, zs, xe, ye, ze;
445 logger(
VERBOSE,
"Level = % grid cells [%,%] x [%,%] x [%,%]", level, xs, xe, ys, ye, zs, ze);
446 for (
int x = xs; x <= xe; ++x)
448 for (
int y = ys; y <= ye; ++y)
450 for (
int z = zs; z <= ze; ++z)
464 #ifdef CONTACT_LIST_HGRID
474 void Mercury3D::InsertCell(
int x,
int y,
int z,
unsigned int l,
BaseParticle *obj)
484 getPossibleContactList().add_PossibleContact(obj,p);
514 if (occupiedLevelsMask_ == 0)
520 if ((occupiedLevelsMask_ & 1) == 0)
528 int xs, xe, ys, ye, zs, ze;
529 xs=
static_cast<int>(std::floor(ownXMin * inv_size - 0.5));
530 xe=
static_cast<int>(std::floor(ownXMax * inv_size + 0.5));
531 ys=
static_cast<int>(std::floor(ownYMin * inv_size - 0.5));
532 ye=
static_cast<int>(std::floor(ownYMax * inv_size + 0.5));
533 zs=
static_cast<int>(std::floor(ownZMin * inv_size - 0.5));
534 ze=
static_cast<int>(std::floor(ownZMax * inv_size + 0.5));
536 for(
int x=xs; x<=xe; ++x)
538 for(
int y=ys; y<=ye; ++y)
540 for(
int z=zs; z<=ze; ++z)
542 InsertCell(x, y, z, level, obj);
void hGridRemoveParticle(BaseParticle *obj)
Removes a BaseParticle from the HGrid.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Mdouble X
the vector components
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.