37 logger(
DEBUG,
"MercuryBase::MercuryBase() constructor finished");
47 logger(
DEBUG,
"MercuryBase::~MercuryBase() destructor finished.");
73 logger(
DEBUG,
"HGRID_base(HGrid_base& other) constructor finished.");
109 std::stringstream line(std::stringstream::in | std::stringstream::out);
114 line >> dummy >> dummy
143 os <<
"NUM_BUCKETS " << 0.0 <<
" "
204 std::vector<Mdouble> cellSizes;
208 if(minParticleInteractionRadius == 0.0 || minParticleInteractionRadius == maxParticleInteractionRadius)
215 cellSizes.push_back(maxCellSize);
218 logger(
INFO,
"While rebuilding the hgrid: the number of levels was "
219 "set to one, as the particle distribution is monodispersed");
233 cellSizes.push_back(minCellSize + (maxCellSize - minCellSize)
237 cellSizes.push_back(maxCellSize);
247 cellSizes.push_back(minCellSize
248 * std::pow(maxCellSize / minCellSize, static_cast<Mdouble>(i + 1)
252 cellSizes.push_back(maxCellSize);
270 cellSizes.push_back(minCellSize * std::pow(2, i));
288 (*it)->setHGridX(9999);
305 #ifdef CONTACT_LIST_HGRID
327 static int stepsBeforeUpdate = 0;
334 stepsBeforeUpdate = 0;
338 #ifndef CONTACT_LIST_HGRID
343 #ifndef CONTACT_LIST_HGRID
351 stepsBeforeUpdate = 0;
408 logger(
WARN,
"In Mdouble MercuryBase::userHGridCellSize(unsigned int level) with level= %", level);
409 logger(
WARN,
"If you want to use user defined HGrid cell sizes, this function should be redefined");
421 if (!strcmp(argv[i],
"-hGridMaxLevels"))
425 else if (!strcmp(argv[i],
"-cellOverSizeRatio"))
524 logger(
VERBOSE,
"HGrid needs updating, because there is no grid.");
529 logger(
VERBOSE,
"HGrid needs updating, because some of its initialisation parameters have changed.");
534 logger(
VERBOSE,
"HGrid needs updating, because said so by the grid itself");
617 if ((*it)->getDistanceAndNormal(p, distance, normal))
644 std::cout <<
"Status of hGrid parameters:" << std::endl;
645 std::cout <<
"HGridMethod hGridMethod_=" <<
hGridMethod_ << std::endl;
646 std::cout <<
"HGridDistribution hGridDistribution_=" <<
hGridDistribution_ << std::endl;
651 std::cout <<
"unsigned int hGridMaxLevels_=" <<
hGridMaxLevels_ << std::endl;
658 std::cout <<
"hGrid does not exist yet" << std::endl;
BaseParticle * getLargestParticle() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
const std::vector< double > & getCellSizes() const
Gets the sizes of the cells at all levels as a vector.
virtual void hGridFindOneSidedContacts(BaseParticle *obj)=0
This is a purely virtual function that checks if an object is in the grid, this code is dimension dep...
virtual void write(std::ostream &os, bool writeAllParticles=true) const
Loads all MD data and plots statistics for all timesteps in the .data file.
virtual void hGridUpdateParticle(BaseParticle *obj UNUSED)
no implementation but can be overidden in its derived classes.
bool checkParticleForInteraction(const BaseParticle &P) override
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
bool hGridNeedsRebuilding()
Gets if the HGrid needs rebuilding before anything else happens.
Mdouble totalCurrentMaxRelativeDisplacement_
After each time step, this Mdouble is increased by 2*currentMaxRelativeDisplacement_.
Mdouble getHGridCellOverSizeRatio() const
Gets the ratio of the smallest cell over the smallest particle.
HGrid * grid
A pointer to the HGrid associated with this MercuryBase.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Mdouble getHGridCurrentMaxRelativeDisplacement() const
Returns hGridCurrentMaxRelativeDisplacement_.
void insertParticleToHgrid(BaseParticle *obj)
Inserts the given BaseParticle in to the HGrid.
virtual unsigned int getHGridTargetNumberOfBuckets() const
Gets the desired number of buckets, which is the maximum of the number of particles and 10...
void setHGridUpdateEachTimeStep(bool updateEachTimeStep)
Sets whether or not the HGrid must be updated every time step.
void info() const
Displays the member variables of the hGrid object. This function is intended for debugging the hGrid...
void clearFirstBaseParticleInBucket()
For all buckets, it removes the pointer to the first BaseParticle in it, practically emptying the buc...
virtual Mdouble getHGridTargetMinInteractionRadius() const
Gets the desired size of the smallest cells of the HGrid.
HGridDistribution hGridDistribution_
Indicator for the distribution of the sizes of the cells of different levels of the HGrid...
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
unsigned int hGridMaxLevels_
Unsigned integer that indicates the maximum number of levels of the HGrid.
HGridMethod getHGridMethod() const
Gets whether the HGrid in this MercuryBase is BOTTOMUP or TOPDOWN.
Mdouble getCellOverSizeRatio() const
Gets the maximum ratio of the cell to a particle it contains.
void hGridUpdateMove(BaseParticle *iP, Mdouble move) override
Computes the relative displacement of the given BaseParticle and updates the currentMaxRelativeDispla...
Mdouble hGridCellOverSizeRatio_
The maximum ratio between the size of the cells and the BaseParticle they contain.
unsigned int getHGridMaxLevels() const
Gets the maximum number of levels of the HGrid in this MercuryBase.
void hGridActionsBeforeTimeStep() override
Performs all necessary actions before a time-step, like updating the particles and resetting all the ...
void hGridInfo() const
Writes the info of the HGrid to the screen in a nice format.
virtual Mdouble getHGridTargetMaxInteractionRadius() const
Gets the desired size of the largest cells of the HGrid.
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
HGridMethod
Enum class that indicates how particles in different levels (cross level checking) of the HGrid are c...
void setHGridMethod(HGridMethod hGridMethod)
Sets the HGridMethod to either BOTTOMUP or TOPDOWN.
HGridMethod hGridMethod_
Indicator of which way the interactions between different levels are tested.
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
Mdouble getHGridTotalCurrentMaxRelativeDisplacement() const
Returns hGridTotalCurrentMaxRelativeDisplacement_.
void hGridActionsAfterIntegration() override
Sets the totalCurrentMaxRelativeDisplacement_ as 2*currentMaxRelativeDisplacement_.
BaseParticle * getSmallestParticle() const
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
void write(std::ostream &os, bool writeAllParticles=true) const override
Writes the MercuryBase to an output stream, for example a restart file.
virtual bool readNextArgument(int &i, int argc, char *argv[])
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
In the HGrid class, here all information about the HGrid is stored.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
bool readNextArgument(int &i, int argc, char *argv[]) override
Reads the next command line argument.
void hGridInsertParticle(BaseParticle *obj) override
Inserts a single Particle to current grid.
void clearBucketIsChecked()
Sets all buckets to not-checked.
~MercuryBase()
This is the default destructor.
void setHGridCellOverSizeRatio(Mdouble cellOverSizeRatio)
Sets the ratio of the smallest cell over the smallest particle.
HGridDistribution
Enum that indicates what the ratio of the size of the cells in different levels is.
bool updateEachTimeStep_
Boolean which indicates whether or not the cell in which a particle is must be updated every timestep...
void setHGridMaxLevels(unsigned int HGridMaxLevels)
Sets the maximum number of levels of the HGrid in this MercuryBase.
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
void hGridActionsBeforeTimeLoop() override
This sets up the broad phase information, has to be done at this stage because it requires the partic...
bool isEqual(Mdouble v1, Mdouble v2, double absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
MercuryBase()
This is the default constructor. It sets sensible defaults.
void hGridRebuild()
This sets up the parameters required for the contact model.
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
double getCellSize(unsigned int i) const
Gets the size of the cells at the given level.
virtual bool hGridHasParticleContacts(const BaseParticle *obj)=0
Purely virtual function that checks if the given particle has a possible contact with any other BaseP...
HGridDistribution getHGridDistribution() const
Gets how the sizes of the cells of different levels are distributed.
void constructor()
This is the actual constructor, it is called do both constructors above.
bool gridNeedsUpdate_
Boolean that indicates whether or not the grid needs to be updated.
void read(std::istream &is) override
Reads the MercuryBase from an input stream, for example a restart file.
bool getNeedsRebuilding() const
Gets whether or not the grid needs to be rebuilt before something else is done with it...
bool getHGridUpdateEachTimeStep() const override
Gets whether or not the HGrid is updated every time step.
void broadPhase(BaseParticle *i) override
This checks particles in the HGRID to see if for closer enough for possible contact.
Implementation of a 3D vector (by Vitaliy).
virtual Mdouble userHGridCellSize(unsigned int level)
Virtual function that enables inheriting classes to implement a function to let the user set the cell...
unsigned int getHGridLevel() const
Returns particle's HGrid level.
void setHGridDistribution(HGridDistribution hGridDistribution)
Sets how the sizes of the cells of different levels are distributed.
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.
virtual void read(std::istream &is)
Reads all particle data into a restart file.
Mdouble currentMaxRelativeDisplacement_
Mdouble that denotes the maximum of the displacement of a particle divided by the cell size of the le...
void hGridActionsBeforeIntegration() override
Resets the currentMaxRelativeDisplacement_ to 0.
unsigned int getNumberOfBuckets() const
Gets the number of buckets of this HGrid.