42 logger(
DEBUG,
"InteractionHandler::InteractionHandler() finished");
56 logger(
DEBUG,
"InteractionHandler::InteractionHandler(const "
57 "InteractionHandler &IH) finished, please note that no interactions"
58 " have been copied.");
71 logger(
DEBUG,
"InteractionHandler::operator =(const InteractionHandler& rhs) finished.");
77 logger(
DEBUG,
"InteractionHandler::~InteractionHandler() finished");
155 if (i->getI() == I && i->getTimeStamp() != timeStamp)
158 if (dNormal > dNormalMax)
161 dNormalMax = dNormal;
206 if (P !=
nullptr && I !=
nullptr)
216 if (iOther ==
nullptr)
220 if (iOther !=
nullptr)
282 i->actionsAfterTimeStep();
294 sum += p->getOverlap();
304 return "InteractionHandler";
315 os << (*i) << std::endl;
323 std::string type, dummy, idType;
324 unsigned int id0, id1;
327 std::stringstream line(std::stringstream::in | std::stringstream::out);
330 line >> type >> idType >> id0 >> id1 >> dummy >> timeStamp;
331 logger(
VERBOSE,
"InteractionHandler::readObject(is): reading type % % %", type, id0, id1);
334 if (idType.compare(
"particleIds") == 0) {
358 static unsigned fileCounter = 0;
364 file.open(fileName.c_str(), std::ios::out);
368 logger(
WARN,
"Error in writeToFile: file % could not be opened", fileName);
371 file <<
"<?xml version=\"1.0\"?>\n\n";
372 file <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
373 file <<
"<UnstructuredGrid>\n";
374 file <<
"<Piece NumberOfPoints=\"" << this->
getNumberOfObjects() <<
"\" NumberOfCells=\"" << 0 <<
"\">\n";
375 file <<
"<Points>\n";
376 file <<
" <DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">\n";
377 for (
const auto &p: *
this)
379 file <<
'\t' << p->getContactPoint() <<
'\n';
381 file <<
" </DataArray>\n";
382 file <<
"</Points>\n";
383 file <<
"<PointData Vectors=\"vector\">\n";
384 file <<
" <DataArray type=\"Float32\" Name=\"Normal\" NumberOfComponents=\"3\" format=\"ascii\">\n";
386 for (
const auto &p: *
this)
388 file <<
'\t' << p->getNormal() <<
'\n';
390 file <<
" </DataArray>\n";
391 file <<
" <DataArray type=\"Float32\" Name=\"Overlap\" format=\"ascii\">\n";
393 for (
const auto &p: *
this)
395 file <<
'\t' << p->getOverlap() <<
'\n';
397 file <<
" </DataArray>\n";
398 file <<
" <DataArray type=\"Float32\" Name=\"ContactRadius\" format=\"ascii\">\n";
400 for (
const auto &p: *
this)
402 file <<
'\t' << p->getContactRadius() <<
'\n';
404 file <<
" </DataArray>\n";
405 file <<
" <DataArray type=\"Float32\" Name=\"Force\" format=\"ascii\">\n";
407 for (
const auto &p: *
this)
409 file <<
'\t' << p->getForce() <<
'\n';
411 file <<
" </DataArray>\n";
412 file <<
" <DataArray type=\"Float32\" Name=\"TangentialOverlap\" format=\"ascii\">\n";
414 for (
const auto &p: *
this)
416 file <<
'\t' << p->getTangentialOverlap() <<
'\n';
418 file <<
" </DataArray>\n";
419 file <<
" <DataArray type=\"Float32\" Name=\"Torque\" format=\"ascii\">\n";
421 for (
const auto &p: *
this)
423 file <<
'\t' << p->getTorque() <<
'\n';
425 file <<
" </DataArray>\n";
433 for (
const auto &p: *
this)
435 for (
auto f : p->getFieldVTK(i))
436 file <<
'\t' << f <<
'\n';
438 file <<
" </DataArray>\n";
441 file <<
"</PointData>\n";
443 file <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
444 file <<
" </DataArray>\n";
445 file <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
446 file <<
" </DataArray>\n";
447 file <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
448 file <<
" </DataArray>\n";
449 file <<
"</Cells>\n";
450 file <<
"</Piece>\n";
451 file <<
"</UnstructuredGrid>\n";
452 file <<
"</VTKFile>\n";
void writeVTK() const
Writes all particles into a vtk file format (unstructured grid), consisting of particle positions...
unsigned int getIndex() const
Returns the index of the object in the handler.
virtual void actionsOnErase()
If an interaction needs to do something before it gets erased, add it here. E.g. Liquid bridges ruptu...
BaseSpecies is the class from which all other species are derived.
void write(std::ostream &os) const
Writes the InteractionHandler to an output stream, for example a restart file.
FileType getWriteVTK() const
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
T * getObjectById(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
void setI(BaseInteractable *I)
Sets the second object involved in the interaction (often particle or wall).
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
InteractionHandler()
Default constructor, it creates an empty InteractionHandler.
~InteractionHandler()
Destructor, it destructs the InteractionHandler and all BaseInteraction it contains.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Mdouble getTimeStamp() const
Returns an Mdouble which is the time stamp of the interaction.
Mdouble getMeanOverlap() const
The mean overlap of all interactions.
void setSpecies(BaseSpecies *species)
Set the Species of the interaction; note this can either be a Species or MixedSpecies.
Stores information about interactions between two interactable objects; often particles but could be ...
void eraseOldInteractions(Mdouble lastTimeStep)
erases interactions which have an old timestamp.
FileType
With FileType options, one is able to choose if data is to be read/written from/into no or single or ...
void actionsAfterTimeStep()
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
void setTimeStamp(Mdouble timeStamp)
Updates the time step of the interacting. Note, timesteps used to find completed interactions.
void removeObjectKeepingPeriodics(unsigned const int id)
Removes interactions of periodic particles when the periodic particles get deleted (see DPMBase::remo...
file will not be created/read
InteractionHandler operator=(const InteractionHandler &rhs)
Assignment operator.
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
virtual void removeObject(unsigned const int id)
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 * 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 std::string getTypeVTK(unsigned i) const
std::string getName() const
Returns the name of the object.
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 std::string getNameVTK(unsigned i) const
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
void setWriteVTK(FileType f)
std::string to_string(const T &n)
BaseInteractable * getI()
virtual void addObject(T *object)
Adds a new Object to the BaseHandler.
Defines the basic properties that a interactable object can have.
BaseInteraction * getExistingInteraction(BaseInteractable *P, BaseInteractable *I) const
Returns the Interaction between the BaseInteractable's P and I if it exists, otherwise returns a null...
void readObject(std::istream &is)
Reads an Interaction into the InteractionHandler from restart data.
const std::list< BaseInteraction * > & getInteractions() const
Returns a reference to the list of interactions in this BaseInteractable.
unsigned int getIndSpecies() const
Returns the index of the Species of this BaseInteractable.
BaseInteraction * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
Implementation of a 3D vector (by Vitaliy).
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
void addObject(BaseInteraction *I)
Adds an Interaction to the InteractionHandler.
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
virtual BaseInteraction * getNewInteraction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp) const =0
returns new Interaction object.
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
virtual unsigned getNumberOfFieldsVTK() const