MercuryDPM
Beta
|
Container to store all BaseParticle. More...
#include <ParticleHandler.h>
Public Member Functions | |
ParticleHandler () | |
Default constructor, it creates an empty ParticleHandler. More... | |
ParticleHandler (const ParticleHandler &PH) | |
Constructor that copies all BaseParticle it contains and then sets the smallest and largest particle. More... | |
ParticleHandler | operator= (const ParticleHandler &rhs) |
Assignment operator. More... | |
~ParticleHandler () | |
Destructor, it destructs the ParticleHandler and all BaseParticle it contains. More... | |
virtual void | addObject (BaseParticle *P) |
Adds a BaseParticle to the ParticleHandler. More... | |
virtual void | removeObject (unsigned const int id) |
Removes a BaseParticle from the ParticleHandler. More... | |
void | removeLastObject () |
Removes the last BaseParticle from the ParticleHandler. More... | |
void | computeSmallestParticle () |
Computes the smallest particle (by interaction radius) and sets it in smallestParticle_. More... | |
void | computeLargestParticle () |
Computes the largest particle (by interaction radius) and sets it in largestParticle_. More... | |
BaseParticle * | getSmallestParticle () const |
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler. More... | |
BaseParticle * | getLargestParticle () const |
Gets a pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler. More... | |
BaseParticle * | getFastestParticle () const |
Gets a pointer to the fastest BaseParticle in this ParticleHandler. More... | |
BaseParticle * | getLowestPositionComponentParticle (const int i) const |
Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler. More... | |
BaseParticle * | getHighestPositionComponentParticle (const int i) const |
Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler. More... | |
BaseParticle * | getLowestVelocityComponentParticle (const int i) const |
Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler. More... | |
BaseParticle * | getHighestVelocityComponentParticle (const int i) const |
Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler. More... | |
BaseParticle * | getLightestParticle () const |
Gets a pointer to the lightest BaseParticle (by mass) in this ParticleHandler. More... | |
void | clear () |
Empties the whole ParticleHandler by removing all BaseParticle. More... | |
void | readObject (std::istream &is) |
Reads BaseParticle into the ParticleHandler from restart data. More... | |
void | readOldObject (std::string type, std::istream &is) |
Reads BaseParticle into the ParticleHandler from old-style restart data. More... | |
void | write (std::ostream &os) const |
void | checkExtrema (BaseParticle *P) |
Checks if the extrema of this ParticleHandler needs updating. More... | |
void | checkExtremaOnDelete (BaseParticle *P) |
Checks if the extrema of this ParticleHandler needs updating when a particle is deleted. More... | |
void | computeAllMasses (unsigned int indSpecies) |
Computes the mass for all BaseParticle of the given species in this ParticleHandler. More... | |
void | computeAllMasses () |
Computes the mass for all BaseParticle in this ParticleHandler. More... | |
std::string | getName () const |
Returns the name of the handler, namely the string "ParticleHandler". More... | |
Public Member Functions inherited from BaseHandler< BaseParticle > | |
BaseHandler () | |
Default BaseHandler constructor, it creates an empty BaseHandler and assigns DPMBase_ to a null pointer. More... | |
BaseHandler (const BaseHandler< BaseParticle > &BH) | |
Constructor that copies the objects of the given handler into itself and sets other variables to 0/nullptr. More... | |
virtual | ~BaseHandler () |
Destructor, it destructs the BaseHandler and all Object it contains. More... | |
void | copyContentsFromOtherHandler (const BaseHandler< BaseParticle > &BH) |
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handler (container) to the other. More... | |
U * | copyAndAddObject (const U &O) |
Creates a copy of a Object and adds it to the BaseHandler. More... | |
U * | copyAndAddObject (U *O) |
Creates a copy of a Object and adds it to the BaseHandler. More... | |
void | removeLastObject () |
Removes the last Object from the BaseHandler. More... | |
void | clear () |
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0. More... | |
void | read (std::istream &is) |
Reads all objects from restart data. More... | |
BaseParticle * | getObjectById (const unsigned int id) |
Gets a pointer to the Object at the specified index in the BaseHandler. More... | |
BaseParticle * | getObject (const unsigned int id) |
Gets a pointer to the Object at the specified index in the BaseHandler. More... | |
const BaseParticle * | getObject (const unsigned int id) const |
Gets a constant pointer to the Object at the specified index in the BaseHandler. More... | |
BaseParticle * | getLastObject () |
Gets a pointer to the last Object in this BaseHandler. More... | |
const BaseParticle * | getLastObject () const |
Gets a constant pointer to the last Object in this BaseHandler. More... | |
unsigned int | getNumberOfObjects () const |
Gets the number of Object in this BaseHandler. More... | |
unsigned int | getStorageCapacity () const |
Gets the storage capacity of this BaseHandler. More... | |
void | setStorageCapacity (const unsigned int N) |
Sets the storage capacity of this BaseHandler. More... | |
const std::vector < BaseParticle * > ::const_iterator | begin () const |
Gets the begin of the const_iterator over all Object in this BaseHandler. More... | |
const std::vector < BaseParticle * >::iterator | begin () |
Gets the begin of the iterator over all BaseBoundary in this BaseHandler. More... | |
const std::vector < BaseParticle * > ::const_iterator | end () const |
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler. More... | |
const std::vector < BaseParticle * >::iterator | end () |
Gets the end of the iterator over all BaseBoundary in this BaseHandler. More... | |
void | setDPMBase (DPMBase *DPMBase) |
Sets the problem that is solved using this handler. More... | |
DPMBase * | getDPMBase () |
Gets the problem that is solved using this handler. More... | |
DPMBase * | getDPMBase () const |
Gets the problem that is solved using this handler and does not change the class. More... | |
Private Attributes | |
BaseParticle * | largestParticle_ |
A pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler. More... | |
BaseParticle * | smallestParticle_ |
A pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler. More... | |
Additional Inherited Members | |
Protected Attributes inherited from BaseHandler< BaseParticle > | |
std::vector< BaseParticle * > | objects_ |
The actual list of Object pointers. More... | |
Container to store all BaseParticle.
The ParticleHandler is a container to store all BaseParticle. It is implemented by a vector of pointers to BaseParticle.
Definition at line 41 of file ParticleHandler.h.
ParticleHandler::ParticleHandler | ( | ) |
Default constructor, it creates an empty ParticleHandler.
Constructor of the ParticleHandler class. It creates and empty ParticleHandler.
Definition at line 39 of file ParticleHandler.cc.
References DEBUG, largestParticle_, logger, and smallestParticle_.
ParticleHandler::ParticleHandler | ( | const ParticleHandler & | PH | ) |
Constructor that copies all BaseParticle it contains and then sets the smallest and largest particle.
[in] | PH | The ParticleHandler that has to be copied. |
This is not a copy constructor! It copies the DPMBase and all BaseParticle, and sets the other variables to 0. After that, it computes the smallest and largest particle in this handler.
Definition at line 52 of file ParticleHandler.cc.
References clear(), computeLargestParticle(), computeSmallestParticle(), BaseHandler< BaseParticle >::copyContentsFromOtherHandler(), DEBUG, BaseHandler< T >::getDPMBase(), largestParticle_, logger, BaseHandler< BaseParticle >::objects_, BaseHandler< BaseParticle >::setDPMBase(), and smallestParticle_.
ParticleHandler::~ParticleHandler | ( | ) |
Destructor, it destructs the ParticleHandler and all BaseParticle it contains.
Set the pointers to largestParticle_ and smallestParticle_ to nullptr, all BaseParticle are destroyed by the BaseHandler afterwards.
Definition at line 96 of file ParticleHandler.cc.
References DEBUG, largestParticle_, logger, and smallestParticle_.
|
virtual |
Adds a BaseParticle to the ParticleHandler.
[in] | P | A pointer to the BaseParticle that has to be added. |
To add a BaseParticle to the ParticleHandler, first check if it has a species, since it is as common bug to use a BaseParticle without species, which leads to a segmentation fault. To help the user with debugging, a warning is given if a particle without species is added. After that, the actions for adding the particle to the BaseHandler are taken, which include adding it to the vector of pointers to all BaseParticle and assigning the correct id and index. Then the particle is added to the HGrid, the particle is told that this is its handler, its mass is computed and finally it is checked if this is the smallest or largest particle in this ParticleHandler.
Reimplemented from BaseHandler< BaseParticle >.
Definition at line 117 of file ParticleHandler.cc.
References BaseHandler< T >::addObject(), checkExtrema(), ParticleSpecies::computeMass(), BaseHandler< BaseParticle >::getDPMBase(), BaseInteractable::getSpecies(), DPMBase::hGridInsertParticle(), DPMBase::hGridUpdateParticle(), and BaseParticle::setHandler().
Referenced by CircularPeriodicBoundary::checkBoundaryAfterParticleMoved(), LeesEdwardsBoundary::createHorizontalPeriodicParticles(), CircularPeriodicBoundary::createPeriodicParticles(), MaserBoundary::createPeriodicParticles(), AngledPeriodicBoundary::createPeriodicParticles(), PeriodicBoundary::createPeriodicParticles(), and LeesEdwardsBoundary::createVerticalPeriodicParticles().
void ParticleHandler::checkExtrema | ( | BaseParticle * | P | ) |
Checks if the extrema of this ParticleHandler needs updating.
[in] | P | A pointer to the particle, which properties have to be checked against the ParticleHandlers extrema. |
Definition at line 488 of file ParticleHandler.cc.
References computeLargestParticle(), computeSmallestParticle(), BaseParticle::getInteractionRadius(), largestParticle_, and smallestParticle_.
Referenced by addObject(), and BaseParticle::setRadius().
void ParticleHandler::checkExtremaOnDelete | ( | BaseParticle * | P | ) |
Checks if the extrema of this ParticleHandler needs updating when a particle is deleted.
[in] | P | A pointer to the particle, which is going to get deleted. |
Definition at line 514 of file ParticleHandler.cc.
References computeLargestParticle(), computeSmallestParticle(), largestParticle_, and smallestParticle_.
Referenced by BaseParticle::~BaseParticle().
void ParticleHandler::clear | ( | ) |
Empties the whole ParticleHandler by removing all BaseParticle.
Note that the pointers to smallestParticle_ and largestParticle_ are set to nullptr since these particles don't exist anymore after calling this function.
Definition at line 389 of file ParticleHandler.cc.
References BaseHandler< T >::clear(), largestParticle_, and smallestParticle_.
Referenced by operator=(), ParticleHandler(), and DPMBase::read().
void ParticleHandler::computeAllMasses | ( | unsigned int | indSpecies | ) |
Computes the mass for all BaseParticle of the given species in this ParticleHandler.
[in] | indSpecies | Unsigned integer with the index of the species for which the masses must be computed. |
Definition at line 530 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::objects_.
Referenced by SpeciesHandler::addObject(), DPMBase::readNextDataFile(), ParticleSpecies::setDensity(), DPMBase::setParticleDimensions(), and DPMBase::solve().
void ParticleHandler::computeAllMasses | ( | ) |
Computes the mass for all BaseParticle in this ParticleHandler.
Definition at line 541 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::objects_.
void ParticleHandler::computeLargestParticle | ( | ) |
Computes the largest particle (by interaction radius) and sets it in largestParticle_.
Definition at line 192 of file ParticleHandler.cc.
References BaseParticle::getInteractionRadius(), BaseHandler< BaseParticle >::getNumberOfObjects(), largestParticle_, logger, BaseHandler< BaseParticle >::objects_, and WARN.
Referenced by checkExtrema(), checkExtremaOnDelete(), operator=(), and ParticleHandler().
void ParticleHandler::computeSmallestParticle | ( | ) |
Computes the smallest particle (by interaction radius) and sets it in smallestParticle_.
Definition at line 173 of file ParticleHandler.cc.
References BaseParticle::getInteractionRadius(), BaseHandler< BaseParticle >::getNumberOfObjects(), logger, BaseHandler< BaseParticle >::objects_, smallestParticle_, and WARN.
Referenced by checkExtrema(), checkExtremaOnDelete(), operator=(), and ParticleHandler().
BaseParticle * ParticleHandler::getFastestParticle | ( | ) | const |
Gets a pointer to the fastest BaseParticle in this ParticleHandler.
Definition at line 240 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects(), logger, BaseHandler< BaseParticle >::objects_, and WARN.
BaseParticle * ParticleHandler::getHighestPositionComponentParticle | ( | const int | i | ) | const |
Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler.
[in] | i | Direction for which one wants the particle with highest coordinates. |
Definition at line 290 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects(), logger, BaseHandler< BaseParticle >::objects_, and WARN.
BaseParticle * ParticleHandler::getHighestVelocityComponentParticle | ( | const int | i | ) | const |
Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler.
[in] | i | Direction for which you want the particle with highest velocity. |
Definition at line 341 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects(), logger, BaseHandler< BaseParticle >::objects_, and WARN.
BaseParticle * ParticleHandler::getLargestParticle | ( | ) | const |
Gets a pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition at line 228 of file ParticleHandler.cc.
References largestParticle_, logger, and WARN.
Referenced by LeesEdwardsBoundary::createHorizontalPeriodicParticles(), CircularPeriodicBoundary::createPeriodicParticles(), MaserBoundary::createPeriodicParticles(), AngledPeriodicBoundary::createPeriodicParticles(), PeriodicBoundary::createPeriodicParticles(), LeesEdwardsBoundary::createVerticalPeriodicParticles(), MercuryBase::getHGridTargetMaxInteractionRadius(), MercuryBase::hGridNeedsRebuilding(), HGridOptimiser::initialise(), and DPMBase::writeFstatHeader().
BaseParticle * ParticleHandler::getLightestParticle | ( | ) | const |
Gets a pointer to the lightest BaseParticle (by mass) in this ParticleHandler.
Definition at line 364 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects(), logger, BaseHandler< BaseParticle >::objects_, and WARN.
BaseParticle * ParticleHandler::getLowestPositionComponentParticle | ( | const int | i | ) | const |
Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler.
[in] | i | Direction for which you want the particle with lowest coordinates. |
Definition at line 265 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects(), logger, BaseHandler< BaseParticle >::objects_, and WARN.
BaseParticle * ParticleHandler::getLowestVelocityComponentParticle | ( | const int | i | ) | const |
Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler.
[in] | i | Direction for which you want the particle with lowest velocity. |
Definition at line 316 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects(), logger, BaseHandler< BaseParticle >::objects_, and WARN.
|
virtual |
Returns the name of the handler, namely the string "ParticleHandler".
Implements BaseHandler< BaseParticle >.
Definition at line 552 of file ParticleHandler.cc.
BaseParticle * ParticleHandler::getSmallestParticle | ( | ) | const |
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition at line 215 of file ParticleHandler.cc.
References logger, smallestParticle_, and WARN.
Referenced by MercuryBase::getHGridTargetMinInteractionRadius(), HGridOptimiser::initialise(), and DPMBase::writeFstatHeader().
ParticleHandler ParticleHandler::operator= | ( | const ParticleHandler & | rhs | ) |
Assignment operator.
[in] | rhs | The ParticleHandler on the right hand side of the assignment. |
This is not a copy assignment operator! It copies the DPMBase and all BaseParticle, and sets the other variables to 0. After that, it computes the smallest and largest particle in this handler.
Definition at line 74 of file ParticleHandler.cc.
References clear(), computeLargestParticle(), computeSmallestParticle(), BaseHandler< BaseParticle >::copyContentsFromOtherHandler(), DEBUG, largestParticle_, logger, BaseHandler< BaseParticle >::objects_, and smallestParticle_.
|
virtual |
Reads BaseParticle into the ParticleHandler from restart data.
[in] | is | The input stream from which the information is read. |
Implements BaseHandler< BaseParticle >.
Definition at line 399 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::copyAndAddObject(), ERROR, BaseObject::getId(), BaseHandler< BaseParticle >::getLastObject(), logger, BaseParticle::oldRead(), readOldObject(), and BaseObject::setId().
Referenced by DPMBase::read().
void ParticleHandler::readOldObject | ( | std::string | type, |
std::istream & | is | ||
) |
Reads BaseParticle into the ParticleHandler from old-style restart data.
[in] | type | The first value of the position. |
[in] | is | The input stream from which the information is read. |
The old objects did not have their type in the beginning of the line. Instead, the first string of the file was the position in x-direction. Since we already read the first string of the file, we need to give it to this function and convert it to the position in x-direction. The rest of the stream is then read in the usual way.
Definition at line 439 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::copyAndAddObject(), helpers::getLineFromStringStream(), logger, VERBOSE, Vec3D::X, Vec3D::Y, and Vec3D::Z.
Referenced by readObject().
void ParticleHandler::removeLastObject | ( | ) |
Removes the last BaseParticle from the ParticleHandler.
Function that removes the last object from this ParticleHandler. It also removes the particle from the HGrid.
Definition at line 164 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getDPMBase(), BaseHandler< BaseParticle >::getLastObject(), DPMBase::hGridRemoveParticle(), and BaseHandler< T >::removeLastObject().
Referenced by DPMBase::readNextDataFile().
|
virtual |
Removes a BaseParticle from the ParticleHandler.
[in] | id | The index of which BaseParticle has to be removed from this ParticleHandler. |
The BaseParticle at position id is removed by moving the last BaseParticle in the vector to the position of id. It also removes the BaseParticle from the HGrid.
Reimplemented from BaseHandler< BaseParticle >.
Definition at line 151 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getDPMBase(), BaseHandler< BaseParticle >::getObject(), DPMBase::hGridRemoveParticle(), and BaseHandler< T >::removeObject().
Referenced by DeletionBoundary::checkBoundaryAfterParticleMoved(), CircularPeriodicBoundary::checkBoundaryAfterParticleMoved(), Chute::cleanChute(), ChuteBottom::makeRoughBottom(), and DPMBase::removeDuplicatePeriodicParticles().
void ParticleHandler::write | ( | std::ostream & | os | ) | const |
Definition at line 477 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects().
Referenced by DPMBase::write().
|
private |
A pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition at line 180 of file ParticleHandler.h.
Referenced by checkExtrema(), checkExtremaOnDelete(), clear(), computeLargestParticle(), getLargestParticle(), operator=(), ParticleHandler(), and ~ParticleHandler().
|
private |
A pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition at line 185 of file ParticleHandler.h.
Referenced by checkExtrema(), checkExtremaOnDelete(), clear(), computeSmallestParticle(), getSmallestParticle(), operator=(), ParticleHandler(), and ~ParticleHandler().