MercuryDPM
Beta
|
Container to store the pointers to all objects that one creates in a simulation. More...
#include <BaseHandler.h>
Public Member Functions | |
BaseHandler () | |
Default BaseHandler constructor, it creates an empty BaseHandler and assigns DPMBase_ to a null pointer. More... | |
BaseHandler (const BaseHandler< T > &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< T > &BH) |
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handler (container) to the other. More... | |
template<typename U > | |
U * | copyAndAddObject (const U &O) |
Creates a copy of a Object and adds it to the BaseHandler. More... | |
template<typename U > | |
U * | copyAndAddObject (U *O) |
Creates a copy of a Object and adds it to the BaseHandler. More... | |
virtual void | addObject (T *O) |
Adds a new Object to the BaseHandler. More... | |
virtual void | removeObject (unsigned const int id) |
Removes an Object from 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... | |
virtual void | readObject (std::istream &is)=0 |
Reads Object into the BaseHandler from restart data. More... | |
void | read (std::istream &is) |
Reads all objects from restart data. More... | |
T * | getObjectById (const unsigned int id) |
Gets a pointer to the Object at the specified index in the BaseHandler. More... | |
T * | getObject (const unsigned int id) |
Gets a pointer to the Object at the specified index in the BaseHandler. More... | |
const T * | getObject (const unsigned int id) const |
Gets a constant pointer to the Object at the specified index in the BaseHandler. More... | |
T * | getLastObject () |
Gets a pointer to the last Object in this BaseHandler. More... | |
const T * | 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< T * > ::const_iterator | begin () const |
Gets the begin of the const_iterator over all Object in this BaseHandler. More... | |
const std::vector< T * >::iterator | begin () |
Gets the begin of the iterator over all BaseBoundary in this BaseHandler. More... | |
const std::vector< T * > ::const_iterator | end () const |
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler. More... | |
const std::vector< T * >::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... | |
virtual std::string | getName () const =0 |
Gets the name of this handler. More... | |
Protected Attributes | |
std::vector< T * > | objects_ |
The actual list of Object pointers. More... | |
Private Attributes | |
unsigned int | maxObjects_ |
An integer to keep track of the largest number of objects ever stored in this BaseHandler. More... | |
unsigned int | nextId_ |
identifier for next object created More... | |
DPMBase * | DPMBase_ |
A pointer back to the DPMBase class. More... | |
Container to store the pointers to all objects that one creates in a simulation.
The BaseHandler allows one to create a container to store all pointer objects of a templated type T It is implemented by a (protected) vector of pointers to objects of type T. Once the container is created, the BaseHandler also provides the provision to manipulate the pointers i.e. by accessing, adding, deleting and few more operations by using its member methods.
Definition at line 50 of file BaseHandler.h.
BaseHandler< T >::BaseHandler | ( | ) |
Default BaseHandler constructor, it creates an empty BaseHandler and assigns DPMBase_ to a null pointer.
Definition at line 230 of file BaseHandler.h.
BaseHandler< T >::BaseHandler | ( | const BaseHandler< T > & | BH | ) |
Constructor that copies the objects of the given handler into itself and sets other variables to 0/nullptr.
[in] | BH | A reference to the BaseHandler that has to be copied. |
This is not a copy constructor! It only copies the vector objects_ from the given handler, and sets all other variables to 0/nullptr.
Definition at line 244 of file BaseHandler.h.
|
virtual |
Destructor, it destructs the BaseHandler and all Object it contains.
Definition at line 252 of file BaseHandler.h.
|
virtual |
Adds a new Object to the BaseHandler.
[in] | O | A pointer to the object that must be added. |
Reimplemented in WallHandler, ParticleHandler, BoundaryHandler, InteractionHandler, and SpeciesHandler.
Definition at line 284 of file BaseHandler.h.
Referenced by SpeciesHandler::addObject(), InteractionHandler::addObject(), BoundaryHandler::addObject(), ParticleHandler::addObject(), and WallHandler::addObject().
const std::vector< T * >::const_iterator BaseHandler< T >::begin | ( | ) | const |
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition at line 482 of file BaseHandler.h.
Referenced by ChuteWithHopper::addHopper(), DPMBase::broadPhase(), DPMBase::checkInteractionWithBoundaries(), MercuryBase::checkParticleForInteraction(), DPMBase::checkParticleForInteraction(), DPMBase::computeAllForces(), DPMBase::computeForcesDueToWalls(), Chute::createBottom(), DPMBase::gatherContactStatistics(), DPMBase::getElasticEnergy(), DPMBase::getKineticEnergy(), MercuryBase::hGridActionsBeforeTimeStep(), MercuryBase::hGridRebuild(), HGridOptimiser::initialise(), DPMBase::integrateAfterForceComputation(), DPMBase::integrateBeforeForceComputation(), ChuteBottom::makeRoughBottom(), DPMBase::outputInteractionDetails(), DPMBase::readNextDataFile(), DPMBase::solve(), DPMBase::write(), DPMBase::writeEneTimestep(), and DPMBase::writeFstatHeader().
const std::vector< T * >::iterator BaseHandler< T >::begin | ( | ) |
Gets the begin of the iterator over all BaseBoundary in this BaseHandler.
Definition at line 488 of file BaseHandler.h.
void BaseHandler< T >::clear | ( | ) |
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Delete all objects stored in objects_ and set the maximum number of objects that have been in this container to 0, and set the Id of the next object that will be added to 0.
Definition at line 360 of file BaseHandler.h.
Referenced by ParticleHandler::clear(), DPMBase::read(), DPMBase::readParAndIniFiles(), and ChuteBottom::setupInitialConditions().
Creates a copy of a Object and adds it to the BaseHandler.
[in] | O | A reference to the BaseHandler of which the objects have to be copied. |
Definition at line 268 of file BaseHandler.h.
Referenced by ChuteWithHopper::addHopper(), MaserBoundary::addParticleToMaser(), InsertionBoundary::checkBoundaryBeforeTimeStep(), Chute::createBottom(), DPMBase::readNextDataFile(), DPMBase::readParAndIniFiles(), ChuteBottom::setupInitialConditions(), Chute::setupInitialConditions(), ChuteWithHopper::setupInitialConditions(), and Chute::setupSideWalls().
Creates a copy of a Object and adds it to the BaseHandler.
[in] | O | A reference to the Object that has to be copied. |
Definition at line 276 of file BaseHandler.h.
void BaseHandler< T >::copyContentsFromOtherHandler | ( | const BaseHandler< T > & | BH | ) |
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handler (container) to the other.
[in] | BH | A reference to the BaseHandler of which the objects have to be copied. |
Definition at line 259 of file BaseHandler.h.
References BaseHandler< T >::objects_.
const std::vector< T * >::const_iterator BaseHandler< T >::end | ( | ) | const |
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition at line 494 of file BaseHandler.h.
Referenced by ChuteWithHopper::addHopper(), DPMBase::checkInteractionWithBoundaries(), MercuryBase::checkParticleForInteraction(), DPMBase::checkParticleForInteraction(), DPMBase::computeAllForces(), DPMBase::computeForcesDueToWalls(), Chute::createBottom(), DPMBase::gatherContactStatistics(), DPMBase::getElasticEnergy(), DPMBase::getKineticEnergy(), MercuryBase::hGridActionsBeforeTimeStep(), MercuryBase::hGridRebuild(), HGridOptimiser::initialise(), DPMBase::integrateAfterForceComputation(), DPMBase::integrateBeforeForceComputation(), ChuteBottom::makeRoughBottom(), DPMBase::outputInteractionDetails(), DPMBase::readNextDataFile(), DPMBase::solve(), DPMBase::write(), DPMBase::writeEneTimestep(), and DPMBase::writeFstatHeader().
const std::vector< T * >::iterator BaseHandler< T >::end | ( | ) |
Gets the end of the iterator over all BaseBoundary in this BaseHandler.
Definition at line 500 of file BaseHandler.h.
DPMBase * BaseHandler< T >::getDPMBase | ( | ) |
Gets the problem that is solved using this handler.
Definition at line 512 of file BaseHandler.h.
Referenced by MaserBoundary::addParticleToMaser(), SlidingFrictionInteraction::computeFrictionForce(), FrictionInteraction::computeFrictionForce(), BaseInteraction::gatherContactStatistics(), ParticleSpecies::getMassFromRadius(), BaseParticle::getParticleDimensions(), BaseParticle::integrateBeforeForceComputation(), WallHandler::operator=(), ParticleHandler::ParticleHandler(), ParticleSpecies::setDensity(), BaseParticle::setIndSpecies(), BaseWall::setSpecies(), BaseParticle::setSpecies(), LeesEdwardsBoundary::shiftVerticalPosition(), SpeciesHandler::SpeciesHandler(), WallHandler::WallHandler(), and LeesEdwardsBoundary::write().
DPMBase * BaseHandler< T >::getDPMBase | ( | ) | const |
Gets the problem that is solved using this handler and does not change the class.
Definition at line 526 of file BaseHandler.h.
T * BaseHandler< T >::getLastObject | ( | ) |
Gets a pointer to the last Object in this BaseHandler.
Definition at line 452 of file BaseHandler.h.
Referenced by LeesEdwardsBoundary::createVerticalPeriodicParticles(), and ChuteWithHopper::setupInitialConditions().
const T * BaseHandler< T >::getLastObject | ( | ) | const |
Gets a constant pointer to the last Object in this BaseHandler.
Definition at line 458 of file BaseHandler.h.
|
pure virtual |
Gets the name of this handler.
Implemented in ParticleHandler, InteractionHandler, SpeciesHandler, WallHandler, and BoundaryHandler.
unsigned int BaseHandler< T >::getNumberOfObjects | ( | ) | const |
Gets the number of Object in this BaseHandler.
Definition at line 464 of file BaseHandler.h.
Referenced by DPMBase::checkAndDuplicatePeriodicParticles(), DPMBase::checkSettings(), Chute::cleanChute(), MercuryBase::getHGridTargetMaxInteractionRadius(), MercuryBase::getHGridTargetMinInteractionRadius(), MercuryBase::getHGridTargetNumberOfBuckets(), MercuryBase::hGridNeedsRebuilding(), HGridOptimiser::initialise(), ChuteBottom::makeRoughBottom(), DPMBase::outputXBallsData(), Chute::printTime(), DPMBase::readNextDataFile(), DPMBase::removeDuplicatePeriodicParticles(), DPMBase::setFixedParticles(), ChuteBottom::setupInitialConditions(), Chute::setupInitialConditions(), and DPMBase::write().
T * BaseHandler< T >::getObject | ( | const unsigned int | index | ) |
Gets a pointer to the Object at the specified index in the BaseHandler.
[in] | index | the index of the requested Object. |
Definition at line 415 of file BaseHandler.h.
Referenced by DPMBase::checkAndDuplicatePeriodicParticles(), Chute::cleanChute(), ChuteBottom::makeRoughBottom(), DPMBase::removeDuplicatePeriodicParticles(), DPMBase::setFixedParticles(), BaseWall::setHandler(), BaseParticle::setHandler(), BaseWall::setIndSpecies(), BaseParticle::setIndSpecies(), Chute::setupInitialConditions(), ChuteWithHopper::setupInitialConditions(), and DPMBase::write().
const T * BaseHandler< T >::getObject | ( | const unsigned int | index | ) | const |
Gets a constant pointer to the Object at the specified index in the BaseHandler.
[in] | index | the index of the requested Object. |
Definition at line 434 of file BaseHandler.h.
T * BaseHandler< T >::getObjectById | ( | const unsigned int | id | ) |
Gets a pointer to the Object at the specified index in the BaseHandler.
[in] | id | The id of the requested Object. |
Definition at line 394 of file BaseHandler.h.
Referenced by InteractionHandler::readObject().
unsigned int BaseHandler< T >::getStorageCapacity | ( | ) | const |
Gets the storage capacity of this BaseHandler.
Definition at line 470 of file BaseHandler.h.
void BaseHandler< T >::read | ( | std::istream & | is | ) |
Reads all objects from restart data.
[in] | is | The input stream from which the information is read. |
Definition at line 374 of file BaseHandler.h.
References helpers::getLineFromStringStream(), logger, and VERBOSE.
Referenced by DPMBase::read(), and DPMBase::readOld().
|
pure virtual |
Reads Object into the BaseHandler from restart data.
[in] | is | The input stream from which the information is read. |
Implemented in ParticleHandler, WallHandler, BoundaryHandler, InteractionHandler, and SpeciesHandler.
void BaseHandler< T >::removeLastObject | ( | ) |
Removes the last Object from the BaseHandler.
Definition at line 345 of file BaseHandler.h.
Referenced by ParticleHandler::removeLastObject().
|
virtual |
Removes an Object from the BaseHandler.
This methods removes a particle. This methods invalidates ANY iterators to particles in this container. This method may shuffle the order of objects in this container.
[in] | index | An unsigned integer that gives the id of the Object that has to be removed. |
Reimplemented in ParticleHandler, and SpeciesHandler.
Definition at line 303 of file BaseHandler.h.
Referenced by BaseInteraction::removeFromHandler(), SpeciesHandler::removeObject(), ParticleHandler::removeObject(), and InteractionHandler::removeObjectKeepingPeriodics().
void BaseHandler< T >::setDPMBase | ( | DPMBase * | DPMBase | ) |
Sets the problem that is solved using this handler.
Definition at line 506 of file BaseHandler.h.
Referenced by DPMBase::constructor(), and DPMBase::DPMBase().
void BaseHandler< T >::setStorageCapacity | ( | const unsigned int | N | ) |
Sets the storage capacity of this BaseHandler.
[in] | N | The storage capacity the BaseHandler will have |
Definition at line 476 of file BaseHandler.h.
Referenced by DPMBase::constructor(), ChuteBottom::makeRoughBottom(), and ChuteBottom::setupInitialConditions().
|
private |
A pointer back to the DPMBase class.
Please note that this pointer back to the DPMBase class is a "shared" pointer and should not be deallocated by this class.
Definition at line 224 of file BaseHandler.h.
|
private |
An integer to keep track of the largest number of objects ever stored in this BaseHandler.
Definition at line 211 of file BaseHandler.h.
|
private |
identifier for next object created
Definition at line 216 of file BaseHandler.h.
|
protected |
The actual list of Object pointers.
The list of Object pointers. This handler is responsible for the memory-deallocation of these objects.
Definition at line 205 of file BaseHandler.h.
Referenced by BaseHandler< T >::copyContentsFromOtherHandler().