MercuryDPM
Alpha
|
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 UNUSED) | |
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) const |
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... | |
BaseInteraction * | getInteraction (BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp, const Vec3D &normal) |
Returns the Interaction between the BaseInteractable's P and I closest to the contact point (should be used when multiple contacts are possible). 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 | actionsAfterTimeStep () |
Mdouble | getMeanOverlap () const |
The mean overlap of all interactions. More... | |
void | write (std::ostream &os) const |
Writes the InteractionHandler to an output stream, for example a restart file. More... | |
void | setWriteVTK (FileType f) |
FileType | getWriteVTK () const |
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... | |
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... | |
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... | |
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... | |
void | setId (BaseInteraction *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... | |
Private Attributes | |
FileType | writeVTK_ |
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 37 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.
References DEBUG, logger, NO_FILE, and writeVTK_.
InteractionHandler::InteractionHandler | ( | const InteractionHandler &IH | UNUSED | ) |
Copy constructor, but since interactions must not be copied, it creates an empty InteractionHandler.
[in] | IH | The InteractionHandler that has to be copied. |
This is not a copy constructor! It only clears all variables, since by default interactions are not copied.
Definition at line 51 of file InteractionHandler.cc.
References DEBUG, logger, and writeVTK_.
InteractionHandler::~InteractionHandler | ( | ) |
Destructor, it destructs the InteractionHandler and all BaseInteraction it contains.
Definition at line 75 of file InteractionHandler.cc.
void InteractionHandler::actionsAfterTimeStep | ( | ) |
Definition at line 278 of file InteractionHandler.cc.
Referenced by DPMBase::solve().
|
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 83 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 260 of file InteractionHandler.cc.
References BaseInteraction::actionsOnErase(), BaseHandler< BaseInteraction >::getNumberOfObjects(), BaseHandler< BaseInteraction >::getObject(), BaseInteraction::getTimeStamp(), and BaseHandler< BaseInteraction >::removeObject().
Referenced by DPMBase::solve().
BaseInteraction * InteractionHandler::getExistingInteraction | ( | BaseInteractable * | P, |
BaseInteractable * | I | ||
) | const |
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 96 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 117 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 TriangulatedWall::getInteractionWith(), BaseWall::getInteractionWith(), BaseParticle::getInteractionWith(), and readObject().
BaseInteraction * InteractionHandler::getInteraction | ( | BaseInteractable * | P, |
BaseInteractable * | I, | ||
Mdouble | timeStamp, | ||
const Vec3D & | normal | ||
) |
Returns the Interaction between the BaseInteractable's P and I closest to the contact point (should be used when multiple contacts are possible).
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 149 of file InteractionHandler.cc.
References addObject(), Vec3D::dot(), BaseHandler< BaseInteraction >::getDPMBase(), BaseInteractable::getIndSpecies(), BaseInteractable::getInteractions(), SpeciesHandler::getMixedObject(), BaseSpecies::getNewInteraction(), BaseInteraction::setSpecies(), BaseInteraction::setTimeStamp(), and DPMBase::speciesHandler.
Mdouble InteractionHandler::getMeanOverlap | ( | ) | const |
The mean overlap of all interactions.
Definition at line 289 of file InteractionHandler.cc.
References BaseHandler< BaseInteraction >::getNumberOfObjects(), and BaseHandler< BaseInteraction >::objects_.
|
virtual |
Returns the name of the object.
Implements BaseHandler< BaseInteraction >.
Definition at line 302 of file InteractionHandler.cc.
FileType InteractionHandler::getWriteVTK | ( | ) | const |
Definition at line 460 of file InteractionHandler.cc.
References writeVTK_.
Referenced by DPMBase::write(), writeVTK(), and DPMBase::writeVTK().
InteractionHandler InteractionHandler::operator= | ( | const InteractionHandler & | rhs | ) |
Assignment operator.
[in] | rhs | The BoundaryHandler on the right hand side of the assignment. |
Definition at line 64 of file InteractionHandler.cc.
References BaseHandler< BaseInteraction >::clear(), DEBUG, logger, and writeVTK_.
|
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 321 of file InteractionHandler.cc.
References BaseHandler< BaseInteraction >::getDPMBase(), getInteraction(), helpers::getLineFromStringStream(), BaseHandler< T >::getObjectById(), logger, DPMBase::particleHandler, VERBOSE, 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 200 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::setWriteVTK | ( | FileType | f | ) |
Definition at line 456 of file InteractionHandler.cc.
References writeVTK_.
Referenced by main(), and DPMBase::read().
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 311 of file InteractionHandler.cc.
References BaseHandler< BaseInteraction >::getNumberOfObjects(), and BaseHandler< BaseInteraction >::objects_.
Referenced by DPMBase::write().
void InteractionHandler::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 353 of file InteractionHandler.cc.
References BaseHandler< BaseInteraction >::getDPMBase(), BaseHandler< BaseInteraction >::getLastObject(), Files::getName(), BaseInteraction::getNameVTK(), BaseInteraction::getNumberOfFieldsVTK(), BaseHandler< BaseInteraction >::getNumberOfObjects(), BaseInteraction::getTypeVTK(), getWriteVTK(), INFO, logger, NO_FILE, helpers::to_string(), and WARN.
Referenced by DPMBase::writeVTK().
|
private |
Definition at line 133 of file InteractionHandler.h.
Referenced by getWriteVTK(), InteractionHandler(), operator=(), and setWriteVTK().