|
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 () override | |
Destructor, it destructs the InteractionHandler and all BaseInteraction it contains. More... | |
void | addObject (BaseInteraction *I) override |
Adds an Interaction to the InteractionHandler. More... | |
void | read (std::istream &is) |
void | readAndAddObject (std::istream &is) override |
Reads an Interaction into the InteractionHandler from restart data. More... | |
BaseInteraction * | getExistingInteraction (const BaseInteractable *P, const BaseInteractable *I) const |
Returns the Interaction between the BaseInteractable's P and I if it exists, otherwise returns a null pointer. More... | |
BaseInteraction * | addInteraction (BaseInteractable *P, BaseInteractable *I, unsigned timeStamp) |
void | resetNewObjectsOMP () |
void | addNewObjectsOMP () |
BaseInteraction * | getInteraction (BaseInteractable *P, BaseInteractable *I, unsigned timeStamp) |
Returns the Interaction between the BaseInteractable's P and I. More... | |
BaseInteraction * | createEmptyInteraction () const |
Creates an empty interaction. More... | |
void | deleteEmptyInteraction (BaseInteraction *interaction) const |
Deletes an empty interaction. More... | |
void * | createMPIInteractionDataArray (unsigned int numberOfInteractions) const |
creates an empty MPIInteractionDataArray More... | |
void | deleteMPIInteractionDataArray (void *dataArray) |
deletes an MPIInteractionDataArray More... | |
void | getInteractionDetails (void *interactionData, unsigned int index, unsigned int &identificationP, unsigned int &identificationI, bool &isWallInteraction, unsigned &timeStamp) |
reads the basic interaction details from an MPIInteractionDataArray More... | |
BaseInteraction * | getInteraction (BaseInteractable *P, BaseInteractable *I, unsigned 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 int id) |
Removes interactions of periodic particles when the periodic particles get deleted (see DPMBase::removeDuplicatePeriodicParticles) More... | |
void | eraseOldInteractions (unsigned) |
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) |
void | setWriteVTK (bool) |
FileType | getWriteVTK () const |
std::string | getName () const override |
Returns the name of the object. More... | |
double | getLiquidBridgeVolume () const |
unsigned | getNumberOfLiquidBridges () const |
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... | |
std::enable_if<!std::is_pointer< U >::value, U * >::type | copyAndAddGhostObject (const U &object) |
Creates a copy of a Object and adds it to the BaseHandler. This is one locally for inserting mpi particles, they avoid the global check if the particle can actually be inserted, because the mpi domain already knows that is the case. More... | |
std::enable_if< std::is_pointer< U >::value, U >::type | copyAndAddGhostObject (const U object) |
Creates a copy of a Object and adds it to the BaseHandler. This is one locally for inserting mpi particles, they avoid the global check if the particle can actually be inserted, because the mpi domain already knows that is the case. More... | |
virtual void | addExistingObject (BaseInteraction *O) |
Adds an existing object to the BaseHandler without changing the id of the object. More... | |
virtual void | addObject (BaseInteraction *object) |
Adds a new Object to the BaseHandler. More... | |
virtual void | addGhostObject (BaseInteraction *O) |
Adds a new Object to the BaseHandler. called by the to avoid increasing the id. More... | |
void | removeIf (const std::function< bool(BaseInteraction *)> cond) |
virtual void | removeObject (unsigned const int index) |
Removes an Object from the BaseHandler. More... | |
void | removeLastObject () |
Removes the last Object from the BaseHandler. More... | |
virtual 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... | |
std::vector< BaseInteraction * > | getObjectsById (const unsigned int id) |
Gets a vector of pointers to the objects with the specific id. 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... | |
virtual unsigned int | getNumberOfObjects () const |
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles) More... | |
unsigned int | getSize () const |
Gets the size of the particleHandler (including mpi and periodic particles) 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... | |
void | resize (const unsigned int N, const BaseInteraction &obj) |
Resizes the container to contain N elements. 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) |
void | increaseId () |
unsigned int | getNextId () |
void | setNextId (unsigned int id) |
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 () const |
now empty function for writing VTK files. More... | |
unsigned | getNextGroupId () |
Should be called each time you assign a groupId. Returns the value of nextGroupId_ and increases nextGroupId_ by one. More... | |
Public Attributes | |
std::vector< std::vector< BaseInteraction * > > | newObjects_ |
Private Attributes | |
FileType | writeVTK_ |
std::map< unsigned, BaseParticle * > | particleById |
std::map< unsigned, BaseWall * > | wallById |
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.
InteractionHandler::InteractionHandler | ( | ) |
Default constructor, it creates an empty InteractionHandler.
Constructor of the ParticleHandler class. It creates and empty ParticleHandler.
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.
|
override |
void InteractionHandler::actionsAfterTimeStep | ( | ) |
References constants::i.
Referenced by DPMBase::computeOneTimeStep(), and DPMBase::initialiseSolve().
BaseInteraction * InteractionHandler::addInteraction | ( | BaseInteractable * | P, |
BaseInteractable * | I, | ||
unsigned | timeStamp | ||
) |
References addObject(), BaseHandler< BaseInteraction >::getDPMBase(), BaseInteractable::getIndSpecies(), SpeciesHandler::getMixedObject(), BaseSpecies::getNewInteraction(), Global_Physical_Variables::P, and DPMBase::speciesHandler.
Referenced by DPMBase::readNextFStatFile().
void InteractionHandler::addNewObjectsOMP | ( | ) |
References addObject(), and newObjects_.
Referenced by DPMBase::computeAllForces().
|
override |
Adds an Interaction to the InteractionHandler.
[in] | P | A pointer to the BaseInteraction (or derived class) that has to be added. |
References BaseInteractable::addInteraction(), BaseHandler< T >::addObject(), BaseInteraction::getI(), BaseInteraction::getP(), and BaseInteraction::setHandler().
Referenced by addInteraction(), addNewObjectsOMP(), BaseInteraction::copySwitchPointer(), and getInteraction().
BaseInteraction * InteractionHandler::createEmptyInteraction | ( | ) | const |
Creates an empty interaction.
Returns the Interaction between the BaseInteractable's P and I.
Empty interactions are required when dealing with parallel code. it is used a proto type interaction that can handle the MPI interaction data type which is a void array
References BaseHandler< BaseInteraction >::getDPMBase(), BaseSpecies::getEmptyInteraction(), BaseHandler< T >::getObject(), and DPMBase::speciesHandler.
Referenced by createMPIInteractionDataArray(), deleteMPIInteractionDataArray(), and getInteractionDetails().
void * InteractionHandler::createMPIInteractionDataArray | ( | unsigned int | numberOfInteractions | ) | const |
creates an empty MPIInteractionDataArray
When sending interactions to other processors it is done with a void* array, because interactions come in many different sizes and shapes. The size of an interaction depends on the type f interaction. By creating an emptyInteraction, the size can be determined and an empty vector can be allocated
[in] | numberOfInteractions | The number of interactions that are added to the MPIInteractionDataArray |
References createEmptyInteraction(), BaseInteraction::createMPIInteractionDataArray(), and deleteEmptyInteraction().
Referenced by PeriodicBoundaryHandler::collectInteractionData(), Domain::performBoundaryDataTransmission(), and PeriodicBoundaryHandler::performNewParticleTransmission().
void InteractionHandler::deleteEmptyInteraction | ( | BaseInteraction * | interaction | ) | const |
Deletes an empty interaction.
When handling the Interaction MPI data type, an empty interaction is created. This function destroys that empty function again
[in,out] | interaction | Pointer to a base interaction that needs to be deleted |
References BaseSpecies::deleteEmptyInteraction(), BaseHandler< BaseInteraction >::getDPMBase(), BaseHandler< T >::getObject(), and DPMBase::speciesHandler.
Referenced by createMPIInteractionDataArray(), deleteMPIInteractionDataArray(), and getInteractionDetails().
void InteractionHandler::deleteMPIInteractionDataArray | ( | void * | dataArray | ) |
deletes an MPIInteractionDataArray
An empty interaction is created that can recast the data array into an array of the interactions. After the conversion the data of the array is cleaned up
[in] | dataArray | void pointer to a data array |
References createEmptyInteraction(), deleteEmptyInteraction(), and BaseInteraction::deleteMPIInteractionDataArray().
Referenced by Domain::finaliseBoundaryDataTransmission().
void InteractionHandler::eraseOldInteractions | ( | unsigned | currentNTime | ) |
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_. |
References BaseInteraction::actionsOnErase(), BaseHandler< BaseInteraction >::getNumberOfObjects(), BaseHandler< BaseInteraction >::getObject(), BaseInteraction::getTimeStamp(), and BaseHandler< BaseInteraction >::removeObject().
Referenced by DPMBase::computeOneTimeStep().
BaseInteraction * InteractionHandler::getExistingInteraction | ( | const BaseInteractable * | P, |
const 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. |
References constants::i, and Global_Physical_Variables::P.
Referenced by MeshTriangle::checkInteractions(), getInteraction(), and removeObjectKeepingPeriodics().
BaseInteraction * InteractionHandler::getInteraction | ( | BaseInteractable * | P, |
BaseInteractable * | I, | ||
unsigned | 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_. |
References addObject(), BaseHandler< BaseInteraction >::getDPMBase(), getExistingInteraction(), BaseInteractable::getIndSpecies(), SpeciesHandler::getMixedObject(), BaseSpecies::getNewInteraction(), newObjects_, Global_Physical_Variables::P, BaseInteraction::setHandler(), BaseInteraction::setSpecies(), BaseInteraction::setTimeStamp(), and DPMBase::speciesHandler.
Referenced by BaseParticle::getInteractionWith(), ArcWall::getInteractionWith(), BaseWall::getInteractionWith(), Combtooth::getInteractionWith(), MeshTriangle::getInteractionWith(), SineWall::getInteractionWith(), TriangleMeshWall::getInteractionWith(), TriangulatedWall::getInteractionWith(), VChute::getInteractionWith(), SuperQuadricParticle::getInteractionWithSuperQuad(), main(), readAndAddObject(), ChargedBondedInteractionSelfTest::setupInitialConditions(), TwoBondedParticleElasticCollision::setupInitialConditions(), UnionOfWalls::setupInitialConditions(), ChargedBondedParticleUnitTest::setupInitialConditions(), and MultiParticlesInsertion::setupInitialConditions().
BaseInteraction * InteractionHandler::getInteraction | ( | BaseInteractable * | P, |
BaseInteractable * | I, | ||
unsigned | 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_. |
References addObject(), Vec3D::dot(), BaseHandler< BaseInteraction >::getDPMBase(), BaseInteractable::getIndSpecies(), SpeciesHandler::getMixedObject(), BaseSpecies::getNewInteraction(), constants::i, Global_Physical_Variables::P, BaseInteraction::setSpecies(), BaseInteraction::setTimeStamp(), and DPMBase::speciesHandler.
void InteractionHandler::getInteractionDetails | ( | void * | interactionData, |
unsigned int | index, | ||
unsigned int & | identificationP, | ||
unsigned int & | identificationI, | ||
bool & | isWallInteraction, | ||
unsigned & | timeStamp | ||
) |
reads the basic interaction details from an MPIInteractionDataArray
because the interactionData array is a void pointer array, it is not possibly to directly read out the interaction data this function reads the basic information such as which objects are interacting and at what time.
[in] | interactionData | void pointer to the mpi interaction data |
[in] | index | The index of the interaction in the interaction data |
[out] | identificationP | the unique id of the P object |
[out] | idientificationI | the unique id of the I object |
[out] | isWallInteraction | a bool that flags if the interaction is a wall interaction or not |
[out] | timeStamp | reads the timestamp of the interaction |
References createEmptyInteraction(), deleteEmptyInteraction(), and BaseInteraction::getInteractionDetails().
Referenced by PeriodicBoundaryHandler::processLocalInteractionData(), PeriodicBoundaryHandler::processReceivedInteractionData(), and Domain::processReceivedInteractionData().
double InteractionHandler::getLiquidBridgeVolume | ( | ) | const |
References getMPISum(), constants::i, BaseParticle::isMPIParticle(), and BaseHandler< BaseInteraction >::objects_.
Referenced by LiquidMigrationMPI2Test::printTime(), and EvaporationAndHeatTest::printTime().
Mdouble InteractionHandler::getMeanOverlap | ( | ) | const |
The mean overlap of all interactions.
References n, and BaseHandler< BaseInteraction >::objects_.
Referenced by InitialConditions< SpeciesType >::getMeanRelativeContactRadius(), Sintering::getMeanRelativeContactRadius(), regimeForceUnitTest::getMeanRelativeContactRadius(), main(), GranuDrum::printTime(), Drum::printTime(), and RotatingDrumWet::printTime().
|
overridevirtual |
Returns the name of the object.
Implements BaseHandler< BaseInteraction >.
Referenced by read().
unsigned InteractionHandler::getNumberOfLiquidBridges | ( | ) | const |
References getMPISum(), constants::i, BaseParticle::isMPIParticle(), and BaseHandler< BaseInteraction >::objects_.
Referenced by RotatingDrumWet::printTime().
FileType InteractionHandler::getWriteVTK | ( | ) | const |
References writeVTK_.
Referenced by DPMBase::write(), DPMBase::writePythonFileForVTKVisualisation(), and DPMBase::writeVTKFiles().
InteractionHandler & InteractionHandler::operator= | ( | const InteractionHandler & | rhs | ) |
Assignment operator.
[in] | rhs | The BoundaryHandler on the right hand side of the assignment. |
References BaseHandler< BaseInteraction >::clear(), DEBUG, logger, and writeVTK_.
void InteractionHandler::read | ( | std::istream & | is | ) |
[in] | is | The input stream from which the information is read. |
References BaseHandler< BaseInteraction >::clear(), BaseHandler< BaseInteraction >::getDPMBase(), helpers::getLineFromStringStream(), getName(), constants::i, INFO, logger, particleById, readAndAddObject(), BaseHandler< BaseInteraction >::setStorageCapacity(), VERBOSE, and wallById.
Referenced by DPMBase::read().
|
overridevirtual |
Reads an Interaction into the InteractionHandler from restart data.
[in] | is | The input stream from which the information is read. |
Implements BaseHandler< BaseInteraction >.
References DEBUG, BaseHandler< BaseInteraction >::getDPMBase(), getInteraction(), BaseHandler< T >::getObjectsById(), logger, particleById, DPMBase::particleHandler, and wallById.
Referenced by read().
void InteractionHandler::removeObjectKeepingPeriodics | ( | unsigned 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. |
References getExistingInteraction(), BaseInteraction::getI(), BaseObject::getIndex(), BaseHandler< BaseInteraction >::getObject(), BaseInteraction::getP(), BaseParticle::getPeriodicFromParticle(), BaseInteraction::getTimeStamp(), Global_Physical_Variables::P, BaseHandler< T >::removeObject(), BaseHandler< BaseInteraction >::removeObject(), and BaseInteraction::setI().
Referenced by SilbertPeriodic::add_flow_particles(), and DPMBase::removeDuplicatePeriodicParticles().
void InteractionHandler::resetNewObjectsOMP | ( | ) |
References BaseHandler< BaseInteraction >::getDPMBase(), and newObjects_.
Referenced by DPMBase::computeAllForces().
void InteractionHandler::setWriteVTK | ( | bool | writeVTK | ) |
References MULTIPLE_FILES, NO_FILE, BaseHandler< BaseInteraction >::writeVTK(), and writeVTK_.
void InteractionHandler::setWriteVTK | ( | FileType | f | ) |
References writeVTK_.
Referenced by main(), DPMBase::read(), DPMBase::setInteractionsWriteVTK(), RotatingDrumWet::setupInitialConditions(), and MovingWalls::setupInitialConditions().
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. |
References BaseHandler< BaseInteraction >::getNumberOfObjects(), constants::i, MPIContainer::Instance(), and BaseHandler< BaseInteraction >::objects_.
Referenced by DPMBase::write().
std::vector<std::vector<BaseInteraction*> > InteractionHandler::newObjects_ |
Referenced by addNewObjectsOMP(), getInteraction(), and resetNewObjectsOMP().
|
private |
Referenced by read(), and readAndAddObject().
|
private |
Referenced by read(), and readAndAddObject().
|
private |
Referenced by getWriteVTK(), InteractionHandler(), operator=(), and setWriteVTK().