MercuryDPM
Beta
|
Container to store Interaction objects. More...
#include <InteractionHandler.h>
Public Member Functions | |
InteractionHandler () | |
Default constructor, it creates an empty InteractionHandler. More... | |
InteractionHandler (const InteractionHandler &IH) | |
Copy constructor, but since interactions must not be copied, it creates an empty InteractionHandler. More... | |
InteractionHandler | operator= (const InteractionHandler &rhs) |
Assignment operator. More... | |
~InteractionHandler () | |
Destructor, it destructs the InteractionHandler and all BaseInteraction it contains. More... | |
void | addObject (BaseInteraction *I) |
Adds an Interaction to the InteractionHandler. More... | |
void | readObject (std::istream &is) |
Reads an Interaction into the InteractionHandler from restart data. More... | |
BaseInteraction * | getExistingInteraction (BaseInteractable *P, BaseInteractable *I) |
Returns the Interaction between the BaseInteractable's P and I if it exists, otherwise returns a null pointer. More... | |
BaseInteraction * | getInteraction (BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp) |
Returns the Interaction between the BaseInteractable's P and I. More... | |
void | removeObjectKeepingPeriodics (unsigned const int id) |
Removes interactions of periodic particles when the periodic particles get deleted (see DPMBase::removeDuplicatePeriodicParticles) More... | |
void | eraseOldInteractions (Mdouble lastTimeStep) |
erases interactions which have an old timestamp. More... | |
void | write (std::ostream &os) const |
Writes the InteractionHandler to an output stream, for example a restart file. More... | |
std::string | getName () const |
Returns the name of the object. More... | |
Public Member Functions inherited from BaseHandler< BaseInteraction > | |
BaseHandler () | |
Default BaseHandler constructor, it creates an empty BaseHandler and assigns DPMBase_ to a null pointer. More... | |
BaseHandler (const BaseHandler< BaseInteraction > &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< BaseInteraction > &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... | |
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... | |
void | read (std::istream &is) |
Reads all objects from restart data. More... | |
BaseInteraction * | getObjectById (const unsigned int id) |
Gets a pointer to the Object at the specified index in the BaseHandler. More... | |
BaseInteraction * | getObject (const unsigned int id) |
Gets a pointer to the Object at the specified index in the BaseHandler. More... | |
const BaseInteraction * | getObject (const unsigned int id) const |
Gets a constant pointer to the Object at the specified index in the BaseHandler. More... | |
BaseInteraction * | getLastObject () |
Gets a pointer to the last Object in this BaseHandler. More... | |
const BaseInteraction * | 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 < BaseInteraction * > ::const_iterator | begin () const |
Gets the begin of the const_iterator over all Object in this BaseHandler. More... | |
const std::vector < BaseInteraction * > ::iterator | begin () |
Gets the begin of the iterator over all BaseBoundary in this BaseHandler. More... | |
const std::vector < BaseInteraction * > ::const_iterator | end () const |
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler. More... | |
const std::vector < BaseInteraction * > ::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... | |
Additional Inherited Members | |
Protected Attributes inherited from BaseHandler< BaseInteraction > | |
std::vector< BaseInteraction * > | objects_ |
The actual list of Object pointers. More... | |
Container to store Interaction objects.
The InteractionHandler is a container to store all Interaction objects. It is implemented as a vector of BaseInteraction pointers.
Definition at line 36 of file InteractionHandler.h.
InteractionHandler::InteractionHandler | ( | ) |
Default constructor, it creates an empty InteractionHandler.
Constructor of the ParticleHandler class. It creates and empty ParticleHandler.
Definition at line 39 of file InteractionHandler.cc.
InteractionHandler::InteractionHandler | ( | const InteractionHandler & | IH | ) |
Copy constructor, but since interactions must not be copied, it creates an empty InteractionHandler.
InteractionHandler::~InteractionHandler | ( | ) |
Destructor, it destructs the InteractionHandler and all BaseInteraction it contains.
Definition at line 72 of file InteractionHandler.cc.
|
virtual |
Adds an Interaction to the InteractionHandler.
[in] | P | A pointer to the BaseInteraction (or derived class) that has to be added. |
Reimplemented from BaseHandler< BaseInteraction >.
Definition at line 80 of file InteractionHandler.cc.
References BaseHandler< T >::addObject(), and BaseInteraction::setHandler().
Referenced by BaseInteraction::copySwitchPointer(), and getInteraction().
void InteractionHandler::eraseOldInteractions | ( | Mdouble | lastTimeStep | ) |
erases interactions which have an old timestamp.
Each interaction contains a time stamp, which stores the last time that an interaction object has been called. Thus, one can see that an interaction has ended by comparing the time stamp with the last value of DPMBase::time_. This function erases all interactions that have ended.
[in] | lastTimeStep | the last used value of DPMBase::time_. |
Definition at line 212 of file InteractionHandler.cc.
References BaseHandler< BaseInteraction >::getNumberOfObjects(), BaseHandler< BaseInteraction >::getObject(), BaseInteraction::getTimeStamp(), and BaseHandler< BaseInteraction >::removeObject().
Referenced by DPMBase::solve().
BaseInteraction * InteractionHandler::getExistingInteraction | ( | BaseInteractable * | P, |
BaseInteractable * | I | ||
) |
Returns the Interaction between the BaseInteractable's P and I if it exists, otherwise returns a null pointer.
[in] | P | the first BaseInteractable by which the interaction is defined. |
[in] | I | the first BaseInteractable by which the interaction is defined. |
Definition at line 93 of file InteractionHandler.cc.
References BaseInteractable::getInteractions().
Referenced by getInteraction(), and removeObjectKeepingPeriodics().
BaseInteraction * InteractionHandler::getInteraction | ( | BaseInteractable * | P, |
BaseInteractable * | I, | ||
Mdouble | timeStamp | ||
) |
Returns the Interaction between the BaseInteractable's P and I.
Returns a pointer to the existing Interaction, if the Interaction already exists otherwise creates a new Interaction and returns a pointer to it.
[in] | P | the first BaseInteractable by which the interaction is defined. |
[in] | I | the first BaseInteractable by which the interaction is defined. |
[in] | timeStamp | the current value of DPMBase::time_. |
Definition at line 114 of file InteractionHandler.cc.
References addObject(), BaseHandler< BaseInteraction >::getDPMBase(), getExistingInteraction(), BaseInteractable::getIndSpecies(), SpeciesHandler::getMixedObject(), BaseSpecies::getNewInteraction(), BaseInteraction::setSpecies(), BaseInteraction::setTimeStamp(), and DPMBase::speciesHandler.
Referenced by Coil::getInteractionWith(), AxisymmetricIntersectionOfWalls::getInteractionWith(), Screw::getInteractionWith(), CylindricalWall::getInteractionWith(), InfiniteWallWithHole::getInteractionWith(), InfiniteWall::getInteractionWith(), IntersectionOfWalls::getInteractionWith(), BaseParticle::getInteractionWith(), and readObject().
|
virtual |
Returns the name of the object.
Implements BaseHandler< BaseInteraction >.
Definition at line 232 of file InteractionHandler.cc.
InteractionHandler InteractionHandler::operator= | ( | const InteractionHandler & | rhs | ) |
Assignment operator.
[in] | rhs | The BoundaryHandler on the right hand side of the assignment. |
Definition at line 62 of file InteractionHandler.cc.
References BaseHandler< BaseInteraction >::clear(), DEBUG, and logger.
|
virtual |
Reads an Interaction into the InteractionHandler from restart data.
[in] | is | The input stream from which the information is read. |
Implements BaseHandler< BaseInteraction >.
Definition at line 251 of file InteractionHandler.cc.
References BaseHandler< BaseInteraction >::getDPMBase(), getInteraction(), helpers::getLineFromStringStream(), BaseHandler< T >::getObjectById(), DPMBase::particleHandler, and DPMBase::wallHandler.
void InteractionHandler::removeObjectKeepingPeriodics | ( | unsigned const int | id | ) |
Removes interactions of periodic particles when the periodic particles get deleted (see DPMBase::removeDuplicatePeriodicParticles)
Deleting the three periodic interactions between two real particles is difficult, because its interaction information has to be saved. If the two real particles interacted (which can be checked by looking at the time stamp), the interaction between the real particles is kept, and all interactions that involve ghost particles gets removed; otherwise, the interaction between the lower-indexed real particle with the ghost particle of the higher indexed particles is saved (with the ghost particle replaced by the real particle), and all other interactions removed.
This is what this function is intended for, and it does it in the following way: When an interaction is removed the periodic particle has to be stored in the I pointer So when an interaction is removed where P is normal and I is periodic, and the information is new it will be transfered when the index of P is lower than the index of the real particle of I.
[in] | the | id of the Interaction that needs to be deleted. |
Definition at line 154 of file InteractionHandler.cc.
References getExistingInteraction(), BaseInteraction::getI(), BaseObject::getIndex(), BaseHandler< BaseInteraction >::getObject(), BaseInteraction::getP(), BaseParticle::getPeriodicFromParticle(), BaseInteraction::getTimeStamp(), BaseHandler< T >::removeObject(), BaseHandler< BaseInteraction >::removeObject(), and BaseInteraction::setI().
Referenced by DPMBase::removeDuplicatePeriodicParticles().
void InteractionHandler::write | ( | std::ostream & | os | ) | const |
Writes the InteractionHandler to an output stream, for example a restart file.
[in] | os | The output stream where the InteractionHandler must be written to, usually a restart file. |
Definition at line 241 of file InteractionHandler.cc.
References BaseHandler< BaseInteraction >::getNumberOfObjects().
Referenced by DPMBase::write().