revision: v0.14
ParticleHandler Class Reference

Container to store all BaseParticle. More...

#include <ParticleHandler.h>

+ Inheritance diagram for ParticleHandler:

Public Member Functions

 ParticleHandler ()
 Default constructor, it creates an empty ParticleHandler. More...
 
 ParticleHandler (const ParticleHandler &PH)
 Constructor that copies all BaseParticle it contains and then sets the smallest and largest particle. More...
 
ParticleHandleroperator= (const ParticleHandler &rhs)
 Assignment operator. More...
 
 ~ParticleHandler () override
 Destructor, it destructs the ParticleHandler and all BaseParticle it contains. More...
 
void addExistingObject (BaseParticle *P) override
 Adds a BaseParticle to the ParticleHandler. More...
 
void addObject (BaseParticle *P) override
 Adds a BaseParticle to the ParticleHandler. More...
 
void addObject (int fromProcessor, BaseParticle *P)
 Adds a BaseParticle located at processor fromProcessor to toProcessor. More...
 
void addGhostObject (int fromPrcessor, int toProcessor, BaseParticle *p)
 Adds a ghost particle located at fromProcessor to toProcessor. More...
 
void addGhostObject (BaseParticle *P) override
 Adds a BaseParticle to the ParticleHandler. More...
 
void removeObject (unsigned int index) override
 Removes a BaseParticle from the ParticleHandler. More...
 
void removeGhostObject (unsigned int index)
 Removes a BaseParticle from the ParticleHandler without a global check, this is only to be done for mpi routines. More...
 
void removeLastObject ()
 Removes the last BaseParticle from the ParticleHandler. More...
 
void computeSmallestParticle ()
 Computes the smallest particle (by interaction radius) and sets it in smallestParticle_. More...
 
void computeLargestParticle ()
 Computes the largest particle (by interaction radius) and sets it in largestParticle_. More...
 
BaseParticlegetSmallestParticleLocal () const
 Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler of the local domain. More...
 
BaseParticlegetSmallestParticle () const
 Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler of the local domain. When mercury is running in parallel this function throws an error since a pointer to another domain is useless. More...
 
BaseParticlegetLargestParticleLocal () const
 Gets a pointer to the largest BaseParticle (by interactionRadius) in the ParticleHandler of the local domain. More...
 
BaseParticlegetLargestParticle () const
 Returns the pointer of the largest particle in the particle handler. When mercury is running in parallel this function throws an error since a pointer to another domain is useless. More...
 
Mdouble getSmallestInteractionRadiusLocal () const
 Returns the smallest interaction radius of the current domain. More...
 
Mdouble getSmallestInteractionRadius () const
 Returns the smallest interaction radius. More...
 
Mdouble getLargestInteractionRadiusLocal () const
 Returns the largest interaction radius of the current domain. More...
 
Mdouble getLargestInteractionRadius () const
 Returns the largest interaction radius. More...
 
BaseParticlegetFastestParticleLocal () const
 Gets a pointer to the fastest BaseParticle in this ParticleHandler. More...
 
BaseParticlegetFastestParticle () const
 
Mdouble getKineticEnergy () const
 
Mdouble getRotationalEnergy () const
 
Mdouble getMass () const
 
Vec3D getMassTimesPosition () const
 
Vec3D getCentreOfMass () const
 
Vec3D getMomentum () const
 
Vec3D getAngularMomentum () const
 
Mdouble getVolume () const
 
Mdouble getMeanRadius () const
 
BaseParticlegetLowestPositionComponentParticleLocal (int i) const
 Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler. More...
 
BaseParticlegetLowestPositionComponentParticle (int i) const
 Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler. More...
 
BaseParticlegetHighestPositionComponentParticleLocal (int i) const
 Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler. More...
 
BaseParticlegetHighestPositionComponentParticle (int i) const
 Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler. More...
 
BaseParticlegetLowestVelocityComponentParticleLocal (int i) const
 Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler. More...
 
BaseParticlegetLowestVelocityComponentParticle (int i) const
 Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler. More...
 
BaseParticlegetHighestVelocityComponentParticleLocal (int i) const
 Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler. More...
 
BaseParticlegetHighestVelocityComponentParticle (int i) const
 Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler. More...
 
template<typename T >
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. More...
 
template<typename T >
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 domain. More...
 
Mdouble getHighestPositionX () const
 Function returns the highest position in the x-direction. More...
 
void clear () override
 Empties the whole ParticleHandler by removing all BaseParticle. More...
 
unsigned int getNumberOfFixedParticles () const
 Gets the number of particles that are fixed. More...
 
unsigned int getNumberOfUnfixedParticles () const
 Gets the number of particles that are not fixed. More...
 
BaseParticlereadAndCreateObject (std::istream &is)
 Create a new particle, based on the information provided in a restart file. More...
 
void readAndAddObject (std::istream &is) override
 
void write (std::ostream &os) const
 
void checkExtrema (BaseParticle *P)
 Checks if the extrema of this ParticleHandler needs updating. More...
 
void checkExtremaOnDelete (BaseParticle *P)
 Checks if the extrema of this ParticleHandler needs updating when a particle is deleted. More...
 
void computeAllMasses (unsigned int indSpecies)
 Computes the mass for all BaseParticle of the given species in this ParticleHandler. More...
 
void computeAllMasses ()
 Computes the mass for all BaseParticle in this ParticleHandler. More...
 
void addedFixedParticle ()
 Increment of the number of fixed particles. More...
 
void removedFixedParticle ()
 Decrement of the number of fixed particles. More...
 
std::string getName () const override
 Returns the name of the handler, namely the string "ParticleHandler". More...
 
unsigned int getNumberOfRealObjects () const
 Returns the number of real objects (on all processors) More...
 
unsigned int getNumberOfObjects () const override
 Returns the number of objects in the container. In parallel code this practice is forbidden to avoid confusion with real and fake particles. If the size of the container is wished, call size() More...
 
unsigned int getNumberOfFixedObjectsLocal () const
 Computes the number of Fixed particles on a local domain. More...
 
unsigned int getNumberOfFixedObjects () const
 Computes the number of fixed particles in the whole simulation. More...
 
unsigned int getNumberOfRealObjectsLocal () const
 Returns the number of real objects on a local domain. MPI particles and periodic particles are neglected. More...
 
void actionsAfterTimeStep ()
 
double getLiquidFilmVolume () const
 
- Public Member Functions inherited from BaseHandler< BaseParticle >
 BaseHandler ()
 Default BaseHandler constructor, it creates an empty BaseHandler and assigns DPMBase_ to a null pointer. More...
 
 BaseHandler (const BaseHandler< BaseParticle > &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< BaseParticle > &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 (BaseParticle *O)
 Adds an existing object to the BaseHandler without changing the id of the object. More...
 
virtual void addObject (BaseParticle *object)
 Adds a new Object to the BaseHandler. More...
 
virtual void addGhostObject (BaseParticle *O)
 Adds a new Object to the BaseHandler. called by the to avoid increasing the id. More...
 
void removeIf (const std::function< bool(BaseParticle *)> cond)
 
void removeLastObject ()
 Removes the last Object from the BaseHandler. More...
 
void read (std::istream &is)
 Reads all objects from restart data. More...
 
BaseParticlegetObjectById (const unsigned int id)
 Gets a pointer to the Object at the specified index in the BaseHandler. More...
 
std::vector< BaseParticle * > getObjectsById (const unsigned int id)
 Gets a vector of pointers to the objects with the specific id. More...
 
BaseParticlegetObject (const unsigned int id)
 Gets a pointer to the Object at the specified index in the BaseHandler.
More...
 
const BaseParticlegetObject (const unsigned int id) const
 Gets a constant pointer to the Object at the specified index in the BaseHandler. More...
 
BaseParticlegetLastObject ()
 Gets a pointer to the last Object in this BaseHandler. More...
 
const BaseParticlegetLastObject () 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 BaseParticle &obj)
 Resizes the container to contain N elements. More...
 
const std::vector< BaseParticle * >::const_iterator begin () const
 Gets the begin of the const_iterator over all Object in this BaseHandler. More...
 
const std::vector< BaseParticle * >::iterator begin ()
 Gets the begin of the iterator over all BaseBoundary in this BaseHandler. More...
 
const std::vector< BaseParticle * >::const_iterator end () const
 Gets the end of the const_iterator over all BaseBoundary in this BaseHandler. More...
 
const std::vector< BaseParticle * >::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 (BaseParticle *object, unsigned int id)
 
void increaseId ()
 
unsigned int getNextId ()
 
void setNextId (unsigned int id)
 
DPMBasegetDPMBase ()
 Gets the problem that is solved using this handler. More...
 
DPMBasegetDPMBase () const
 Gets the problem that is solved using this handler and does not change the class. More...
 
virtual std::string getName () const=0
 Gets the name of this handler. 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...
 

Static Public Member Functions

static BaseParticlecreateObject (const std::string &type)
 Reads BaseParticle into the ParticleHandler from restart data. More...
 

Private Member Functions

Mdouble getKineticEnergyLocal () const
 
Mdouble getRotationalEnergyLocal () const
 
Mdouble getMassLocal () const
 
Mdouble getVolumeLocal () const
 
Vec3D getMassTimesPositionLocal () const
 
Mdouble getSumRadiusLocal () const
 

Private Attributes

BaseParticlelargestParticle_
 A pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler. More...
 
BaseParticlesmallestParticle_
 A pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler. More...
 
unsigned int NFixedParticles_
 Number of fixed particles. More...
 

Additional Inherited Members

- Protected Attributes inherited from BaseHandler< BaseParticle >
std::vector< BaseParticle * > objects_
 The actual list of Object pointers. More...
 

Detailed Description

Container to store all BaseParticle.

The ParticleHandler is a container to store all BaseParticle. It is implemented by a vector of pointers to BaseParticle.

Constructor & Destructor Documentation

◆ ParticleHandler() [1/2]

ParticleHandler::ParticleHandler ( )

Default constructor, it creates an empty ParticleHandler.

Constructor of the ParticleHandler class. It creates and empty ParticleHandler.

50 {
51  largestParticle_ = nullptr;
52  smallestParticle_ = nullptr;
53  logger(DEBUG, "ParticleHandler::ParticleHandler() finished");
54 }

References FATAL, largestParticle_, logger, and smallestParticle_.

◆ ParticleHandler() [2/2]

ParticleHandler::ParticleHandler ( const ParticleHandler PH)

Constructor that copies all BaseParticle it contains and then sets the smallest and largest particle.

Parameters
[in]PHThe ParticleHandler that has to be copied.

This is not a copy constructor! It copies the DPMBase and all BaseParticle, and sets the other variables to 0. After that, it computes the smallest and largest particle in this handler.

64 {
65  clear();
66  setDPMBase(PH.getDPMBase());
67  largestParticle_ = nullptr;
68  smallestParticle_ = nullptr;
70  if (!objects_.empty())
71  {
74  }
75  logger(DEBUG, "ParticleHandler::ParticleHandler(const ParticleHandler &PH) finished");
76 }

References clear(), computeLargestParticle(), computeSmallestParticle(), BaseHandler< BaseParticle >::copyContentsFromOtherHandler(), FATAL, BaseHandler< T >::getDPMBase(), largestParticle_, logger, BaseHandler< BaseParticle >::objects_, BaseHandler< BaseParticle >::setDPMBase(), and smallestParticle_.

◆ ~ParticleHandler()

ParticleHandler::~ParticleHandler ( )
override

Destructor, it destructs the ParticleHandler and all BaseParticle it contains.

Set the pointers to largestParticle_ and smallestParticle_ to nullptr, all BaseParticle are destroyed by the BaseHandler afterwards.

107 {
108  //First reset the pointers, such that they are not checked twice when removing particles
109  largestParticle_ = nullptr;
110  smallestParticle_ = nullptr;
111  logger(DEBUG, "ParticleHandler::~ParticleHandler() finished");
112 }

References FATAL, largestParticle_, logger, and smallestParticle_.

Member Function Documentation

◆ actionsAfterTimeStep()

void ParticleHandler::actionsAfterTimeStep ( )
1363 {
1364  for (auto i: *this)
1365  {
1366  i->actionsAfterTimeStep();
1367  }
1368 }

References constants::i.

Referenced by DPMBase::computeOneTimeStep().

◆ addedFixedParticle()

void ParticleHandler::addedFixedParticle ( )

Increment of the number of fixed particles.

Todo:
MX: For Jonny, is this still required, keeping the parallel code in mind?
1225 {
1226  NFixedParticles_++;
1227 }

References NFixedParticles_.

Referenced by BaseParticle::fixParticle().

◆ addExistingObject()

void ParticleHandler::addExistingObject ( BaseParticle P)
override

Adds a BaseParticle to the ParticleHandler.

Parameters
[in]PA pointer to the BaseParticle that has to be added.

To add a BaseParticle to the ParticleHandler, first check if it has a species, since it is as common bug to use a BaseParticle without species, which leads to a segmentation fault. To help the user with debugging, a warning is given if a particle without species is added. After that, the actions for adding the particle to the BaseHandler are taken, which include adding it to the vector of pointers to all BaseParticle and assigning the correct id and index. Then the particle is added to the HGrid, the particle is told that this is its handler, its mass is computed and finally it is checked if this is the smallest or largest particle in this ParticleHandler. The particle exists, in other words: it has been made before. This implies it already got an id Attached to it and hence we don't want to assign a new ID to it.

131 {
132  if (P->getSpecies() == nullptr)
133  {
134  logger(WARN, "WARNING: The particle with ID % that is added in ParticleHandler::addObject does not have a "
135  "species yet. Please make sure that you have "
136  "set the species somewhere in the driver code.", P->getId());
137  }
138 
139  //Puts the particle in the Particle list
141  if (getDPMBase() != nullptr)
142  {
143  //This places the particle in this grid
145  //This computes where the particle currently is in the grid
147  }
148  //set the particleHandler pointer
149  P->setHandler(this);
150  //compute mass of the particle
151  P->getSpecies()->computeMass(P);
152  //Check if this particle has new extrema
153  checkExtrema(P);
154 }

References BaseHandler< T >::addExistingObject(), checkExtrema(), ParticleSpecies::computeMass(), BaseHandler< BaseParticle >::getDPMBase(), BaseObject::getId(), BaseInteractable::getSpecies(), DPMBase::hGridInsertParticle(), DPMBase::hGridUpdateParticle(), logger, BaseParticle::setHandler(), and WARN.

Referenced by readAndAddObject().

◆ addGhostObject() [1/2]

void ParticleHandler::addGhostObject ( BaseParticle P)
override

Adds a BaseParticle to the ParticleHandler.

This is a special function that is used in the parallel code. The functions differs from the standard parallel implementation as this function does not check if the particle is an mpi particle and the mpi domain is not updated. When the domain adds mpi particles to the simulation these checks are not required. It also doesnt increase the id of the particle

Parameters
[in]Apointer to the BaseParticle that has to be added.
345 {
346 #ifdef MERCURY_USE_MPI
347  if (P->getSpecies() == nullptr)
348  {
349  logger(WARN, "[ParticleHandler::adGhostObject(BaseParticle*)] "
350  "WARNING: The particle with ID % that is added in "
351  "ParticleHandler::addObject does not have a species yet."
352  " Please make sure that you have "
353  "set the species somewhere in the driver code.", P->getId());
354  }
355 
356  MPIContainer& communicator = MPIContainer::Instance();
357  //Puts the particle in the Particle list
359  if (getDPMBase() != nullptr)
360  {
361  //This places the particle in this grid
363  //This computes where the particle currently is in the grid
365 
366  // broadcast particle addition
368  }
369  //set the particleHandler pointer
370  P->setHandler(this);
371  //compute mass of the particle
372  P->getSpecies()->computeMass(P) ;
373  //Check if this particle has new extrema
374  checkExtrema(P);
375 #else
376  logger(INFO,
377  "Function ParticleHandler::mpiAddObject(BaseParticle* P) should only be called when compiling with parallel build on");
378 #endif
379 }

References BaseHandler< T >::addGhostObject(), checkExtrema(), ParticleSpecies::computeMass(), BaseHandler< BaseParticle >::getDPMBase(), BaseObject::getId(), BaseInteractable::getSpecies(), DPMBase::handleParticleAddition(), DPMBase::hGridInsertParticle(), DPMBase::hGridUpdateParticle(), INFO, MPIContainer::Instance(), logger, BaseParticle::setHandler(), and WARN.

◆ addGhostObject() [2/2]

void ParticleHandler::addGhostObject ( int  fromProcessor,
int  toProcessor,
BaseParticle p 
)

Adds a ghost particle located at fromProcessor to toProcessor.

This function adds a ghost particle from one processor to another processor.

When a periodic ghost particle or a mpi ghost particle is created, the ID should not be updated and hence the addGhostObject needs to be called. Adding a ghost keeps the ID constant. Additionally this function copies the particle information given on processor fromProcessor to all other processors. The target processor then adds the particle.

Parameters
[in]fromProcessorprocessor containing the particle data
[in]toProcessorprocessor that needs to add the particle
[in,out]particlethat contains the data and receives the data
284 {
285 #ifdef MERCURY_USE_MPI
286  MPIContainer& communicator = MPIContainer::Instance();
287  if (fromProcessor == toProcessor)
288  {
289  if (communicator.getProcessorID() == fromProcessor)
290  {
291  addGhostObject(p);
292  }
293 
294  return;
295  }
296 
297  //Create communication information object
299  MPIParticle pInfo;
300  int tag;
301  if (communicator.getProcessorID() == fromProcessor)
302  {
304  tag = fromProcessor*MAX_PROC*10 + toProcessor*10 + MercuryMPITag::PARTICLE_DATA;
305  communicator.send(&pInfo, MercuryMPIType::PARTICLE, 1, toProcessor, tag);
306  }
307 
308  if (communicator.getProcessorID() == toProcessor)
309  {
310  tag = fromProcessor*MAX_PROC*10 + toProcessor*10 + MercuryMPITag::PARTICLE_DATA;
311  communicator.receive(&pInfo, MercuryMPIType::PARTICLE, 1, fromProcessor, tag);
312  }
313 
314  //Sync the communication
315  communicator.sync();
316 
317  //Add the data to the new particle
318  if (communicator.getProcessorID() == toProcessor)
319  {
320  copyDataFromMPIParticleToParticle(&pInfo, p, this);
321  }
322 
323 
324  //Only toProcessor adds the particle, quietly without any check with other processors
325  //IMPORTANT NOTE: When adding a periodic particle in parallel, this is performed just before
326  //finding new particles. For that reason we dont have to add a ghostparticle to the mpi communication lists
327  if (communicator.getProcessorID() == toProcessor)
328  {
329  addGhostObject(p);
330  }
331 #else
332  logger(WARN,
333  "Function addGhostObject(int fromProcessor, int toProcessor, BaseParticle* p) should not be used in serial code");
334 #endif
335 }

References copyDataFromMPIParticleToParticle(), MPISphericalParticle::copyDataFromParticleToMPIParticle(), MPIContainer::getProcessorID(), MPIContainer::Instance(), logger, MAX_PROC, PARTICLE, PARTICLE_DATA, MPIContainer::receive(), MPIContainer::send(), MPIContainer::sync(), and WARN.

Referenced by PeriodicBoundaryHandler::processLocalGhostParticles(), Domain::processReceivedBoundaryParticleData(), and PeriodicBoundaryHandler::processReceivedGhostParticleData().

◆ addObject() [1/2]

void ParticleHandler::addObject ( BaseParticle P)
override

Adds a BaseParticle to the ParticleHandler.

Parameters
[in]PA pointer to the BaseParticle that has to be added.

To add a BaseParticle to the ParticleHandler, first check if it has a species, since it is as common bug to use a BaseParticle without species, which leads to a segmentation fault. To help the user with debugging, a warning is given if a particle without species is added. After that, the actions for adding the particle to the BaseHandler are taken, which include adding it to the vector of pointers to all BaseParticle and assigning the correct id and index. Then the particle is added to the HGrid, the particle is told that this is its handler, its mass is computed and finally it is checked if this is the smallest or largest particle in this ParticleHandler.

171 {
172  if (P->getSpecies() == nullptr)
173  {
174  logger(WARN, "WARNING: The particle with ID % that is added in "
175  "ParticleHandler::addObject does not have a species yet. "
176  "Please make sure that you have "
177  "set the species somewhere in the driver code.", P->getId());
178  }
179 #ifdef MERCURY_USE_MPI
180  bool insertParticle;
181  //Check if the particle P should be added to the current domain
182  if (NUMBER_OF_PROCESSORS == 1)
183  {
184  insertParticle = true;
185  }
186  else
187  {
188  insertParticle = getDPMBase()->mpiInsertParticleCheck(P);
189  }
190 
191  //Add the particle if it is in the mpi domain or if the domain is not yet defined
192  if(insertParticle)
193  {
194 #endif
195  //Puts the particle in the Particle list
197  if (getDPMBase() != nullptr)
198  {
199  //This places the particle in this grid
201  //This computes where the particle currently is in the grid
203 
204  // Broadcasts the existance of a new particle
206  }
207  //set the particleHandler pointer
208  P->setHandler(this);
209  //compute mass of the particle
210  P->getSpecies()->computeMass(P);
211  //Check if this particle has new extrema
212  checkExtrema(P);
213  if (!P->isSphericalParticle())
214  {
215  getDPMBase()->setRotation(true);
216  }
217 #ifdef MERCURY_USE_MPI
218  P->setPeriodicComplexity(std::vector<int>(0));
219  }
220  else
221  {
222  logger.assert_debug(!P->isMPIParticle(),"Can't add mpi particle as it does not exist");
223  logger.assert_debug(!P->isPeriodicGhostParticle(),"Can't add mpi particle as it does not exist");
224  //Somehwere a really new particle has been added, so to keep the ID's globally unique, we also update
225  //the unique value on all other processors
227  }
228 
229  //Add the particle to the ghost particle lists
231  //Check if this new particle requires an update in the mpi grid (interactionDistance).
233 
234  //Delete the particle that was supposed to be added (but was not)
235  if(!insertParticle)
236  {
237  delete P;
238  }
239 #endif
240 }

References BaseHandler< T >::addObject(), checkExtrema(), ParticleSpecies::computeMass(), BaseHandler< BaseParticle >::getDPMBase(), BaseObject::getId(), BaseInteractable::getSpecies(), DPMBase::handleParticleAddition(), DPMBase::hGridInsertParticle(), DPMBase::hGridUpdateParticle(), BaseHandler< T >::increaseId(), DPMBase::insertGhostParticle(), BaseParticle::isMPIParticle(), BaseParticle::isPeriodicGhostParticle(), BaseParticle::isSphericalParticle(), logger, DPMBase::mpiInsertParticleCheck(), NUMBER_OF_PROCESSORS, BaseParticle::setHandler(), BaseParticle::setPeriodicComplexity(), DPMBase::setRotation(), DPMBase::updateGhostGrid(), and WARN.

Referenced by ChuteWithPeriodicInflow::AddContinuingBottom(), addObject(), CircularPeriodicBoundary::checkBoundaryAfterParticleMoved(), ConstantMassFlowMaserBoundary::checkBoundaryAfterParticleMoved(), SubcriticalMaserBoundary::checkBoundaryAfterParticleMoved(), SubcriticalMaserBoundaryTEST::checkBoundaryAfterParticleMoved(), ChuteWithContraction::ChuteWithContraction(), ChuteWithPeriodicInflowAndContinuingBottom::ChuteWithPeriodicInflowAndContinuingBottom(), ChuteWithPeriodicInflowAndContraction::ChuteWithPeriodicInflowAndContraction(), ChuteWithPeriodicInflowAndVariableBottom::ChuteWithPeriodicInflowAndVariableBottom(), ContractionWithPeriodicInflow::ContractionWithPeriodicInflow(), SubcriticalMaserBoundaryTEST::copyExtraParticles(), CurvyChute::createBottom(), PeriodicBoundary::createGhostParticle(), TimeDependentPeriodicBoundary::createGhostParticle(), LeesEdwardsBoundary::createHorizontalPeriodicParticles(), ShearBoxBoundary::createHorizontalPeriodicParticles(), AngledPeriodicBoundary::createPeriodicParticle(), CircularPeriodicBoundary::createPeriodicParticle(), ConstantMassFlowMaserBoundary::createPeriodicParticle(), SubcriticalMaserBoundary::createPeriodicParticle(), LeesEdwardsBoundary::createVerticalPeriodicParticles(), ShearBoxBoundary::createVerticalPeriodicParticles(), SubcriticalMaserBoundaryTEST::extendBottom(), ChuteWithPeriodicInflow::ExtendInWidth(), ChuteWithPeriodicInflow::integrateBeforeForceComputation(), and ContactDetectionTester::setupParticles().

◆ addObject() [2/2]

void ParticleHandler::addObject ( int  fromProcessor,
BaseParticle p 
)

Adds a BaseParticle located at processor fromProcessor to toProcessor.

This function adds a particle to the simulation where the information of the particle is not available by the target processor.

When a certain processor generates a particle which needs to be inserted in a domain of another processor, this information needs to be transfered before the particle can be actually added

Parameters
[in]fromProcessorprocessor containing the particle data
[in,out]particlethat contains the data and receives the data
251 {
252 #ifdef MERCURY_USE_MPI
253  MPIContainer& communicator = MPIContainer::Instance();
254 
255  //The processor that contains the particle that needs to be copied needs to identify the target, and communicate this
256  MPIParticle pInfo;
257  if (communicator.getProcessorID() == fromProcessor)
258  {
260  }
261 
262  //Broadcast from processor i
263  communicator.broadcast(&pInfo,MercuryMPIType::PARTICLE,fromProcessor);
264  copyDataFromMPIParticleToParticle(&pInfo, p, this);
265 
266  //All processors now know have the same information and we can proceed with the collective add
267  addObject(p);
268 #else
269  logger(WARN, "Function addObject(int fromProcessor, BaseParticle* p) should not be used in serial code");
270 #endif
271 }

References addObject(), MPIContainer::broadcast(), copyDataFromMPIParticleToParticle(), MPISphericalParticle::copyDataFromParticleToMPIParticle(), MPIContainer::getProcessorID(), MPIContainer::Instance(), logger, PARTICLE, and WARN.

◆ checkExtrema()

void ParticleHandler::checkExtrema ( BaseParticle P)

Checks if the extrema of this ParticleHandler needs updating.

 \param[in] type The first value of the position.
 \param[in] is The input stream from which the information is read.
 \details The old objects did not have their type in the beginning of the line.
          Instead, the first string of the file was the position in x-direction.
          Since we already read the first string of the file, we need to give
          it to this function and convert it to the position in x-direction.
          The rest of the stream is then read in the usual way.
&zwj;/

void ParticleHandler::readAndCreateOldObject(std::istream& is, const std::string& type) { //read in next line std::stringstream line; helpers::getLineFromStringStream(is, line); logger(VERBOSE, line.str()); //stdcout << line.str() << std::endl;

BaseParticle particle;

//Declare all properties of the particle unsigned int indSpecies; Mdouble radius, inverseMass, inverseInertia; Vec3D position, velocity, euler, angularVelocity;

//Read all values position.X = atof(type.c_str());

line >> position.Y >> position.Z >> velocity >> radius >> euler >> angularVelocity >> inverseMass >> inverseInertia >> indSpecies;

//Put the values in the particle particle.setSpecies(getDPMBase()->speciesHandler.getObject(indSpecies)); particle.setPosition(position); particle.setVelocity(velocity); particle.setRadius(radius); Quaternion q; q.setEuler(euler); particle.setOrientation(q); particle.setAngularVelocity(angularVelocity); if (inverseMass == 0.0) particle.fixParticle(); else { particle.setInverseInertia(MatrixSymmetric3D(1,0,0,1,0,1)*inverseInertia); }

//Put the particle in the handler copyAndAddObject(particle); }

void ParticleHandler::write(std::ostream& os) const {

os << "Particles " << getSize() << '\n';
for (BaseParticle* it : *this)
{
    os << (*it) << '\n';
}

os.flush(); }

/*!

Parameters
[in]PA pointer to the particle, which properties have to be checked against the ParticleHandlers extrema.
1164 {
1165  if (P == largestParticle_)
1166  {
1167  //if the properties of the largest particle changes
1169  }
1171  {
1172  largestParticle_ = P;
1173  }
1174 
1175  if (P == smallestParticle_)
1176  {
1177  //if the properties of the smallest particle changes
1179  }
1181  {
1182  smallestParticle_ = P;
1183  }
1184 }

References computeLargestParticle(), computeSmallestParticle(), BaseParticle::getMaxInteractionRadius(), largestParticle_, and smallestParticle_.

Referenced by addExistingObject(), addGhostObject(), addObject(), and BaseParticle::setRadius().

◆ checkExtremaOnDelete()

void ParticleHandler::checkExtremaOnDelete ( BaseParticle P)

Checks if the extrema of this ParticleHandler needs updating when a particle is deleted.

Parameters
[in]PA pointer to the particle, which is going to get deleted.
1190 {
1191  if (P == largestParticle_)
1192  {
1194  }
1195  if (P == smallestParticle_)
1196  {
1198  }
1199 }

References computeLargestParticle(), computeSmallestParticle(), largestParticle_, and smallestParticle_.

Referenced by BaseParticle::~BaseParticle(), and SuperQuadricParticle::~SuperQuadricParticle().

◆ clear()

void ParticleHandler::clear ( )
overridevirtual

Empties the whole ParticleHandler by removing all BaseParticle.

Note that the pointers to smallestParticle_ and largestParticle_ are set to nullptr since these particles don't exist anymore after calling this function.

Reimplemented from BaseHandler< BaseParticle >.

974 {
975  smallestParticle_ = nullptr;
976  largestParticle_ = nullptr;
977 
978  for (auto p0: *this)
979  {
980  getDPMBase()->handleParticleRemoval(p0->getId());
981  }
982 
984 }

References BaseHandler< T >::clear(), BaseHandler< BaseParticle >::getDPMBase(), DPMBase::handleParticleRemoval(), largestParticle_, and smallestParticle_.

Referenced by NautaMixer::addParticles(), NautaMixer::addParticlesAtWall(), CGHandler::evaluateRestartFiles(), HorizontalMixer::introduceParticlesAtWall(), HorizontalMixer::introduceParticlesInDomain(), HorizontalMixer::introduceSingleParticle(), operator=(), ParticleHandler(), FileReader::read(), DPMBase::read(), DPMBase::readNextDataFile(), HorizontalMixerWalls::setupInitialConditions(), FreeCooling2DinWallsDemo::setupInitialConditions(), FreeCooling3DDemoProblem::setupInitialConditions(), FreeCooling3DinWallsDemo::setupInitialConditions(), FreeCoolingDemoProblem::setupInitialConditions(), CoilSelfTest::setupInitialConditions(), ParticleParticleInteraction::setupInitialConditions(), ParticleParticleInteractionWithPlasticForces::setupInitialConditions(), ParticleWallInteraction::setupInitialConditions(), EnergyUnitTest::setupInitialConditions(), HertzianSinterForceUnitTest::setupInitialConditions(), MD_demo::setupInitialConditions(), PlasticForceUnitTest::setupInitialConditions(), SeparateFilesSelfTest::setupInitialConditions(), SinterForceUnitTest::setupInitialConditions(), and BaseCluster::setupInitialConditions().

◆ computeAllMasses() [1/2]

void ParticleHandler::computeAllMasses ( )

Computes the mass for all BaseParticle in this ParticleHandler.

1217 {
1218  for (BaseParticle* particle : objects_)
1219  {
1220  particle->getSpecies()->computeMass(particle);
1221  }
1222 }

References BaseHandler< BaseParticle >::objects_.

◆ computeAllMasses() [2/2]

void ParticleHandler::computeAllMasses ( unsigned int  indSpecies)

Computes the mass for all BaseParticle of the given species in this ParticleHandler.

Parameters
[in]indSpeciesUnsigned integer with the index of the species for which the masses must be computed.
1206 {
1207  for (BaseParticle* particle : objects_)
1208  {
1209  if (particle->getIndSpecies() == indSpecies)
1210  {
1211  particle->getSpecies()->computeMass(particle);
1212  }
1213  }
1214 }

References BaseHandler< BaseParticle >::objects_.

Referenced by SpeciesHandler::addObject(), DPMBase::readNextDataFile(), ParticleSpecies::setDensity(), DPMBase::setParticleDimensions(), and DPMBase::solve().

◆ computeLargestParticle()

void ParticleHandler::computeLargestParticle ( )

Computes the largest particle (by interaction radius) and sets it in largestParticle_.

472 {
473  if (getSize() == 0)
474  {
475  logger(DEBUG, "No particles, so cannot compute the largest particle.");
476  largestParticle_ = nullptr;
477  return;
478  }
479  Mdouble max = -std::numeric_limits<Mdouble>::max();
480  largestParticle_ = nullptr;
481  for (BaseParticle* const particle : objects_)
482  {
483  //if (!(particle->isMPIParticle() || particle->isPeriodicGhostParticle()))
484  {
485  if (particle->getMaxInteractionRadius() > max)
486  {
487  max = particle->getMaxInteractionRadius();
488  largestParticle_ = particle;
489  }
490  }
491  }
492 }

References FATAL, BaseHandler< BaseParticle >::getSize(), largestParticle_, logger, and BaseHandler< BaseParticle >::objects_.

Referenced by DeletionBoundary::checkBoundaryAfterParticleMoved(), checkExtrema(), checkExtremaOnDelete(), operator=(), and ParticleHandler().

◆ computeSmallestParticle()

void ParticleHandler::computeSmallestParticle ( )

Computes the smallest particle (by interaction radius) and sets it in smallestParticle_.

448 {
449  if (getSize() == 0)
450  {
451  logger(DEBUG, "No particles, so cannot compute the smallest particle.");
452 
453  smallestParticle_ = nullptr;
454  return;
455  }
456  Mdouble min = std::numeric_limits<Mdouble>::max();
457  smallestParticle_ = nullptr;
458  for (BaseParticle* const particle : objects_)
459  {
460  //if (!(particle->isMPIParticle() || particle->isPeriodicGhostParticle()))
461  {
462  if (particle->getMaxInteractionRadius() < min)
463  {
464  min = particle->getMaxInteractionRadius();
465  smallestParticle_ = particle;
466  }
467  }
468  }
469 }

References FATAL, BaseHandler< BaseParticle >::getSize(), logger, BaseHandler< BaseParticle >::objects_, and smallestParticle_.

Referenced by DeletionBoundary::checkBoundaryAfterParticleMoved(), checkExtrema(), checkExtremaOnDelete(), operator=(), and ParticleHandler().

◆ createObject()

BaseParticle * ParticleHandler::createObject ( const std::string &  type)
static

Reads BaseParticle into the ParticleHandler from restart data.

Parameters
[in]isThe input stream from which the information is read.
1022 {
1023  if (type == "BaseParticle") {
1024  //for backwards compatibility
1025  return new SphericalParticle;
1026  }
1027  else if (type == "SphericalParticle")
1028  {
1029  return new SphericalParticle;
1030  }
1031  else if (type == "LiquidFilmParticle")
1032  {
1033  return new LiquidFilmParticle;
1034  }
1035  else if (type == "SuperQuadricParticle")
1036  {
1037  return new SuperQuadricParticle;
1038  }
1039  else if (type == "ThermalParticle")
1040  {
1041  return new ThermalParticle;
1042  }
1043  else if (type == "HeatFluidCoupledParticle")
1044  {
1045  return new HeatFluidCoupledParticle;
1046  }
1047  else
1048  {
1049  logger(WARN, "Particle type % not understood in restart file. Particle will not be read.", type);
1050  return nullptr;
1051  }
1052 }

References logger, and WARN.

Referenced by readAndCreateObject().

◆ getAngularMomentum()

Vec3D ParticleHandler::getAngularMomentum ( ) const
672 {
673  Vec3D momentum = {0, 0, 0};
674  for (auto p : *this)
675  if (!(p->isFixed() || p->isMPIParticle() || p->isPeriodicGhostParticle()))
676  momentum += p->getAngularMomentum();
677  return getMPISum(momentum);
678 }

References getMPISum().

Referenced by main().

◆ getCentreOfMass()

Vec3D ParticleHandler::getCentreOfMass ( ) const
651 {
652  Mdouble m = getMass();
653  if (m == 0)
654  {
656  return nanvec;
657  }
658  else
659  return getMassTimesPosition() / m;
660 }

References getMass(), getMassTimesPosition(), and constants::NaN.

Referenced by DPMBase::getCentreOfMass().

◆ getFastestParticle()

BaseParticle * ParticleHandler::getFastestParticle ( ) const
707 {
708 #ifdef MERCURY_USE_MPI
709  logger(ERROR,"This function should not be used in parallel");
710 #endif
711  return getFastestParticleLocal();
712 }

References ERROR, getFastestParticleLocal(), and logger.

◆ getFastestParticleLocal()

BaseParticle * ParticleHandler::getFastestParticleLocal ( ) const

Gets a pointer to the fastest BaseParticle in this ParticleHandler.

Returns
A pointer to the fastest BaseParticle in this ParticleHandler.
684 {
685  if (getSize() == 0)
686  {
687  logger(WARN, "No particles to set getFastestParticle()");
688  return nullptr;
689  }
690  BaseParticle* p = nullptr;
691  Mdouble maxSpeed = -std::numeric_limits<Mdouble>::max();
692  for (BaseParticle* const pLoop : objects_)
693  {
694  if (!(pLoop->isMPIParticle() || pLoop->isPeriodicGhostParticle()))
695  {
696  if ((pLoop->getVelocity().getLength()) > maxSpeed)
697  {
698  maxSpeed = pLoop->getVelocity().getLength();
699  p = pLoop;
700  }
701  }
702  }
703  return p;
704 }

References BaseHandler< BaseParticle >::getSize(), logger, BaseHandler< BaseParticle >::objects_, and WARN.

Referenced by getFastestParticle().

◆ getHighestPositionComponentParticle()

BaseParticle * ParticleHandler::getHighestPositionComponentParticle ( int  i) const

Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler.

889 {
890 #ifdef MERCURY_USE_MPI
891  logger(ERROR,"This function should not be used in parallel");
892 #endif
894 }

References ERROR, getHighestPositionComponentParticleLocal(), constants::i, and logger.

◆ getHighestPositionComponentParticleLocal()

BaseParticle * ParticleHandler::getHighestPositionComponentParticleLocal ( int  i) const

Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler.

Parameters
[in]iDirection for which one wants the particle with highest coordinates.
Returns
A pointer to the particle with the highest coordinates in direction i in this ParticleHandler.
865 {
866  if (getSize() == 0)
867  {
868  logger(WARN, "No getHighestPositionComponentParticle(const int i) since there are no particles.");
869  return nullptr;
870  }
871  BaseParticle* p = nullptr;
872  Mdouble max = -std::numeric_limits<Mdouble>::max();
873  for (BaseParticle* const pLoop : objects_)
874  {
875  if (!(pLoop->isMPIParticle() || pLoop->isPeriodicGhostParticle()))
876  {
877  if (pLoop->getPosition().getComponent(i) > max)
878  {
879  max = pLoop->getPosition().getComponent(i);
880  p = pLoop;
881  }
882  }
883  }
884 
885  return p;
886 }

References BaseHandler< BaseParticle >::getSize(), constants::i, logger, BaseHandler< BaseParticle >::objects_, and WARN.

Referenced by getHighestPositionComponentParticle().

◆ getHighestPositionX()

Mdouble ParticleHandler::getHighestPositionX ( ) const

Function returns the highest position in the x-direction.

This is a prototype example of how to obtain global particle attributes in the parallel code

Returns
Returns the highest x-position value of all particles
992 {
993  //Define the attribute function
994  std::function<Mdouble(BaseParticle*)> particleAttribute = [](BaseParticle* p) { return p->getPosition().X; };
995 
996  //Obtain the MAX attribute
997  Mdouble positionXGlobal = getParticleAttribute<Mdouble>(particleAttribute, AttributeType::MAX);
998 
999  return positionXGlobal;
1000 }

References MAX.

◆ getHighestVelocityComponentParticle()

BaseParticle * ParticleHandler::getHighestVelocityComponentParticle ( int  i) const

Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler.

961 {
962 #ifdef MERCURY_USE_MPI
963  logger(ERROR,"This function should not be used in parallel");
964 #endif
966 }

References ERROR, getHighestVelocityComponentParticleLocal(), constants::i, and logger.

◆ getHighestVelocityComponentParticleLocal()

BaseParticle * ParticleHandler::getHighestVelocityComponentParticleLocal ( int  i) const

Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler.

Parameters
[in]iDirection for which you want the particle with highest velocity.
Returns
A pointer to the particle with the highest velocity in direction i in this ParticleHandler.
938 {
939  if (!getSize())
940  {
941  logger(WARN, "No getHighestVelocityComponentParticle(const int i) since there are no particles");
942  return nullptr;
943  }
944  BaseParticle* p = nullptr;
945  Mdouble max = -std::numeric_limits<Mdouble>::max();
946  for (BaseParticle* const pLoop : objects_)
947  {
948  if (!(pLoop->isMPIParticle() || pLoop->isPeriodicGhostParticle()))
949  {
950  if (pLoop->getVelocity().getComponent(i) > max)
951  {
952  max = pLoop->getVelocity().getComponent(i);
953  p = pLoop;
954  }
955  }
956  }
957  return p;
958 }

References BaseHandler< BaseParticle >::getSize(), constants::i, logger, BaseHandler< BaseParticle >::objects_, and WARN.

Referenced by getHighestVelocityComponentParticle().

◆ getKineticEnergy()

Mdouble ParticleHandler::getKineticEnergy ( ) const
554 {
555 #ifdef MERCURY_USE_MPI
556  Mdouble kineticEnergyLocal = getKineticEnergyLocal();
557  Mdouble kineticEnergyGlobal = 0.0;
558 
559  //sum up over all domains
560  MPIContainer& communicator = MPIContainer::Instance();
561  communicator.allReduce(kineticEnergyLocal, kineticEnergyGlobal, MPI_SUM);
562 
563  return kineticEnergyGlobal;
564 #else
565  return getKineticEnergyLocal();
566 #endif
567 }

References getKineticEnergyLocal(), and MPIContainer::Instance().

Referenced by main(), DPMBase::writeEneTimeStep(), and LawinenBox::writeEneTimeStep().

◆ getKineticEnergyLocal()

Mdouble ParticleHandler::getKineticEnergyLocal ( ) const
private
541 {
542  Mdouble ene = 0;
543  for (auto p : *this)
544  {
545  if (!(p->isMPIParticle() || p->isPeriodicGhostParticle()))
546  {
547  ene += p->getKineticEnergy();
548  }
549  }
550  return ene;
551 }

Referenced by getKineticEnergy().

◆ getLargestInteractionRadius()

Mdouble ParticleHandler::getLargestInteractionRadius ( ) const

Returns the largest interaction radius.

769 {
770 #ifdef MERCURY_USE_MPI
771  Mdouble largestInteractionRadiusLocal = getLargestInteractionRadiusLocal();
772  Mdouble largestInteractionRadiusGlobal = 0.0;
773 
774  //Obtain the global value
775  MPIContainer& communicator = MPIContainer::Instance();
776  communicator.allReduce(largestInteractionRadiusLocal, largestInteractionRadiusGlobal, MPI_MAX);
777 
778  return largestInteractionRadiusGlobal;
779 #else
781 #endif
782 }

References getLargestInteractionRadiusLocal(), and MPIContainer::Instance().

Referenced by Contact::actionsAfterSolve(), and DPMBase::read().

◆ getLargestInteractionRadiusLocal()

Mdouble ParticleHandler::getLargestInteractionRadiusLocal ( ) const

Returns the largest interaction radius of the current domain.

754 {
755  if (!(getLargestParticleLocal() == nullptr))
756  {
758  }
759  else
760  {
761  return 0.0;
762  }
763 }

References getLargestParticle(), getLargestParticleLocal(), and BaseParticle::getMaxInteractionRadius().

Referenced by MercuryBase::getHGridTargetMaxInteractionRadius(), and getLargestInteractionRadius().

◆ getLargestParticle()

BaseParticle * ParticleHandler::getLargestParticle ( ) const

◆ getLargestParticleLocal()

BaseParticle * ParticleHandler::getLargestParticleLocal ( ) const

Gets a pointer to the largest BaseParticle (by interactionRadius) in the ParticleHandler of the local domain.

Returns
A pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
523 {
524  return largestParticle_;
525 }

References largestParticle_.

Referenced by ConstantMassFlowMaserBoundary::activateMaser(), ConstantMassFlowMaserBoundary::createPeriodicParticle(), getLargestInteractionRadiusLocal(), getLargestParticle(), RotatingDrum::setupInitialConditions(), and DPMBase::writeFstatHeader().

◆ getLiquidFilmVolume()

double ParticleHandler::getLiquidFilmVolume ( ) const
1370  {
1371  double liquidVolume = 0;
1372  for (auto i : objects_) {
1373  auto j = dynamic_cast<LiquidFilmParticle*>(i);
1374  if (j and !j->isMPIParticle()) liquidVolume += j->getLiquidVolume();
1375  }
1376  return getMPISum(liquidVolume);
1377 };

References getMPISum(), constants::i, and BaseHandler< BaseParticle >::objects_.

Referenced by LiquidMigrationMPI2Test::printTime().

◆ getLowestPositionComponentParticle()

BaseParticle * ParticleHandler::getLowestPositionComponentParticle ( int  i) const

Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler.

852 {
853 #ifdef MERCURY_USE_MPI
854  logger(ERROR,"This function should not be used in parallel");
855 #endif
857 }

References ERROR, getLowestPositionComponentParticleLocal(), constants::i, and logger.

◆ getLowestPositionComponentParticleLocal()

BaseParticle * ParticleHandler::getLowestPositionComponentParticleLocal ( int  i) const

Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler.

Parameters
[in]iDirection for which you want the particle with lowest coordinates.
Returns
A pointer to the particle with the lowest coordinates in the given direction in this ParticleHandler.
826 {
827 #ifdef MERCURY_USE_MPI
828  logger(ERROR,"getLowestPositionComponentParticle() not implemented yet in parallel");
829 #endif
830  if (getSize() == 0)
831  {
832  logger(WARN, "No getLowestPositionComponentParticle(const int i) since there are no particles.");
833  return nullptr;
834  }
835  BaseParticle* p = nullptr;
836  Mdouble min = std::numeric_limits<Mdouble>::max();
837  for (BaseParticle* const pLoop : objects_)
838  {
839  if (!(pLoop->isMPIParticle() || pLoop->isPeriodicGhostParticle()))
840  {
841  if (pLoop->getPosition().getComponent(i) < min)
842  {
843  min = pLoop->getPosition().getComponent(i);
844  p = pLoop;
845  }
846  }
847  }
848  return p;
849 }

References ERROR, BaseHandler< BaseParticle >::getSize(), constants::i, logger, BaseHandler< BaseParticle >::objects_, and WARN.

Referenced by getLowestPositionComponentParticle().

◆ getLowestVelocityComponentParticle()

BaseParticle * ParticleHandler::getLowestVelocityComponentParticle ( int  i) const

Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler.

925 {
926 #ifdef MERCURY_USE_MPI
927  logger(ERROR,"This function should not be used in parallel");
928 #endif
930 }

References ERROR, getLowestVelocityComponentParticleLocal(), constants::i, and logger.

◆ getLowestVelocityComponentParticleLocal()

BaseParticle * ParticleHandler::getLowestVelocityComponentParticleLocal ( int  i) const

Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler.

Parameters
[in]iDirection for which you want the particle with lowest velocity.
Returns
A pointer to the particle with the lowest velocity in direction i in this ParticleHandler.
902 {
903  if (getSize() == 0)
904  {
905  logger(WARN, "No getLowestVelocityComponentParticle(const int i) since there are no particles");
906  return nullptr;
907  }
908  BaseParticle* p = nullptr;
909  Mdouble min = std::numeric_limits<Mdouble>::max();
910  for (BaseParticle* const pLoop : objects_)
911  {
912  if (!(pLoop->isMPIParticle() || pLoop->isPeriodicGhostParticle()))
913  {
914  if (pLoop->getVelocity().getComponent(i) < min)
915  {
916  min = pLoop->getVelocity().getComponent(i);
917  p = pLoop;
918  }
919  }
920  }
921  return p;
922 }

References BaseHandler< BaseParticle >::getSize(), constants::i, logger, BaseHandler< BaseParticle >::objects_, and WARN.

Referenced by getLowestVelocityComponentParticle().

◆ getMass()

Mdouble ParticleHandler::getMass ( ) const
608 {
609 #ifdef MERCURY_USE_MPI
610  Mdouble massLocal = getMassLocal();
611  Mdouble massGlobal = 0.0;
612 
613  //Sum up over all domains
614  MPIContainer& communicator = MPIContainer::Instance();
615  communicator.allReduce(massLocal, massGlobal, MPI_SUM);
616 
617  return massGlobal;
618 #else
619  return getMassLocal();
620 #endif
621 }

References getMassLocal(), and MPIContainer::Instance().

Referenced by BoundariesSelfTest::actionsAfterTimeStep(), FluxAndPeriodicBoundarySelfTest::actionsAfterTimeStep(), FluxBoundarySelfTest::actionsAfterTimeStep(), FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), getCentreOfMass(), DPMBase::getTotalMass(), HeaterBoundaryTest::setupInitialConditions(), DPMBase::writeEneTimeStep(), and LawinenBox::writeEneTimeStep().

◆ getMassLocal()

Mdouble ParticleHandler::getMassLocal ( ) const
private
599 {
600  Mdouble m = 0;
601  for (auto p : *this)
602  if (!(p->isFixed() || p->isMPIParticle() || p->isPeriodicGhostParticle()))
603  m += p->getMass();
604  return m;
605 }

Referenced by getMass().

◆ getMassTimesPosition()

Vec3D ParticleHandler::getMassTimesPosition ( ) const
633 {
634 #ifdef MERCURY_USE_MPI
635  Vec3D massTimesPositionLocal = getMassTimesPositionLocal();
636  Vec3D massTimesPositionGlobal = {0.0, 0.0, 0.0};
637 
638  // Sum up over all domains
639  MPIContainer& communicator = MPIContainer::Instance();
640  communicator.allReduce(massTimesPositionLocal.X, massTimesPositionGlobal.X, MPI_SUM);
641  communicator.allReduce(massTimesPositionLocal.Y, massTimesPositionGlobal.Y, MPI_SUM);
642  communicator.allReduce(massTimesPositionLocal.Z, massTimesPositionGlobal.Z, MPI_SUM);
643 
644  return massTimesPositionGlobal;
645 #else
646  return getMassTimesPositionLocal();
647 #endif
648 }

References getMassTimesPositionLocal(), MPIContainer::Instance(), Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by getCentreOfMass(), and DPMBase::writeEneTimeStep().

◆ getMassTimesPositionLocal()

Vec3D ParticleHandler::getMassTimesPositionLocal ( ) const
private
624 {
625  Vec3D com = {0, 0, 0};
626  for (auto p : *this)
627  if (!(p->isFixed() || p->isMPIParticle() || p->isPeriodicGhostParticle()))
628  com += p->getMass() * p->getPosition();
629  return com;
630 }

Referenced by getMassTimesPosition().

◆ getMeanRadius()

Mdouble ParticleHandler::getMeanRadius ( ) const
801 {
802 #ifdef MERCURY_USE_MPI
803  Mdouble sumRadiusLocal = getSumRadiusLocal();
804  unsigned numberOfRealParticlesLocal = getNumberOfRealObjectsLocal();
805 
806  Mdouble sumRadiusGlobal = 0.0;
807  unsigned numberOfRealParticlesGlobal = 0;
808 
809  //Sum up over all domains
810  MPIContainer& communicator = MPIContainer::Instance();
811  communicator.allReduce(sumRadiusLocal, sumRadiusGlobal, MPI_SUM);
812  communicator.allReduce(numberOfRealParticlesLocal, numberOfRealParticlesGlobal, MPI_SUM);
813 
814  return sumRadiusGlobal/numberOfRealParticlesGlobal;
815 #else
816  return getSumRadiusLocal() / getSize();
817 #endif
818 }

References getNumberOfRealObjectsLocal(), BaseHandler< BaseParticle >::getSize(), getSumRadiusLocal(), and MPIContainer::Instance().

Referenced by InitialConditions< SpeciesType >::getMeanRelativeContactRadius(), Sintering::getMeanRelativeContactRadius(), regimeForceUnitTest::getMeanRelativeContactRadius(), main(), regimeForceUnitTest::printTime(), and SingleParticle< SpeciesType >::writeEneTimeStep().

◆ getMomentum()

Vec3D ParticleHandler::getMomentum ( ) const
663 {
664  Vec3D momentum = {0, 0, 0};
665  for (auto p : *this)
666  if (!(p->isFixed() || p->isMPIParticle() || p->isPeriodicGhostParticle()))
667  momentum += p->getMomentum();
668  return getMPISum(momentum);
669 }

References getMPISum().

Referenced by DPMBase::getTotalMomentum(), main(), and LawinenBox::writeEneTimeStep().

◆ getName()

std::string ParticleHandler::getName ( ) const
override

Returns the name of the handler, namely the string "ParticleHandler".

Returns
The string "ParticleHandler".
1238 {
1239  return "ParticleHandler";
1240 }

◆ getNumberOfFixedObjects()

unsigned int ParticleHandler::getNumberOfFixedObjects ( ) const

Computes the number of fixed particles in the whole simulation.

1349 {
1350 #ifdef MERCURY_USE_MPI
1351  unsigned int numberOfFixedParticlesLocal = getNumberOfFixedObjectsLocal();
1352  unsigned int numberOfFixedParticles = 0;
1353 
1354  MPIContainer& communicator = MPIContainer::Instance();
1355  communicator.allReduce(numberOfFixedParticlesLocal, numberOfFixedParticles, MPI_SUM);
1356  return numberOfFixedParticles;
1357 #else
1359 #endif
1360 }

References getNumberOfFixedObjectsLocal(), and MPIContainer::Instance().

Referenced by LawinenBox::setupInitialConditions().

◆ getNumberOfFixedObjectsLocal()

unsigned int ParticleHandler::getNumberOfFixedObjectsLocal ( ) const

Computes the number of Fixed particles on a local domain.

Loops over all particles to check if the particle is fixed or not, in a local domain.

Returns
the number of fixed particles in a local domain
1333 {
1334  unsigned int numberOfFixedParticles = 0;
1335  for (BaseParticle* particle : *this)
1336  {
1337  if (particle->isFixed())
1338  {
1339  numberOfFixedParticles++;
1340  }
1341  }
1342  return numberOfFixedParticles;
1343 }

References BaseParticle::isFixed().

Referenced by getNumberOfFixedObjects().

◆ getNumberOfFixedParticles()

unsigned int ParticleHandler::getNumberOfFixedParticles ( ) const

Gets the number of particles that are fixed.

1006 {
1007  return NFixedParticles_;
1008 }

References NFixedParticles_.

◆ getNumberOfObjects()

unsigned int ParticleHandler::getNumberOfObjects ( ) const
override

Returns the number of objects in the container. In parallel code this practice is forbidden to avoid confusion with real and fake particles. If the size of the container is wished, call size()

1316 {
1317 //#ifdef MERCURY_USE_MPI
1318 // MPIContainer& communicator = MPIContainer::Instance();
1319 // if (communicator.getNumberOfProcessors() > 1)
1320 // {
1321 // logger(WARN,"When compiling with MPI please do not use getNumberOfObjects(). Instead use: getNumberOfRealObjectsLocal(), getNumberOfRealObjects() or getSize()");
1322 // }
1323 //#endif
1324  return getSize();
1325 }

References BaseHandler< BaseParticle >::getSize().

Referenced by Contact::actionsAfterSolve(), TwoByTwoMPIDomainMPI4Test::actionsAfterTimeStep(), GranularCollapse::actionsAfterTimeStep(), MercuryProblem::actionsAfterTimeStep(), Chutebelt::actionsBeforeTimeStep(), LawinenBox::actionsBeforeTimeStep(), SmoothChute::actionsBeforeTimeStep(), AngleOfRepose::actionsBeforeTimeStep(), ChutePeriodic::add_flow_particles(), SilbertPeriodic::add_flow_particles(), ChuteWithPeriodicInflow::AddContinuingBottom(), Chute::addFlowParticlesCompactly(), NautaMixer::addParticles(), statistics_while_running< T >::auto_set_domain(), statistics_while_running< T >::auto_set_z(), DPMBase::checkParticleForInteractionLocalPeriodic(), ChuteWithContraction::ChuteWithContraction(), ChuteWithPeriodicInflowAndContinuingBottom::ChuteWithPeriodicInflowAndContinuingBottom(), ChuteWithPeriodicInflowAndContraction::ChuteWithPeriodicInflowAndContraction(), ChuteWithPeriodicInflowAndVariableBottom::ChuteWithPeriodicInflowAndVariableBottom(), ChuteWithPeriodicInflow::cleanChute(), ChuteWithContraction::cleanChute(), Funnel::cleanChute(), Chute::cleanChute(), ClosedCSCRestart::ClosedCSCRestart(), ClosedCSCRun::ClosedCSCRun(), ContractionWithPeriodicInflow::ContractionWithPeriodicInflow(), Slide::create_rough_wall(), AngleOfRepose::createBaseSpecies(), SilbertPeriodic::createBaseSpecies(), CSCInit::CSCInit(), ChuteWithPeriodicInflow::ExtendInWidth(), SphericalIndenter::getBedHeight(), getNumberOfUnfixedParticles(), InitialConditions< SpeciesType >::InitialConditions(), ChuteWithPeriodicInflow::integrateBeforeForceComputation(), ContactDetectionIntersectionOfWallsTest::introduceParticlesAtWall(), LawinenBox::LawinenBox(), main(), ChuteBottom::makeRoughBottom(), LiquidMigrationSelfTest::outputXBallsData(), SphericalIndenter::outputXBallsData(), ChuteWithPeriodicInflow::printTime(), LawinenBox::printTime(), VerticalMixer::printTime(), SilbertPeriodic::printTime(), vibratedBed::printTime(), Chute::printTime(), CSCInit::save(), save(), ClosedCSCWalls::saveWalls(), CSCWalls::saveWalls(), MeshTriangle::setHandler(), ClosedCSCWalls::setupInitialConditions(), CSCRun::setupInitialConditions(), CSCWalls::setupInitialConditions(), Cstatic2d::setupInitialConditions(), Cstatic3D::setupInitialConditions(), Chutebelt::setupInitialConditions(), LawinenBox::setupInitialConditions(), Binary::setupInitialConditions(), FreeCooling2DinWalls::setupInitialConditions(), FreeCooling2DinWallsDemo::setupInitialConditions(), FreeCooling3DDemoProblem::setupInitialConditions(), FreeCooling3DinWallsDemo::setupInitialConditions(), FreeCoolingDemoProblem::setupInitialConditions(), HourGlass2D::setupInitialConditions(), HourGlass::setupInitialConditions(), AngleOfRepose::setupInitialConditions(), SilbertPeriodic::setupInitialConditions(), ParticleCreation::setupInitialConditions(), TriangulatedScrewSelfTest::setupInitialConditions(), TriangulatedStepWallSelfTest::setupInitialConditions(), TriangulatedWallSelfTest::setupInitialConditions(), SphericalIndenter::setupInitialConditions(), ScalingTestRun::setupInitialConditions(), GranularCollapse::setupInitialConditions(), Tutorial11::setupInitialConditions(), MD_demo::setupInitialConditions(), ChuteBottom::setupInitialConditions(), and SingleParticleIndenter::SingleParticleIndenter().

◆ getNumberOfRealObjects()

unsigned int ParticleHandler::getNumberOfRealObjects ( ) const

Returns the number of real objects (on all processors)

1295 {
1296 #ifdef MERCURY_USE_MPI
1297  MPIContainer& communicator = MPIContainer::Instance();
1298  unsigned int numberOfRealParticles = getNumberOfRealObjectsLocal();
1299 
1300  // \todo MX: use an allreduce here
1301  //Combine the total number of Particles into one number on processor 0
1302  communicator.reduce(numberOfRealParticles, MPI_SUM);
1303 
1304  //Broadcast new number to all the processorsi
1305  communicator.broadcast(numberOfRealParticles);
1306  return numberOfRealParticles;
1307 #else
1308  return getSize();
1309 #endif
1310 }

References MPIContainer::broadcast(), getNumberOfRealObjectsLocal(), BaseHandler< BaseParticle >::getSize(), and MPIContainer::Instance().

Referenced by Membrane::createVertexParticles(), DPMBase::decompose(), and HourGlass2D::setupInitialConditions().

◆ getNumberOfRealObjectsLocal()

unsigned int ParticleHandler::getNumberOfRealObjectsLocal ( ) const

Returns the number of real objects on a local domain. MPI particles and periodic particles are neglected.

Returns
the number of real particles (neglecting MPI and periodic) on a local domain
Todo:
MX: in future also add the periodic mpi particles
1274 {
1275 #ifdef MERCURY_USE_MPI
1276  const MPIContainer& communicator = MPIContainer::Instance();
1277  if (communicator.getNumberOfProcessors() > 1)
1278  {
1279  unsigned int numberOfFakeParticles = 0;
1280  numberOfFakeParticles += getDPMBase()->domainHandler.getCurrentDomain()->getNumberOfTrueMPIParticles();
1282  logger.assert_debug(numberOfFakeParticles <= getSize(), "More fake particles than getSize()");
1283  return (getSize() - numberOfFakeParticles);
1284  }
1285  else
1286  {
1287  return getSize();
1288  }
1289 #else
1290  return getSize();
1291 #endif
1292 }

References DPMBase::domainHandler, DomainHandler::getCurrentDomain(), BaseHandler< BaseParticle >::getDPMBase(), PeriodicBoundaryHandler::getNumberOfPeriodicGhostParticles(), MPIContainer::getNumberOfProcessors(), Domain::getNumberOfTrueMPIParticles(), BaseHandler< BaseParticle >::getSize(), MPIContainer::Instance(), logger, and DPMBase::periodicBoundaryHandler.

Referenced by MaserRepeatedOutInMPI2Test::actionsAfterSolve(), TwoByTwoMPIDomainMPI4Test::actionsAfterTimeStep(), getMeanRadius(), getNumberOfRealObjects(), and DPMBase::outputXBallsData().

◆ getNumberOfUnfixedParticles()

unsigned int ParticleHandler::getNumberOfUnfixedParticles ( ) const

Gets the number of particles that are not fixed.

1014 {
1016 }

References getNumberOfObjects(), and NFixedParticles_.

◆ getParticleAttribute()

template<typename T >
std::enable_if<std::is_scalar<T>::value, T>::type ParticleHandler::getParticleAttribute ( std::function< T(BaseParticle *)>  attribute,
AttributeType  type 
) const
inline

Computes an attribute type (min/max/..) of a particle attribute(position/velocity) in the global domain.

Many functions the particleHandler return a pointer to a BaseParticle, i.e. the fastest particle, however in parallel this is not usefull as pointers can't be send across processes. This function gives the flexibility to find a global particle extremum such as the fastest particle Velocity or lowest particle position.

Parameters
[in]attributeA function that obtains a scalar from a particle. i.e. position or radius
[in]typeAn AttribyteType tells this function what to do with the attribute, take the maximum or the minimum
Returns
Returns a scalar value representing the AttributeType of the Attribute: In easier terms returns the max/min/... of a particle atribute such as radius
306  {
307 #ifdef MERCURY_USE_MPI
308  T particleAttributeLocal = getParticleAttributeLocal(attribute, type);
309  T particleAttributeGlobal;
310 
311  //Communicate local to global using the approriate rule
312  MPIContainer& communicator = MPIContainer::Instance();
313  switch(type)
314  {
315  case AttributeType::MIN :
316  communicator.allReduce(particleAttributeLocal,particleAttributeGlobal,MPI_MIN);
317  break;
318  case AttributeType::MAX :
319  communicator.allReduce(particleAttributeLocal,particleAttributeGlobal,MPI_MAX);
320  break;
321  default :
322  logger(ERROR,"Attribute type is not recognised");
323  break;
324  }
325  return particleAttributeGlobal;
326 #else
327  return getParticleAttributeLocal(attribute, type);
328 #endif
329  }

References ERROR, getParticleAttributeLocal(), MPIContainer::Instance(), logger, MAX, and MIN.

◆ getParticleAttributeLocal()

template<typename T >
std::enable_if<std::is_scalar<T>::value, T>::type ParticleHandler::getParticleAttributeLocal ( std::function< T(BaseParticle *)>  attribute,
AttributeType  type 
) const
inline

Computes an attribute type (min/max/..) of a particle attribute (position/velocity) in a local domain.

Computes an attribute type (min/max/..) of a particle attribute (position/velocity) in a local domain

Many functions the particleHandler return a pointer to a BaseParticle, i.e. the fastest particle, however in parallel this is not usefull as pointers can't be send across processes. This function gives the flexibility to find a global particle extremum such as the fastest particle Velocity or lowest particle position.

Parameters
[in]attributeA function that obtains a scalar from a particle. i.e. position or radius
[in]typeAn AttribyteType tells this function what to do with the attribute, take the maximum or the minimum
Returns
Returns a scalar value representing the AttributeType of the Attribute: In easier terms returns the max/min/... of a particle atribute such as radius
245  {
246  T attributeParticle;
247  T attributeFinal;
248 
249  if ((*this).getSize() == 0)
250  {
251  logger(WARN, "ParticleHandler is empty: returning 0.0");
252  attributeFinal = 0;
253  return 0.0;
254  }
255  else
256  {
257  //Initialise with the first particle found
258  attributeParticle = attribute(objects_[0]);
259  attributeFinal = attributeParticle;
260 
261  //Findn the final attribute
262  for (BaseParticle* particle : (*this))
263  {
264  //Obtain the attribute
265  if (!(particle->isMPIParticle() || particle->isPeriodicGhostParticle() || particle->isFixed()))
266  {
267  attributeParticle = attribute(particle);
268  }
269 
270  //Decide what to do with the magnitude of the attribute
271  switch (type)
272  {
273  case AttributeType::MIN :
274  if (attributeParticle < attributeFinal)
275  {
276  attributeFinal = attributeParticle;
277  }
278  break;
279  case AttributeType::MAX :
280  if (attributeParticle > attributeFinal)
281  {
282  attributeFinal = attributeParticle;
283  }
284  break;
285  default :
286  logger(ERROR, "Attribute type is not recognised");
287  break;
288  }
289  }
290  return attributeFinal;
291  }
292  }

References ERROR, logger, MAX, MIN, BaseHandler< BaseParticle >::objects_, and WARN.

Referenced by getParticleAttribute().

◆ getRotationalEnergy()

Mdouble ParticleHandler::getRotationalEnergy ( ) const
583 {
584 #ifdef MERCURY_USE_MPI
585  Mdouble rotationalEnergyLocal = getRotationalEnergyLocal();
586  Mdouble rotationalEnergyGlobal = 0.0;
587 
588  //sum up over all domains
589  MPIContainer& communicator = MPIContainer::Instance();
590  communicator.allReduce(rotationalEnergyLocal, rotationalEnergyGlobal, MPI_SUM);
591 
592  return rotationalEnergyGlobal;
593 #else
594  return getRotationalEnergyLocal();
595 #endif
596 }

References getRotationalEnergyLocal(), and MPIContainer::Instance().

Referenced by main(), DPMBase::writeEneTimeStep(), and LawinenBox::writeEneTimeStep().

◆ getRotationalEnergyLocal()

Mdouble ParticleHandler::getRotationalEnergyLocal ( ) const
private
570 {
571  Mdouble ene = 0;
572  for (auto p : *this)
573  {
574  if (!(p->isMPIParticle() || p->isPeriodicGhostParticle()))
575  {
576  ene += p->getRotationalEnergy();
577  }
578  }
579  return ene;
580 }

Referenced by getRotationalEnergy().

◆ getSmallestInteractionRadius()

Mdouble ParticleHandler::getSmallestInteractionRadius ( ) const

Returns the smallest interaction radius.

733 {
734 #ifdef MERCURY_USE_MPI
735  //Compute the local value
736  Mdouble smallestInteractionRadiusLocal = getSmallestInteractionRadiusLocal();
737  Mdouble smallestInteractionRadiusGlobal = 0.0;
738 
739  //Obtain the global value
740  MPIContainer& communicator = MPIContainer::Instance();
741  communicator.allReduce(smallestInteractionRadiusLocal, smallestInteractionRadiusGlobal, MPI_MIN);
742 
743  return smallestInteractionRadiusGlobal;
744 
745 #else
747 #endif
748 }

References getSmallestInteractionRadiusLocal(), and MPIContainer::Instance().

Referenced by Contact::actionsAfterSolve(), and main().

◆ getSmallestInteractionRadiusLocal()

Mdouble ParticleHandler::getSmallestInteractionRadiusLocal ( ) const

Returns the smallest interaction radius of the current domain.

718 {
719  if (!(getSmallestParticleLocal() == nullptr))
720  {
722  }
723  else
724  {
725  return 0.0;
726  }
727 }

References BaseParticle::getMaxInteractionRadius(), and getSmallestParticleLocal().

Referenced by MercuryBase::getHGridTargetMinInteractionRadius(), and getSmallestInteractionRadius().

◆ getSmallestParticle()

BaseParticle * ParticleHandler::getSmallestParticle ( ) const

Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler of the local domain. When mercury is running in parallel this function throws an error since a pointer to another domain is useless.

Returns
A pointer to the to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
508 {
509 #ifdef MERCURY_USE_MPI
510  logger(WARN,"getSmallestParticle should not be used in parallel; use getSmallestInteractionRadius or "
511  "ParticleSpecies::getSmallestParticleMass instead");
512  return nullptr;
513 #else
514  return getSmallestParticleLocal();
515 #endif
516 }

References getSmallestParticleLocal(), logger, and WARN.

Referenced by HGridOptimiser::initialise().

◆ getSmallestParticleLocal()

BaseParticle * ParticleHandler::getSmallestParticleLocal ( ) const

Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler of the local domain.

Returns
A pointer to the to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
499 {
500  return smallestParticle_;
501 }

References smallestParticle_.

Referenced by getSmallestInteractionRadiusLocal(), getSmallestParticle(), RotatingDrum::setupInitialConditions(), and DPMBase::writeFstatHeader().

◆ getSumRadiusLocal()

Mdouble ParticleHandler::getSumRadiusLocal ( ) const
private
Returns
The sum of all particle radii
788 {
789  Mdouble sumRadius = 0;
790  for (BaseParticle* const p : objects_)
791  {
792  if (!(p->isMPIParticle() || p->isPeriodicGhostParticle()))
793  {
794  sumRadius += p->getRadius();
795  }
796  }
797  return sumRadius;
798 }

References BaseHandler< BaseParticle >::objects_.

Referenced by getMeanRadius().

◆ getVolume()

Mdouble ParticleHandler::getVolume ( ) const

◆ getVolumeLocal()

Mdouble ParticleHandler::getVolumeLocal ( ) const
private
1243 {
1244  Mdouble volume = 0;
1245  for (auto p : *this)
1246  {
1247  if (!(p->isFixed() || p->isPeriodicGhostParticle() || p->isMPIParticle()))
1248  volume += p->getVolume();
1249  }
1250  return volume;
1251 }

Referenced by getVolume().

◆ operator=()

ParticleHandler & ParticleHandler::operator= ( const ParticleHandler rhs)

Assignment operator.

Parameters
[in]rhsThe ParticleHandler on the right hand side of the assignment.

This is not a copy assignment operator! It copies the DPMBase and all BaseParticle, and sets the other variables to 0. After that, it computes the smallest and largest particle in this handler.

85 {
86  if (this != &rhs)
87  {
88  clear();
89  largestParticle_ = nullptr;
90  smallestParticle_ = nullptr;
92  if (!objects_.empty())
93  {
96  }
97  }
98  logger(DEBUG, "ParticleHandler::operator = (const ParticleHandler& rhs) finished");
99  return *this;
100 }

References clear(), computeLargestParticle(), computeSmallestParticle(), BaseHandler< BaseParticle >::copyContentsFromOtherHandler(), FATAL, largestParticle_, logger, BaseHandler< BaseParticle >::objects_, and smallestParticle_.

◆ readAndAddObject()

void ParticleHandler::readAndAddObject ( std::istream &  is)
overridevirtual
     \brief Create a new particle, based on the information from old-style restart data.
    &zwj;/

void readAndCreateOldObject(std::istream &is, const std::string& type);

/*!
   \brief Create a new particle in the WallHandler, based on the information provided in a restart file.
Parameters
[in]isThe input stream from which the information is read.

Implements BaseHandler< BaseParticle >.

1085 {
1087  addExistingObject(o);
1088 }

References addExistingObject(), and readAndCreateObject().

Referenced by DPMBase::read().

◆ readAndCreateObject()

BaseParticle * ParticleHandler::readAndCreateObject ( std::istream &  is)

Create a new particle, based on the information provided in a restart file.

Parameters
[in]isThe input stream from which the information is read.
1058 {
1059  std::string type;
1060  BaseParticle* particle = nullptr;
1061  if (getStorageCapacity() > 0)
1062  {
1063  is >> type;
1064  logger(DEBUG, "ParticleHandler::readAndCreateObject(is): type %", type);
1065  particle = createObject(type);
1066  particle->setHandler(this);
1067  particle->read(is);
1068  }
1069  else //for insertion boundaries
1070  {
1071  is >> type;
1072  logger(DEBUG, "ParticleHandler::readAndCreateObject(is): type %", type);
1073  particle = createObject(type);
1074  particle->setHandler(this);
1075  particle->read(is);
1076  }
1077  particle->setSpecies(getDPMBase()->speciesHandler.getObject(particle->getIndSpecies()));
1078  return particle;
1079 }

References createObject(), FATAL, BaseHandler< BaseParticle >::getDPMBase(), BaseInteractable::getIndSpecies(), BaseHandler< BaseParticle >::getStorageCapacity(), logger, BaseParticle::read(), BaseParticle::setHandler(), and BaseParticle::setSpecies().

Referenced by InsertionBoundary::read(), and readAndAddObject().

◆ removedFixedParticle()

void ParticleHandler::removedFixedParticle ( )

Decrement of the number of fixed particles.

Todo:
MX: For Jonny, is this still required, keeping the parallel code in mind?
1230 {
1231  NFixedParticles_--;
1232 }

References NFixedParticles_.

Referenced by BaseParticle::unfix(), and BaseParticle::~BaseParticle().

◆ removeGhostObject()

void ParticleHandler::removeGhostObject ( unsigned int  index)

Removes a BaseParticle from the ParticleHandler without a global check, this is only to be done for mpi routines.

Parameters
[in]indexThe index of which BaseParticle has to be removed from this ParticleHandler.

The BaseParticle with index is removed and the last BaseParticle in the vector is moved to its position. It also removes the BaseParticle from the HGrid. This function is only called by the parallel routines where we are sure the particles have been flushed out of the communication boundaries.

419 {
420 #ifdef MERCURY_USE_MPI
421 #ifdef CONTACT_LIST_HGRID
422  getDPMBase()->getPossibleContactList().remove_ParticlePosibleContacts(getObject(id));
423 #endif
425  // broadcast the particle removal
426  getDPMBase()->handleParticleRemoval(getObject(index)->getId());
428 #else
429  logger(ERROR, "This function should only be used interally for mpi routines");
430 #endif
431 }

References ERROR, BaseHandler< BaseParticle >::getDPMBase(), BaseHandler< BaseParticle >::getObject(), DPMBase::handleParticleRemoval(), DPMBase::hGridRemoveParticle(), logger, and BaseHandler< T >::removeObject().

Referenced by DeletionBoundary::checkBoundaryAfterParticleMoved(), DPMBase::checkInteractionWithBoundaries(), and DPMBase::deleteGhostParticles().

◆ removeLastObject()

void ParticleHandler::removeLastObject ( )

Removes the last BaseParticle from the ParticleHandler.

Function that removes the last object from this ParticleHandler. It also removes the particle from the HGrid.

438 {
439 #ifdef CONTACT_LIST_HGRID
440  getDPMBase()->getPossibleContactList().remove_ParticlePosibleContacts(getLastObject());
441 #endif
445 }

References BaseHandler< BaseParticle >::getDPMBase(), BaseHandler< BaseParticle >::getLastObject(), DPMBase::handleParticleRemoval(), DPMBase::hGridRemoveParticle(), and BaseHandler< T >::removeLastObject().

Referenced by Penetration::setupInitialConditions().

◆ removeObject()

void ParticleHandler::removeObject ( unsigned int  index)
overridevirtual

Removes a BaseParticle from the ParticleHandler.

Parameters
[in]indexThe index of which BaseParticle has to be removed from this ParticleHandler.

The BaseParticle with index is removed and the last BaseParticle in the vector is moved to its position. It also removes the BaseParticle from the HGrid. When running this in parallel a warning is thrown that deleting particles might cause havoc in the communication between boundaries, as the deleted particle might still be in one of the boundary lists

Reimplemented from BaseHandler< BaseParticle >.

391 {
392 #ifdef MERCURY_USE_MPI
393  MPIContainer& communicator = MPIContainer::Instance();
394  if (communicator.getNumberOfProcessors() > 1 )
395  {
396  logger(WARN, "[ParticleHandler::removeObject(const unsigned int)] Using the function removeObject in parallel could lead to out-of-sync communication, Instead use deletion boundaries");
397  }
398 #endif
399 #ifdef CONTACT_LIST_HGRID
400  getDPMBase()->getPossibleContactList().remove_ParticlePosibleContacts(getObject(id));
401 #endif
403  // broadcast the particle removal
404  getDPMBase()->handleParticleRemoval(getObject(index)->getId());
406 }

References BaseHandler< BaseParticle >::getDPMBase(), MPIContainer::getNumberOfProcessors(), BaseHandler< BaseParticle >::getObject(), DPMBase::handleParticleRemoval(), DPMBase::hGridRemoveParticle(), MPIContainer::Instance(), logger, BaseHandler< T >::removeObject(), and WARN.

Referenced by AngleOfRepose::actionsBeforeTimeStep(), PeriodicWallsWithSlidingFrictionUnitTest::actionsBeforeTimeStep(), SilbertPeriodic::add_flow_particles(), CircularPeriodicBoundary::checkBoundaryAfterParticleMoved(), ConstantMassFlowMaserBoundary::checkBoundaryAfterParticleMoved(), DeletionBoundary::checkBoundaryAfterParticleMoved(), ChuteWithContraction::ChuteWithContraction(), ChuteWithPeriodicInflowAndContraction::ChuteWithPeriodicInflowAndContraction(), ChuteWithPeriodicInflow::cleanChute(), ChuteWithContraction::cleanChute(), Funnel::cleanChute(), Chute::cleanChute(), ContactDetectionTester::cleanup(), ContractionWithPeriodicInflow::ContractionWithPeriodicInflow(), ChuteBottom::makeRoughBottom(), CurvyChute::recreateBottom(), DPMBase::removeDuplicatePeriodicParticles(), CSCWalls::saveWalls(), and AngleOfRepose::setupInitialConditions().

◆ write()

Member Data Documentation

◆ largestParticle_

BaseParticle* ParticleHandler::largestParticle_
private

A pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.

Todo:
TW: note that checkExtrema gets called if a particle gets created and its Species and Radius gets set, even if it's not yet included in the particleHandler! This is necessary to check a not included particle for overlaps before inserting it into the handler. Not sure if this is a sensible structure; to be discussed. Note: these statistic now include mpi and ghost particles as well

Referenced by checkExtrema(), checkExtremaOnDelete(), clear(), computeLargestParticle(), getLargestParticleLocal(), operator=(), ParticleHandler(), and ~ParticleHandler().

◆ NFixedParticles_

unsigned int ParticleHandler::NFixedParticles_
private

◆ smallestParticle_

BaseParticle* ParticleHandler::smallestParticle_
private

A pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.

Referenced by checkExtrema(), checkExtremaOnDelete(), clear(), computeSmallestParticle(), getSmallestParticleLocal(), operator=(), ParticleHandler(), and ~ParticleHandler().


The documentation for this class was generated from the following files:
BaseHandler< BaseParticle >::setDPMBase
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
Definition: BaseHandler.h:718
BaseHandler< BaseParticle >::getStorageCapacity
unsigned int getStorageCapacity() const
Gets the storage capacity of this BaseHandler.
Definition: BaseHandler.h:662
ParticleHandler::checkExtrema
void checkExtrema(BaseParticle *P)
Checks if the extrema of this ParticleHandler needs updating.
Definition: ParticleHandler.cc:1163
BaseHandler::increaseId
void increaseId()
Definition: BaseHandler.h:251
BaseInteractable::getSpecies
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
Definition: BaseInteractable.h:108
ParticleHandler::getLargestInteractionRadiusLocal
Mdouble getLargestInteractionRadiusLocal() const
Returns the largest interaction radius of the current domain.
Definition: ParticleHandler.cc:753
ParticleHandler::createObject
static BaseParticle * createObject(const std::string &type)
Reads BaseParticle into the ParticleHandler from restart data.
Definition: ParticleHandler.cc:1021
BaseParticle::setHandler
void setHandler(ParticleHandler *handler)
Sets the pointer to the particle's ParticleHandler.
Definition: BaseParticle.cc:651
ParticleHandler::largestParticle_
BaseParticle * largestParticle_
A pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition: ParticleHandler.h:465
PARTICLE_DATA
@ PARTICLE_DATA
Definition: MpiContainer.h:79
MIN
@ MIN
Definition: ParticleHandler.h:39
BaseHandler< BaseParticle >
ParticleHandler::getVolumeLocal
Mdouble getVolumeLocal() const
Definition: ParticleHandler.cc:1242
LiquidFilmParticle::getLiquidVolume
Mdouble getLiquidVolume() const
Definition: LiquidFilmParticle.h:103
DPMBase::hGridUpdateParticle
virtual void hGridUpdateParticle(BaseParticle *obj UNUSED)
Definition: DPMBase.cc:1695
BaseHandler::addGhostObject
virtual void addGhostObject(T *O)
Adds a new Object to the BaseHandler. called by the to avoid increasing the id.
Definition: BaseHandler.h:444
logger
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
DPMBase::hGridRemoveParticle
virtual void hGridRemoveParticle(BaseParticle *obj UNUSED)
Definition: DPMBase.cc:1702
ParticleHandler::getNumberOfObjects
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:1315
Vec3D::X
Mdouble X
the vector components
Definition: Vector.h:65
MAX_PROC
#define MAX_PROC
Definition: GeneralDefine.h:51
ParticleHandler::getMassTimesPosition
Vec3D getMassTimesPosition() const
Definition: ParticleHandler.cc:632
DPMBase::periodicBoundaryHandler
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1415
ParticleHandler::getKineticEnergyLocal
Mdouble getKineticEnergyLocal() const
Definition: ParticleHandler.cc:540
copyDataFromMPIParticleToParticle
void copyDataFromMPIParticleToParticle(MPIParticle *bP, BaseParticle *p, ParticleHandler *particleHandler)
Copies data from an MPIParticle class to a BaseParticle and sets the particleHandler and species.
Definition: MpiDataClass.cc:105
PeriodicBoundaryHandler::getNumberOfPeriodicGhostParticles
unsigned int getNumberOfPeriodicGhostParticles()
Returns the number of particles that are flagged is periodicGhostParticle.
Definition: PeriodicBoundaryHandler.cc:357
BaseHandler< BaseParticle >::getSize
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
MPISphericalParticle::copyDataFromParticleToMPIParticle
void copyDataFromParticleToMPIParticle(BaseParticle *p)
Definition: MpiDataClass.cc:131
MPIContainer::receive
std::enable_if< std::is_scalar< T >::value, void >::type receive(T &t, int from, int tag)
asynchronously receive a scalar from some other processor.
Definition: MpiContainer.h:221
BaseHandler::removeLastObject
void removeLastObject()
Removes the last Object from the BaseHandler.
Definition: BaseHandler.h:511
PARTICLE
@ PARTICLE
Definition: MpiContainer.h:67
MPIContainer::getProcessorID
std::size_t getProcessorID()
Reduces a scalar on all processors to one scalar on a target processor.
Definition: MpiContainer.cc:113
DPMBase::handleParticleRemoval
virtual void handleParticleRemoval(unsigned int id)
Handles the removal of particles from the particleHandler.
Definition: DPMBase.cc:5298
BaseInteractable::getIndSpecies
unsigned int getIndSpecies() const
Returns the index of the species associated with the interactable object.
Definition: BaseInteractable.h:88
INFO
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
ParticleHandler::getLowestVelocityComponentParticleLocal
BaseParticle * getLowestVelocityComponentParticleLocal(int i) const
Gets a pointer to the particle with the lowest velocity in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:901
Vec3D
Definition: Vector.h:50
ParticleHandler::getLowestPositionComponentParticleLocal
BaseParticle * getLowestPositionComponentParticleLocal(int i) const
Gets a pointer to the particle with the lowest coordinates in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:825
ParticleHandler::getParticleAttributeLocal
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
DPMBase::handleParticleAddition
virtual void handleParticleAddition(unsigned int id, BaseParticle *p)
Definition: DPMBase.cc:5313
ParticleHandler::getMassTimesPositionLocal
Vec3D getMassTimesPositionLocal() const
Definition: ParticleHandler.cc:623
BaseHandler::addExistingObject
virtual void addExistingObject(T *O)
Adds an existing object to the BaseHandler without changing the id of the object.
Definition: BaseHandler.h:417
Mdouble
double Mdouble
Definition: GeneralDefine.h:34
ParticleHandler::getHighestVelocityComponentParticleLocal
BaseParticle * getHighestVelocityComponentParticleLocal(int i) const
Gets a pointer to the particle with the highest velocity in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:937
NUMBER_OF_PROCESSORS
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
ParticleHandler::getLargestParticle
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:530
BaseHandler< BaseParticle >::objects_
std::vector< BaseParticle * > objects_
The actual list of Object pointers.
Definition: BaseHandler.h:302
DPMBase::mpiInsertParticleCheck
bool mpiInsertParticleCheck(BaseParticle *P)
Function that checks if the mpi particle should really be inserted by the current domain.
Definition: DPMBase.cc:1723
ParticleHandler::computeLargestParticle
void computeLargestParticle()
Computes the largest particle (by interaction radius) and sets it in largestParticle_.
Definition: ParticleHandler.cc:471
BaseParticle::isMPIParticle
bool isMPIParticle() const
Indicates if this particle is a ghost in the MPI domain.
Definition: BaseParticle.cc:175
ParticleHandler::addExistingObject
void addExistingObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:130
ERROR
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
LiquidFilmParticle
Definition: LiquidFilmParticle.h:36
BaseHandler::removeObject
virtual void removeObject(unsigned const int index)
Removes an Object from the BaseHandler.
Definition: BaseHandler.h:472
ParticleHandler::addGhostObject
void addGhostObject(int fromPrcessor, int toProcessor, BaseParticle *p)
Adds a ghost particle located at fromProcessor to toProcessor.
Definition: ParticleHandler.cc:283
ParticleHandler::NFixedParticles_
unsigned int NFixedParticles_
Number of fixed particles.
Definition: ParticleHandler.h:475
BaseParticle::setSpecies
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:804
DomainHandler::getCurrentDomain
Domain * getCurrentDomain()
Gets the domain assigned to the processor.
Definition: DomainHandler.cc:250
WARN
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:54
ParticleHandler::clear
void clear() override
Empties the whole ParticleHandler by removing all BaseParticle.
Definition: ParticleHandler.cc:973
Log::FATAL
@ FATAL
DPMBase::domainHandler
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1420
Domain::getNumberOfTrueMPIParticles
unsigned int getNumberOfTrueMPIParticles()
Obtains the number of particles in the particleHandler that are MPIParticles, but NOT periodic partic...
Definition: Domain.cc:1679
ParticleHandler::getNumberOfRealObjectsLocal
unsigned int getNumberOfRealObjectsLocal() const
Returns the number of real objects on a local domain. MPI particles and periodic particles are neglec...
Definition: ParticleHandler.cc:1273
MPIContainer::getNumberOfProcessors
std::size_t getNumberOfProcessors() const
Get the total number of processors participating in this simulation.
Definition: MpiContainer.cc:104
SphericalParticle
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
BaseParticle::setPeriodicComplexity
void setPeriodicComplexity(std::vector< int > complexity)
Set the periodic communication complexity of the particle.
Definition: BaseParticle.cc:200
MAX
@ MAX
Definition: ParticleHandler.h:39
MPIContainer::sync
void sync()
Process all pending asynchronous communication requests before continuing.
Definition: MpiContainer.h:152
MPIContainer
This class contains all information and functions required for communication between processors.
Definition: MpiContainer.h:130
ParticleHandler::getSmallestParticleLocal
BaseParticle * getSmallestParticleLocal() const
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler of the loc...
Definition: ParticleHandler.cc:498
getMPISum
Vec3D getMPISum(Vec3D &val)
Definition: MpiDataClass.cc:199
DPMBase::updateGhostGrid
void updateGhostGrid(BaseParticle *P)
Checks if the Domain/periodic interaction distance needs to be updated and updates it accordingly.
Definition: DPMBase.cc:1828
Vec3D::Y
Mdouble Y
Definition: Vector.h:65
MPIParticle
Data class to send a particle over MPI.
Definition: MpiDataClass.h:81
ThermalParticle
Definition: ThermalParticle.h:36
MPIContainer::send
std::enable_if< std::is_scalar< T >::value, void >::type send(T &t, int to, int tag)
Asynchronously send a scalar to some other processor.
Definition: MpiContainer.h:171
constants::i
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
DPMBase::setRotation
void setRotation(bool rotation)
Sets whether particle rotation is enabled or disabled.
Definition: DPMBase.h:552
ParticleHandler::getFastestParticleLocal
BaseParticle * getFastestParticleLocal() const
Gets a pointer to the fastest BaseParticle in this ParticleHandler.
Definition: ParticleHandler.cc:683
BaseHandler< BaseParticle >::getLastObject
BaseParticle * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
BaseHandler< BaseParticle >::getObject
BaseParticle * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
BaseObject::getId
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
ParticleHandler::computeSmallestParticle
void computeSmallestParticle()
Computes the smallest particle (by interaction radius) and sets it in smallestParticle_.
Definition: ParticleHandler.cc:447
ParticleHandler::getRotationalEnergyLocal
Mdouble getRotationalEnergyLocal() const
Definition: ParticleHandler.cc:569
ParticleHandler::smallestParticle_
BaseParticle * smallestParticle_
A pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
Definition: ParticleHandler.h:470
ParticleHandler::getSmallestInteractionRadiusLocal
Mdouble getSmallestInteractionRadiusLocal() const
Returns the smallest interaction radius of the current domain.
Definition: ParticleHandler.cc:717
BaseHandler::getDPMBase
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
BaseParticle
Definition: BaseParticle.h:54
ParticleHandler::addObject
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:170
BaseParticle::getMaxInteractionRadius
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e....
Definition: BaseParticle.h:362
SuperQuadricParticle
Definition: SuperQuadricParticle.h:56
BaseHandler< BaseParticle >::copyContentsFromOtherHandler
void copyContentsFromOtherHandler(const BaseHandler< BaseParticle > &BH)
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handle...
Definition: BaseHandler.h:367
ParticleHandler::getNumberOfFixedObjectsLocal
unsigned int getNumberOfFixedObjectsLocal() const
Computes the number of Fixed particles on a local domain.
Definition: ParticleHandler.cc:1332
BaseHandler::clear
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Definition: BaseHandler.h:528
constants::NaN
const Mdouble NaN
Definition: GeneralDefine.h:43
BaseParticle::read
void read(std::istream &is) override
Particle read function, which accepts an std::istream as input.
Definition: BaseParticle.cc:368
ParticleHandler::getMass
Mdouble getMass() const
Definition: ParticleHandler.cc:607
MPIContainer::broadcast
std::enable_if< std::is_scalar< T >::value, void >::type broadcast(T &t, int fromProcessor=0)
Broadcasts a scalar from the root to all other processors.
Definition: MpiContainer.h:441
ParticleHandler::getLargestParticleLocal
BaseParticle * getLargestParticleLocal() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in the ParticleHandler of the local...
Definition: ParticleHandler.cc:522
ParticleHandler::getMassLocal
Mdouble getMassLocal() const
Definition: ParticleHandler.cc:598
BaseParticle::isFixed
bool isFixed() const override
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Definition: BaseParticle.h:93
BaseParticle::isSphericalParticle
virtual bool isSphericalParticle() const
Definition: BaseParticle.h:645
Vec3D::Z
Mdouble Z
Definition: Vector.h:65
BaseParticle::isPeriodicGhostParticle
bool isPeriodicGhostParticle() const
Indicates if this particle is a ghost in the periodic boundary.
Definition: BaseParticle.cc:291
DPMBase::insertGhostParticle
void insertGhostParticle(BaseParticle *P)
This function inserts a particle in the mpi communication boundaries.
Definition: DPMBase.cc:1802
HeatFluidCoupledParticle
Class that implements particles which store both temperature/heat capacity and liquid content which i...
Definition: HeatFluidCoupledParticle.h:42
ParticleHandler::getHighestPositionComponentParticleLocal
BaseParticle * getHighestPositionComponentParticleLocal(int i) const
Gets a pointer to the particle with the highest coordinates in direction i in this ParticleHandler.
Definition: ParticleHandler.cc:864
BaseHandler::addObject
virtual void addObject(T *object)
Adds a new Object to the BaseHandler.
Definition: BaseHandler.h:431
ParticleHandler::getSumRadiusLocal
Mdouble getSumRadiusLocal() const
Definition: ParticleHandler.cc:787
ParticleHandler::readAndCreateObject
BaseParticle * readAndCreateObject(std::istream &is)
Create a new particle, based on the information provided in a restart file.
Definition: ParticleHandler.cc:1057
DPMBase::hGridInsertParticle
virtual void hGridInsertParticle(BaseParticle *obj UNUSED)
Definition: DPMBase.cc:1688
ParticleSpecies::computeMass
void computeMass(BaseParticle *p) const
Compute Particle mass function, which required a reference to the Species vector. It computes the Par...
Definition: ParticleSpecies.cc:166
MPIContainer::Instance
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134