MpiDataClass.cc File Reference

Functions

void copyDataFromMPIParticleToParticle (MPIParticle *bP, BaseParticle *p, ParticleHandler *particleHandler)
 Copies data from an MPIParticle class to a BaseParticle and sets the particleHandler and species. More...
 
MPIParticle copyDataFromParticleToMPIParticle (BaseParticle *p)
 Copies data from a NonSphericalParticle to an MPIParticle class and returns this. More...
 
MPIParticlePosition copyPositionFrom (BaseParticle *particle)
 Copies the position from a particle to an MPIParticlePosition class. More...
 
MPIParticleVelocity copyVelocityFrom (BaseParticle *particle)
 Copies the velocity from a particle to an MPIParticleVelocity class. More...
 
Vec3D getMPISum (Vec3D &val)
 
double getMPISum (double val)
 

Function Documentation

◆ copyDataFromMPIParticleToParticle()

void copyDataFromMPIParticleToParticle ( MPIParticle bP,
BaseParticle p,
ParticleHandler particleHandler 
)

Copies data from an MPIParticle class to a BaseParticle and sets the particleHandler and species.

Copies data from an MPIParticle class to a BaseParticle.

Parameters
[in]bPPointer to an MPIParticle which contains data for a ghost particle
[in,out]pPointer to BaseParticle, a ghost particle that will be added to the domain
[in]particleHandlerPointer to the ParticleHandler required for creating a new particle
Todo:
MX: Maybe renamet his function to setParticleSpecies() or something
106 {
107  //Set the species of the particle, but before we can do that we have to set the handler
108  p->setHandler(particleHandler);
109  //p->setIndSpecies(bP->indSpecies);
111  p->setSpecies(species);
113 }
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
ParticleHandler * getHandler() const
Returns pointer to the particle's ParticleHandler.
Definition: BaseParticle.cc:673
void setHandler(ParticleHandler *handler)
Sets the pointer to the particle's ParticleHandler.
Definition: BaseParticle.cc:663
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
void copyDataFromMPIParticleToParticle(BaseParticle *p)
Copies data from a BaseParticle to an MPIParticle class and returns this.
Definition: MpiDataClass.cc:51
unsigned int indSpecies
Definition: MpiDataClass.h:43
Definition: ParticleSpecies.h:37

References MPISphericalParticle::copyDataFromMPIParticleToParticle(), BaseHandler< T >::getDPMBase(), BaseParticle::getHandler(), BaseHandler< T >::getObject(), MPISphericalParticle::indSpecies, BaseParticle::setHandler(), BaseParticle::setSpecies(), and DPMBase::speciesHandler.

Referenced by ParticleHandler::addGhostObject(), ParticleHandler::addObject(), InsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), Domain::processReceivedBoundaryParticleData(), PeriodicBoundaryHandler::processReceivedGhostParticleData(), and DPMBase::synchroniseParticle().

◆ copyDataFromParticleToMPIParticle()

MPIParticle copyDataFromParticleToMPIParticle ( BaseParticle p)

Copies data from a NonSphericalParticle to an MPIParticle class and returns this.

Copies data from a BaseParticle to an MPIParticle class and returns this.

In order to create ghost particles on other processors, data of particles have to be transmitted to other processors. Only the required data is sent. The data is sent in an MPIParticle data class and this function copies the data from a particle into that class.

Parameters
[in]pPointer to a NonSphericalParticle particle from which data is copied
Returns
MPIParticle class is returned filled with data from BaseParticle p
125 {
126  MPIParticle bP;
128  return bP;
129 }
Data class to send a particle over MPI.
Definition: MpiDataClass.h:81
void copyDataFromParticleToMPIParticle(BaseParticle *p)
Definition: MpiDataClass.cc:131

References MPISphericalParticle::copyDataFromParticleToMPIParticle().

Referenced by RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), Domain::collectBoundaryParticleData(), and PeriodicBoundaryHandler::collectGhostParticleData().

◆ copyPositionFrom()

MPIParticlePosition copyPositionFrom ( BaseParticle particle)

Copies the position from a particle to an MPIParticlePosition class.

Parameters
[in]particleBaseParticle which position is copied
Returns
MPIParticlePosition object containing the position of the particle
175 {
176  MPIParticlePosition particlePosition;
177  particlePosition.id = particle->getId();
178  particlePosition.position = particle->getPosition();
179  particlePosition.orientation = particle->getOrientation();
180  if (std::is_base_of<MPILiquidFilmParticle,MPIParticle>())
181  particlePosition.liquidVolume = static_cast<LiquidFilmParticle*>(particle)->getLiquidVolume();
182  return particlePosition;
183 }
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:230
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
Definition: LiquidFilmParticle.h:36
Data class to send a particle position over MPI.
Definition: MpiDataClass.h:90
Vec3D position
Definition: MpiDataClass.h:93
Quaternion orientation
Definition: MpiDataClass.h:94
Mdouble liquidVolume
Definition: MpiDataClass.h:95
unsigned int id
Definition: MpiDataClass.h:92

References BaseObject::getId(), BaseInteractable::getOrientation(), BaseInteractable::getPosition(), MPIParticlePosition::id, MPIParticlePosition::liquidVolume, MPIParticlePosition::orientation, and MPIParticlePosition::position.

Referenced by Domain::preparePositionAndVelocityUpdate(), and PeriodicBoundaryHandler::preparePositionAndVelocityUpdate().

◆ copyVelocityFrom()

MPIParticleVelocity copyVelocityFrom ( BaseParticle particle)

Copies the velocity from a particle to an MPIParticleVelocity class.

Parameters
[in]particleBaseParticle which velocity is copied
Returns
MPIParticleVelocityn object containing the velocity of the particle
191 {
192  MPIParticleVelocity particleVelocity;
193  particleVelocity.velocity = particle->getVelocity();
194  particleVelocity.angularVelocity = particle->getAngularVelocity();
195 
196  return particleVelocity;
197 }
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
Definition: BaseInteractable.cc:341
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: BaseInteractable.cc:329
Data class to send a particle velocity over MPI.
Definition: MpiDataClass.h:103
Vec3D velocity
Definition: MpiDataClass.h:105
Vec3D angularVelocity
Definition: MpiDataClass.h:106

References MPIParticleVelocity::angularVelocity, BaseInteractable::getAngularVelocity(), BaseInteractable::getVelocity(), and MPIParticleVelocity::velocity.

Referenced by Domain::preparePositionAndVelocityUpdate(), PeriodicBoundaryHandler::preparePositionAndVelocityUpdate(), and Domain::prepareVelocityUpdate().

◆ getMPISum() [1/2]

double getMPISum ( double  val)

Sums the values over all processors using MPI_reduce

215 {
216 #ifdef MERCURYDPM_USE_MPI
217  //Sum up over all domains
218  double valGlobal = 0.0;
219  MPIContainer& communicator = MPIContainer::Instance();
220  communicator.allReduce(val, valGlobal, MPI_SUM);
221  return valGlobal;
222 #else
223  return val;
224 #endif
225 }
This class contains all information and functions required for communication between processors.
Definition: MpiContainer.h:130
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134

References MPIContainer::Instance().

◆ getMPISum() [2/2]

Vec3D getMPISum ( Vec3D val)

Sums the values over all processors using MPI_reduce

200 {
201 #ifdef MERCURYDPM_USE_MPI
202  //Sum up over all domains
203  Vec3D valGlobal = {0.0,0.0,0.0};
204  MPIContainer& communicator = MPIContainer::Instance();
205  communicator.allReduce(val.X, valGlobal.X, MPI_SUM);
206  communicator.allReduce(val.Y, valGlobal.Y, MPI_SUM);
207  communicator.allReduce(val.Z, valGlobal.Z, MPI_SUM);
208  return valGlobal;
209 #else
210  return val;
211 #endif
212 }
Definition: Vector.h:51
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66

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

Referenced by ParticleHandler::getAngularMomentum(), InteractionHandler::getLiquidBridgeVolume(), ParticleHandler::getLiquidFilmVolume(), ParticleHandler::getMomentum(), InteractionHandler::getNumberOfLiquidBridges(), and Membrane::saveVertexPositions().