36 #ifdef MERCURY_USE_OMP
46 logger(
DEBUG,
"InteractionHandler::InteractionHandler() finished");
60 logger(
DEBUG,
"InteractionHandler::InteractionHandler(const "
61 "InteractionHandler &IH) finished, please note that no interactions"
62 " have been copied.");
75 logger(
DEBUG,
"InteractionHandler::operator =(const InteractionHandler& rhs) finished.");
81 logger(
DEBUG,
"InteractionHandler::~InteractionHandler() finished");
109 if (
i->getI() == I) {
126 #ifdef MERCURY_USE_OMP
134 for (
auto object : objects) {
157 #ifdef MERCURY_USE_OMP
158 if (omp_get_num_threads()>1) {
191 return emptyInteraction;
249 unsigned int& identificationI,
bool& isWallInteraction,
253 emptyInteraction->
getInteractionDetails(interactionData, index, identificationP, identificationI, isWallInteraction,
273 if (
i->getI() == I &&
i->getTimeStamp() != timeStamp)
276 if (dNormal > dNormalMax)
279 dNormalMax = dNormal;
325 if (P !=
nullptr && I !=
nullptr)
335 if (iOther ==
nullptr)
339 if (iOther !=
nullptr)
402 i->actionsAfterTimeStep();
415 if (p->getOverlap() > 0)
417 sum += p->getOverlap();
429 return "InteractionHandler";
438 #ifdef MERCURY_USE_MPI
443 os <<
"Interactions " << totalNumberOfInteractions <<
'\n';
463 std::stringstream line;
483 for (
unsigned int i = 0;
i < N;
i++)
497 std::string type, dummy, idType;
498 unsigned int id0, id1;
504 logger(
DEBUG,
"InteractionHandler::readAndAddObject(is): reading type %.", type);
506 is >> idType >> id0 >> id1 >> dummy >> timeStampDouble;
507 timeStamp = timeStampDouble;
512 #ifdef MERCURY_USE_MPI
513 if (idType.compare(
"particleIds") == 0)
517 for (
int p0 = 0; p0 < list0.size(); p0++)
519 for (
int p1 = 0; p1 < list1.size(); p1++)
533 for (
int p0 = 0; p0 < list0.size(); p0++)
544 if (idType ==
"particleIds")
550 is.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
564 double liquidVolume = 0;
567 if (j and !static_cast<BaseParticle*>(j->getP())->isMPIParticle()) liquidVolume += j->
getLiquidBridgeVolume();
This class contains all information and functions required for communication between processors...
InteractionHandler & operator=(const InteractionHandler &rhs)
Assignment operator.
BaseInteraction * createEmptyInteraction() const
Creates an empty interaction.
unsigned int getIndex() const
Returns the index of the object in the handler.
virtual void deleteEmptyInteraction(BaseInteraction *interaction) const =0
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
void eraseOldInteractions(unsigned)
erases interactions which have an old timestamp.
virtual void actionsOnErase()
If an interaction needs to do something before it gets erased, add it here. E.g. Liquid bridges ruptu...
static MPIContainer & Instance()
fetch the instance to be used for communication
Defines the liquid bridge willet interaction between two particles or walls.
BaseSpecies is the class from which all other species are derived.
virtual void getInteractionDetails(void *interactionDataArray, unsigned int index, unsigned int &identificationP, unsigned int &identificationI, bool &isWallInteraction, unsigned &timeStamp)
void write(std::ostream &os) const
Writes the InteractionHandler to an output stream, for example a restart file.
FileType getWriteVTK() const
virtual void * createMPIInteractionDataArray(unsigned int numberOfInteractions) const
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
void addInteraction(BaseInteraction *I)
Adds an interaction to this BaseInteractable.
void * createMPIInteractionDataArray(unsigned int numberOfInteractions) const
creates an empty MPIInteractionDataArray
std::map< unsigned, BaseParticle * > particleById
void read(std::istream &is)
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this BaseHandler.
void setI(BaseInteractable *I)
Sets the second object involved in the interaction (often particle or wall).
const std::complex< Mdouble > i
std::vector< T * > getObjectsById(const unsigned int id)
Gets a vector of pointers to the objects with the specific id.
void resetNewObjectsOMP()
void removeObjectKeepingPeriodics(unsigned int id)
Removes interactions of periodic particles when the periodic particles get deleted (see DPMBase::remo...
~InteractionHandler() override
Destructor, it destructs the InteractionHandler and all BaseInteraction it contains.
InteractionHandler()
Default constructor, it creates an empty InteractionHandler.
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
void deleteMPIInteractionDataArray(void *dataArray)
deletes an MPIInteractionDataArray
BaseInteractable * getI()
Returns a pointer to the second object involved in the interaction (often a wall or a particle)...
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
void setTimeStamp(unsigned timeStamp)
Updates the time step of the interacting. Note, time steps used to find completed interactions...
Mdouble getTimeStamp() const
Returns an Mdouble which is the time stamp of the interaction.
Mdouble getMeanOverlap() const
The mean overlap of all interactions.
Stores information about interactions between two interactable objects; often particles but could be ...
std::string getName() const override
Returns the name of the object.
FileType
With FileType options, one is able to choose if data is to be read/written from/into no or single or ...
void deleteEmptyInteraction(BaseInteraction *interaction) const
Deletes an empty interaction.
void actionsAfterTimeStep()
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
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
file will not be created/read
Mdouble getLiquidBridgeVolume() const
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
virtual void removeObject(unsigned const int index)
Removes an Object from the BaseHandler.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Container to store Interaction objects.
BaseInteraction * addInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
void setHandler(InteractionHandler *handler)
Sets the pointer to the interaction hander which is storing this interaction.
virtual BaseInteraction * getEmptyInteraction() const =0
double getLiquidBridgeVolume() const
std::vector< std::vector< BaseInteraction * > > newObjects_
void setSpecies(const BaseSpecies *species)
Set the Species of the interaction; note this can either be a Species or MixedSpecies.
Vec3D getMPISum(Vec3D &val)
Sums the values over all processors using MPI_reduce.
void addObject(BaseInteraction *I) override
Adds an Interaction to the InteractionHandler.
std::vector< BaseInteraction * > objects_
The actual list of Object pointers.
Container to store the pointers to all objects that one creates in a simulation.
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles) ...
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
std::map< unsigned, BaseWall * > wallById
void setWriteVTK(FileType f)
const std::vector< BaseInteraction * > & getInteractions() const
Returns a list of interactions which belong to this interactable.
virtual void addObject(T *object)
Adds a new Object to the BaseHandler.
Defines the basic properties that a interactable object can have.
virtual BaseInteraction * getNewInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp) const =0
returns new Interaction object.
unsigned int getIndSpecies() const
Returns the index of the species associated with the interactable object.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
void readAndAddObject(std::istream &is) override
Reads an Interaction into the InteractionHandler from restart data.
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...
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
virtual void deleteMPIInteractionDataArray(void *dataArray)