43 logger(
DEBUG,
"ParticleHandler::ParticleHandler() finished");
65 logger(
DEBUG,
"ParticleHandler::ParticleHandler(const ParticleHandler &PH) finished");
88 logger(
DEBUG,
"ParticleHandler::operator = (const ParticleHandler& rhs) finished");
101 logger(
DEBUG,
"ParticleHandler::~ParticleHandler() finished");
153 #ifdef CONTACT_LIST_HGRID
166 #ifdef CONTACT_LIST_HGRID
177 logger(
WARN,
"No particles, so cannot compute the smallest particle.");
180 Mdouble min = std::numeric_limits<Mdouble>::max();
184 if (particle->getInteractionRadius() < min)
196 logger(
WARN,
"No particles, so cannot compute the largest particle.");
199 Mdouble max = -std::numeric_limits<Mdouble>::max();
203 if (particle->getInteractionRadius() > max)
219 logger(
WARN,
"No particles to return in getSmallestParticle()");
232 logger(
WARN,
"No particles to set get_LargestParticle()");
244 logger(
WARN,
"No particles to set getFastestParticle()" );
248 Mdouble maxSpeed = -std::numeric_limits<Mdouble>::max();
251 if ((pLoop->getVelocity().getLength()) > maxSpeed)
253 maxSpeed = pLoop->getVelocity().getLength();
269 logger(
WARN,
"No getLowestPositionComponentParticle(const int i) since there are no particles.");
273 Mdouble min = std::numeric_limits<Mdouble>::max();
276 if (pLoop->getPosition().getComponent(i) < min)
278 min = pLoop->getPosition().getComponent(i);
294 logger(
WARN,
"No getHighestPositionComponentParticle(const int i) since there are no particles.");
298 Mdouble max = -std::numeric_limits<Mdouble>::max();
301 if (pLoop->getPosition().getComponent(i) > max)
303 max = pLoop->getPosition().getComponent(i);
320 logger(
WARN,
"No getLowestVelocityComponentParticle(const int i) since there are no particles");
324 Mdouble min = std::numeric_limits<Mdouble>::max();
327 if (pLoop->getVelocity().getComponent(i) < min)
329 min = pLoop->getVelocity().getComponent(i);
345 logger(
WARN,
"No getHighestVelocityComponentParticle(const int i) since there are no particles");
349 Mdouble max = -std::numeric_limits<Mdouble>::max();
352 if (pLoop->getVelocity().getComponent(i) > max)
354 max = pLoop->getVelocity().getComponent(i);
368 logger(
WARN,
"No particles to set getLightestParticle()");
372 Mdouble minMass = std::numeric_limits<Mdouble>::max();
375 if (pLoop->getMass() < minMass)
377 minMass = pLoop->getMass();
403 if (type ==
"BaseParticle")
412 else if (type ==
"BP")
419 else if (isdigit(type[0]))
425 logger(
ERROR,
"Particle type % not understood in restart file. Particle has not been read.", type);
442 std::stringstream line(std::stringstream::in | std::stringstream::out);
450 unsigned int indSpecies;
451 Mdouble radius, inverseMass, inverseInertia;
452 Vec3D position, velocity, orientation, angularVelocity;
455 position.
X = atof(type.c_str());
457 line >> position.
Y >> position.
Z >> velocity >> radius >> orientation >> angularVelocity >> inverseMass >> inverseInertia >> indSpecies;
460 particle.setIndSpecies(indSpecies);
461 particle.setPosition(position);
462 particle.setVelocity(velocity);
463 particle.setRadius(radius);
464 particle.setOrientation(orientation);
465 particle.setAngularVelocity(angularVelocity);
466 if (inverseMass == 0.0)
467 particle.fixParticle();
470 particle.setInertia(1./inverseInertia);
481 os << (*it) << std::endl;
534 if (particle->getIndSpecies() == indSpecies)
536 particle->getSpecies()->computeMass(particle);
545 particle->getSpecies()->computeMass(particle);
554 return "ParticleHandler";
BaseParticle * getLargestParticle() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
unsigned int getId() const
Returns the unique identifier of any particular object.
virtual void hGridUpdateParticle(BaseParticle *obj UNUSED)
no implementation but can be overidden in its derived classes.
void checkExtremaOnDelete(BaseParticle *P)
Checks if the extrema of this ParticleHandler needs updating when a particle is deleted.
void write(std::ostream &os) const
virtual void hGridInsertParticle(BaseParticle *obj UNUSED)
no implementation but can be overidden in its derived classes.
Mdouble X
the vector components
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void checkExtrema(BaseParticle *P)
Checks if the extrema of this ParticleHandler needs updating.
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
BaseParticle * getLowestVelocityComponentParticle(const int i) const
Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler.
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
std::string getName() const
Returns the name of the handler, namely the string "ParticleHandler".
void setHandler(ParticleHandler *handler)
Sets the pointer to the particle's ParticleHandler.
BaseParticle * getLightestParticle() const
Gets a pointer to the lightest BaseParticle (by mass) in this ParticleHandler.
virtual void computeMass(BaseParticle *p) const
Compute Particle mass function, which required a reference to the Species vector. It computes the Par...
void computeAllMasses()
Computes the mass for all BaseParticle in this ParticleHandler.
void readObject(std::istream &is)
Reads BaseParticle into the ParticleHandler from restart data.
BaseParticle * smallestParticle_
A pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
void removeLastObject()
Removes the last Object from the BaseHandler.
void clear()
Empties the whole ParticleHandler by removing all BaseParticle.
void setId(const unsigned int id)
Assigns a unique identifier to each object in the handler (container) which remains constant even aft...
BaseParticle * getSmallestParticle() const
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
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.
void removeLastObject()
Removes the last BaseParticle from the ParticleHandler.
BaseParticle * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
virtual void addObject(BaseParticle *P)
Adds a BaseParticle to the ParticleHandler.
void readOldObject(std::string type, std::istream &is)
Reads BaseParticle into the ParticleHandler from old-style restart data.
ParticleHandler()
Default constructor, it creates an empty ParticleHandler.
BaseParticle * largestParticle_
A pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
~ParticleHandler()
Destructor, it destructs the ParticleHandler and all BaseParticle it contains.
BaseParticle * getHighestVelocityComponentParticle(const int i) const
Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler.
virtual void addObject(T *O)
Adds a new Object to the BaseHandler.
std::vector< BaseParticle * > objects_
The actual list of Object pointers.
Container to store the pointers to all objects that one creates in a simulation.
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
Container to store all BaseParticle.
virtual void hGridRemoveParticle(BaseParticle *obj UNUSED)
no implementation but can be overidden in its derived classes.
void computeSmallestParticle()
Computes the smallest particle (by interaction radius) and sets it in smallestParticle_.
BaseParticle * getHighestPositionComponentParticle(const int i) const
Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler...
virtual MERCURY_DEPRECATED void oldRead(std::istream &is)
deprecated version of the read function.
void computeLargestParticle()
Computes the largest particle (by interaction radius) and sets it in largestParticle_.
BaseParticle * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
void copyContentsFromOtherHandler(const BaseHandler< BaseParticle > &BH)
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handle...
Implementation of a 3D vector (by Vitaliy).
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
BaseParticle * getLowestPositionComponentParticle(const int i) const
Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler...
Mdouble getInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
virtual void removeObject(unsigned const int id)
Removes a BaseParticle from the ParticleHandler.
ParticleHandler operator=(const ParticleHandler &rhs)
Assignment operator.
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
BaseParticle * getFastestParticle() const
Gets a pointer to the fastest BaseParticle in this ParticleHandler.