MercuryDPM
Alpha
|
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 index) |
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... | |
Mdouble | getMeanRadius () 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... | |
void | writeVTK () const |
Writes all particles into a vtk file format (unstructured grid), consisting of particle positions, velocities, radii and type of species (IndSpecies) 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... | |
std::enable_if <!std::is_pointer< U >::value, U * >::type | copyAndAddObject (const U &object) |
Creates a copy of a Object and adds it to the BaseHandler. More... | |
std::enable_if < std::is_pointer< U >::value, U >::type | copyAndAddObject (const U object) |
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... | |
void | setId (BaseParticle *object, unsigned int id) |
This function sets the id and ensures that nextId is a bigger value than id. 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... | |
virtual void | writeVTK () |
Over written in WallHandler and ParticleHandler. More... | |
Static Public Member Functions | |
static BaseParticle * | getNewObject (const std::string &type) |
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 40 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 42 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 55 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 99 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 120 of file ParticleHandler.cc.
References BaseHandler< T >::addObject(), checkExtrema(), ParticleSpecies::computeMass(), BaseHandler< BaseParticle >::getDPMBase(), BaseObject::getId(), BaseInteractable::getSpecies(), DPMBase::hGridInsertParticle(), DPMBase::hGridUpdateParticle(), logger, BaseParticle::setHandler(), and WARN.
Referenced by CircularPeriodicBoundary::checkBoundaryAfterParticleMoved(), LeesEdwardsBoundary::createHorizontalPeriodicParticles(), ShearBoxBoundary::createHorizontalPeriodicParticles(), CircularPeriodicBoundary::createPeriodicParticles(), MaserBoundary::createPeriodicParticles(), AngledPeriodicBoundary::createPeriodicParticles(), PeriodicBoundary::createPeriodicParticles(), ShearBoxBoundary::createVerticalPeriodicParticles(), 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 548 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 574 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 402 of file ParticleHandler.cc.
References BaseHandler< T >::clear(), largestParticle_, and smallestParticle_.
Referenced by operator=(), ParticleHandler(), FileReader::read(), 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 590 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 601 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 194 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 175 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 242 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 303 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 354 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 230 of file ParticleHandler.cc.
References largestParticle_, logger, and WARN.
Referenced by DPMBase::checkParticleForInteractionLocalPeriodic(), LeesEdwardsBoundary::createHorizontalPeriodicParticles(), ShearBoxBoundary::createHorizontalPeriodicParticles(), CircularPeriodicBoundary::createPeriodicParticles(), MaserBoundary::createPeriodicParticles(), AngledPeriodicBoundary::createPeriodicParticles(), PeriodicBoundary::createPeriodicParticles(), LeesEdwardsBoundary::createVerticalPeriodicParticles(), ShearBoxBoundary::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 377 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 278 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 329 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects(), logger, BaseHandler< BaseParticle >::objects_, and WARN.
Mdouble ParticleHandler::getMeanRadius | ( | ) | const |
Gets a pointer to the fastest BaseParticle in this ParticleHandler.
Definition at line 265 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects(), and BaseHandler< BaseParticle >::objects_.
|
virtual |
Returns the name of the handler, namely the string "ParticleHandler".
Implements BaseHandler< BaseParticle >.
Definition at line 612 of file ParticleHandler.cc.
|
static |
Definition at line 409 of file ParticleHandler.cc.
Referenced by InsertionBoundary::read().
BaseParticle * ParticleHandler::getSmallestParticle | ( | ) | const |
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition at line 217 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 77 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 429 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::copyAndAddObject(), DEBUG, ERROR, BaseHandler< BaseParticle >::getDPMBase(), BaseObject::getId(), BaseInteractable::getIndSpecies(), BaseHandler< BaseParticle >::getLastObject(), logger, BaseParticle::oldRead(), readOldObject(), BaseParticle::setHandler(), BaseHandler< BaseParticle >::setId(), and BaseParticle::setSpecies().
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 499 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::copyAndAddObject(), BaseHandler< BaseParticle >::getDPMBase(), 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 166 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] | index | The index of which BaseParticle has to be removed from this ParticleHandler. |
The BaseParticle with index is removed and the last BaseParticle in the vector is moved to its position. It also removes the BaseParticle from the HGrid.
Reimplemented from BaseHandler< BaseParticle >.
Definition at line 153 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(), and DPMBase::removeDuplicatePeriodicParticles().
void ParticleHandler::write | ( | std::ostream & | os | ) | const |
Definition at line 537 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getNumberOfObjects().
Referenced by DPMBase::write().
void ParticleHandler::writeVTK | ( | ) | const |
Writes all particles into a vtk file format (unstructured grid), consisting of particle positions, velocities, radii and type of species (IndSpecies)
Writes all points ans cells to a file in the VTK format. The filename is hard-coded in this method, and is based on the name of the DPMBase and has a unique counter in it to ensure there are no two files with the same name.
Definition at line 623 of file ParticleHandler.cc.
References BaseHandler< BaseParticle >::getDPMBase(), DPMBase::getInfo(), BaseHandler< BaseParticle >::getLastObject(), Files::getName(), BaseParticle::getNameVTK(), BaseParticle::getNumberOfFieldsVTK(), BaseHandler< BaseParticle >::getNumberOfObjects(), BaseParticle::getTypeVTK(), INFO, logger, helpers::to_string(), and WARN.
Referenced by main(), and DPMBase::writeVTK().
|
private |
A pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition at line 192 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 197 of file ParticleHandler.h.
Referenced by checkExtrema(), checkExtremaOnDelete(), clear(), computeSmallestParticle(), getSmallestParticle(), operator=(), ParticleHandler(), and ~ParticleHandler().