27 #ifndef PARTICLE_HANDLER_H
28 #define PARTICLE_HANDLER_H
243 typename std::enable_if<std::is_scalar<T>::value, T>::type
249 if ((*this).getSize() == 0)
251 logger(
WARN,
"ParticleHandler is empty: returning 0.0");
258 attributeParticle = attribute(
objects_[0]);
259 attributeFinal = attributeParticle;
265 if (!(particle->isMPIParticle() || particle->isPeriodicGhostParticle() || particle->isFixed()))
267 attributeParticle = attribute(particle);
274 if (attributeParticle < attributeFinal)
276 attributeFinal = attributeParticle;
280 if (attributeParticle > attributeFinal)
282 attributeFinal = attributeParticle;
290 return attributeFinal;
304 typename std::enable_if<std::is_scalar<T>::value, T>::type
307 #ifdef MERCURYDPM_USE_MPI
309 T particleAttributeGlobal;
316 communicator.allReduce(particleAttributeLocal,particleAttributeGlobal,MPI_MIN);
319 communicator.allReduce(particleAttributeLocal,particleAttributeGlobal,MPI_MAX);
325 return particleAttributeGlobal;
339 void clear()
override;
409 std::string
getName()
const override;
441 void saveNumberPSDtoCSV(std::string csvFileName, std::vector<double> diameterBins = {});
double Mdouble
Definition: GeneralDefine.h:34
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
AttributeType
Definition: ParticleHandler.h:38
@ MIN
Definition: ParticleHandler.h:39
@ MAX
Definition: ParticleHandler.h:39
Container to store the pointers to all objects that one creates in a simulation.
Definition: BaseHandler.h:51
std::vector< BaseParticle * > objects_
The actual list of Object pointers.
Definition: BaseHandler.h:302
Definition: BaseParticle.h:54
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:50
This class contains all information and functions required for communication between processors.
Definition: MpiContainer.h:130
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
Container to store all BaseParticle.
Definition: ParticleHandler.h:48
BaseParticle * getSmallestParticleLocal() const
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler of the loc...
Definition: ParticleHandler.cc:502
BaseParticle * getHighestPositionComponentParticle(int i) const
Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:892
~ParticleHandler() override
Destructor, it destructs the ParticleHandler and all BaseParticle it contains.
Definition: ParticleHandler.cc:107
std::enable_if< std::is_scalar< T >::value, T >::type getParticleAttribute(std::function< T(BaseParticle *)> attribute, AttributeType type) const
Computes an attribute type (min/max/..) of a particle attribute(position/velocity) in the global doma...
Definition: ParticleHandler.h:305
Mdouble getLargestInteractionRadiusLocal() const
Returns the largest interaction radius of the current domain.
Definition: ParticleHandler.cc:757
std::enable_if< std::is_scalar< T >::value, T >::type getParticleAttributeLocal(std::function< T(BaseParticle *)> attribute, AttributeType type) const
Computes an attribute type (min/max/..) of a particle attribute (position/velocity) in a local domain...
Definition: ParticleHandler.h:244
BaseParticle * getFastestParticle() const
Definition: ParticleHandler.cc:710
Mdouble getRotationalEnergy() const
Definition: ParticleHandler.cc:586
void clear() override
Empties the whole ParticleHandler by removing all BaseParticle.
Definition: ParticleHandler.cc:977
void removeGhostObject(unsigned int index)
Removes a BaseParticle from the ParticleHandler without a global check, this is only to be done for m...
Definition: ParticleHandler.cc:422
BaseParticle * getFastestParticleLocal() const
Gets a pointer to the fastest BaseParticle in this ParticleHandler.
Definition: ParticleHandler.cc:687
Vec3D getMomentum() const
Definition: ParticleHandler.cc:666
double getLiquidFilmVolume() const
Definition: ParticleHandler.cc:1380
BaseParticle * getHighestVelocityComponentParticle(int i) const
Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:964
void readAndAddObject(std::istream &is) override
Definition: ParticleHandler.cc:1094
Mdouble getHighestPositionX() const
Function returns the highest position in the x-direction.
Definition: ParticleHandler.cc:995
static BaseParticle * createObject(const std::string &type)
Reads BaseParticle into the ParticleHandler from restart data.
Definition: ParticleHandler.cc:1025
Mdouble getKineticEnergyLocal() const
Definition: ParticleHandler.cc:544
void computeSmallestParticle()
Computes the smallest particle (by interaction radius) and sets it in smallestParticle_.
Definition: ParticleHandler.cc:451
Mdouble getSmallestInteractionRadiusLocal() const
Returns the smallest interaction radius of the current domain.
Definition: ParticleHandler.cc:721
std::string getName() const override
Returns the name of the handler, namely the string "ParticleHandler".
Definition: ParticleHandler.cc:1247
Vec3D getMassTimesPositionLocal() const
Definition: ParticleHandler.cc:627
Vec3D getMassTimesPosition() const
Definition: ParticleHandler.cc:636
Mdouble getMassLocal() const
Definition: ParticleHandler.cc:602
Vec3D getCentreOfMass() const
Definition: ParticleHandler.cc:654
BaseParticle * getLowestVelocityComponentParticleLocal(int i) const
Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:905
Vec3D getAngularMomentum() const
Definition: ParticleHandler.cc:675
unsigned int getNumberOfRealObjectsLocal() const
Returns the number of real objects on a local domain. MPI particles and periodic particles are neglec...
Definition: ParticleHandler.cc:1283
BaseParticle * getLowestPositionComponentParticleLocal(int i) const
Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:829
void actionsAfterTimeStep()
Definition: ParticleHandler.cc:1372
BaseParticle * getLowestVelocityComponentParticle(int i) const
Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:928
void addExistingObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:131
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:171
ParticleHandler & operator=(const ParticleHandler &rhs)
Assignment operator.
Definition: ParticleHandler.cc:85
Mdouble getLargestInteractionRadius() const
Returns the largest interaction radius.
Definition: ParticleHandler.cc:772
Mdouble getSmallestInteractionRadius() const
Returns the smallest interaction radius.
Definition: ParticleHandler.cc:736
unsigned int getNumberOfFixedObjects() const
Computes the number of fixed particles in the whole simulation.
Definition: ParticleHandler.cc:1358
void write(std::ostream &os) const
BaseParticle * readAndCreateObject(std::istream &is)
Create a new particle, based on the information provided in a restart file.
Definition: ParticleHandler.cc:1065
unsigned int getNumberOfRealObjects() const
Returns the number of real objects (on all processors)
Definition: ParticleHandler.cc:1304
Mdouble getVolume() const
Definition: ParticleHandler.cc:1263
BaseParticle * smallestParticle_
A pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition: ParticleHandler.h:471
void checkExtrema(BaseParticle *P)
Checks if the extrema of this ParticleHandler needs updating.
Definition: ParticleHandler.cc:1173
void removeObject(unsigned int index) override
Removes a BaseParticle from the ParticleHandler.
Definition: ParticleHandler.cc:394
unsigned int NFixedParticles_
Number of fixed particles.
Definition: ParticleHandler.h:476
BaseParticle * getLargestParticleLocal() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in the ParticleHandler of the local...
Definition: ParticleHandler.cc:526
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
Definition: ParticleHandler.cc:1325
BaseParticle * largestParticle_
A pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition: ParticleHandler.h:466
unsigned int getNumberOfFixedObjectsLocal() const
Computes the number of Fixed particles on a local domain.
Definition: ParticleHandler.cc:1342
BaseParticle * getHighestPositionComponentParticleLocal(int i) const
Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:868
Mdouble getVolumeLocal() const
Definition: ParticleHandler.cc:1252
void saveNumberPSDtoCSV(std::string csvFileName, std::vector< double > diameterBins={})
Definition: ParticleHandler.cc:1390
void checkExtremaOnDelete(BaseParticle *P)
Checks if the extrema of this ParticleHandler needs updating when a particle is deleted.
Definition: ParticleHandler.cc:1199
Mdouble getKineticEnergy() const
Definition: ParticleHandler.cc:557
void addGhostObject(int fromProcessor, int toProcessor, BaseParticle *p)
Adds a ghost particle located at fromProcessor to toProcessor.
Definition: ParticleHandler.cc:287
Mdouble getSumRadiusLocal() const
Definition: ParticleHandler.cc:791
BaseParticle * getLowestPositionComponentParticle(int i) const
Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:855
void removeLastObject()
Removes the last BaseParticle from the ParticleHandler.
Definition: ParticleHandler.cc:441
BaseParticle * getHighestVelocityComponentParticleLocal(int i) const
Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:941
Mdouble getRotationalEnergyLocal() const
Definition: ParticleHandler.cc:573
unsigned int getNumberOfFixedParticles() const
Gets the number of particles that are fixed.
Definition: ParticleHandler.cc:1009
void computeAllMasses()
Computes the mass for all BaseParticle in this ParticleHandler.
Definition: ParticleHandler.cc:1226
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:534
BaseParticle * getSmallestParticle() const
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler of the loc...
Definition: ParticleHandler.cc:511
ParticleHandler()
Default constructor, it creates an empty ParticleHandler.
Definition: ParticleHandler.cc:50
unsigned int getNumberOfUnfixedParticles() const
Gets the number of particles that are not fixed.
Definition: ParticleHandler.cc:1017
void addedFixedParticle()
Increment of the number of fixed particles.
Definition: ParticleHandler.cc:1234
void computeLargestParticle()
Computes the largest particle (by interaction radius) and sets it in largestParticle_.
Definition: ParticleHandler.cc:475
void removedFixedParticle()
Decrement of the number of fixed particles.
Definition: ParticleHandler.cc:1239
Mdouble getMeanRadius() const
Definition: ParticleHandler.cc:804
Mdouble getMass() const
Definition: ParticleHandler.cc:611
Container to store all ParticleSpecies.
Definition: SpeciesHandler.h:37
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:73
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51