MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Domain Class Referencefinal

The simulation can be subdivided into Domain's used in parallel code. More...

#include <Domain.h>

+ Inheritance diagram for Domain:

Public Member Functions

 Domain ()
 Default Domain constructor. More...
 
 Domain (std::vector< unsigned > globalMeshIndex)
 Constructs an empty domain with a globalMeshIndex. More...
 
 Domain (const Domain &d)
 Constructor that copies the domain range and rank from a given domain. More...
 
 ~Domain () override
 Destructor, destroys the domain. More...
 
void constructor ()
 contructor of a domain More...
 
virtual Domaincopy () const
 Function that creates a copy of this current domain, using the copy constructor. More...
 
void read (std::istream &is) override
 This function does nothing. More...
 
void write (std::ostream &os) const override
 This function does nothing. More...
 
std::string getName () const override
 Returns the name of the object. More...
 
void setRange (Direction direction, Mdouble min, Mdouble max)
 Sets the domain range in a given direction. More...
 
void setBounds (std::vector< double > domainLeft, std::vector< double > domainRight, bool computeMiddle)
 Sets the domain bounds. More...
 
std::vector< double > getDomainMin ()
 Gets the minimum domain bounds. More...
 
std::vector< double > getDomainMax ()
 Gets the maximum domain bounds. More...
 
int getRank ()
 Gets the rank associated with the assigned processorID. More...
 
void setRank (int rank)
 Sets the rank associated with the assigned processorID. More...
 
void setHandler (DomainHandler *handler)
 Sets the domainHandler. More...
 
DomainHandlergetHandler () const
 Gets the domainHandler. More...
 
int getGlobalIndex ()
 Gets the global index of the domain. More...
 
std::vector< unsignedgetGlobalMeshIndex ()
 Gets the global mesh index of the domain. More...
 
void setGlobalMeshIndex (std::vector< unsigned > globalMeshIndex)
 Sets the global mesh index of theh domain. More...
 
void disableBoundary (unsigned localIndex)
 Disables a boundary of the domain with a neighbouring domain. More...
 
void disableBoundaries ()
 disables all domain boundaries that have no neighbour More...
 
std::vector< bool > getActiveBoundaryList ()
 Returns a list of boundaries that are active in mpi communication. More...
 
bool containsParticle (BaseParticle *particle, Mdouble offset=0.0)
 Check to see if a given particle is within the current domain. More...
 
bool isInGreaterDomain (BaseParticle *particle)
 Check to see if a given particle is in the current domain or in neighbouring communication zones. More...
 
bool isInInnerDomain (BaseParticle *particle)
 Check if the particle is in the current domain but not in the communication zone. More...
 
bool isInCommunicationZone (BaseParticle *particle)
 Check if the particle is in the communication zone of the current domain. More...
 
void createLookUpTable ()
 Create a look up table between local index system to global index system. More...
 
int getLocalIndex (int i, int j, int k)
 return the local index of a domain given local mesh indices i,j and k More...
 
int getLocalIndex (std::vector< int > localMeshIndex)
 return the local index of a doman given the localMeshIndex vector More...
 
BaseParticlefindParticleInList (unsigned int identification, std::vector< BaseParticle * > particleList)
 Searches for a particle with a specific id in a list of particles. More...
 
std::vector< int > findNearbyBoundaries (BaseParticle *particle, Mdouble offset=0)
 This function finds if a given particle is close to a given boundary. More...
 
void addParticlesToLists (BaseParticle *particle, std::vector< std::vector< BaseParticle * > > &list)
 Function that adds the particles to the approriate boundary list. More...
 
void findNewMPIParticles (const ParticleHandler &particleHandler)
 Function that finds new particles in the particle handler that should be added to the communication lists. More...
 
void findNewMPIParticle (BaseParticle *particle)
 Function that check if a given particle should be added to the communication lists. More...
 
bool isInNewBoundaryParticleList (BaseParticle *object, int localIndex) const
 
void findNewMPIInteractions ()
 Finds interactions that have to be send over to another domain. More...
 
void collectBoundaryParticleData (int localIndex)
 collects the data of a particle that has to be communicated to other processors More...
 
void collectInteractionData (int localIndex)
 Collects the data of an interaction that has to be communicated to other processors. More...
 
void processReceivedBoundaryParticleData (unsigned index, std::vector< BaseParticle * > &newParticles)
 Function that copies the mpi data format of a base particle to a real particle and adds it to the particleHandler. More...
 
void processSentBoundaryParticles (unsigned index)
 Bookkeep the newly send particles. More...
 
void processReceivedInteractionData (unsigned index, std::vector< BaseParticle * > &newParticles)
 Processes the received interactions from newly added mpi particles. More...
 
void debugInformation ()
 
void sendAndReceiveCount (MercuryMPITag tag, unsigned &countReceive, unsigned &countSend, unsigned localIndexNeighbour)
 A symmetric communication between two domains exchanging a send/recieve count. More...
 
void prepareBoundaryDataTransmission ()
 Prepares the MPI transmission of particle and interaction data from particles in particleHandler. More...
 
void prepareBoundaryDataTransmission (BaseParticle *particle)
 Prepares the MPI transmission of a single particle and its interactions. More...
 
void performBoundaryDataTransmission ()
 Collects data to be transmitted and then performs the transmission of the data. More...
 
void finaliseBoundaryDataTransmission ()
 This function processes the transmitted data. More...
 
void updateParticles (std::set< BaseParticle * > &ghostParticlesToBeDeleted)
 This step updates all communication lists and particles in the communication zone. More...
 
void updateParticlePosition (int localIndex)
 Updates the position of particles which are flagged as MPIParticles. More...
 
void updateParticleVelocity (int localIndex)
 Updates the velocity of particles which are flagged as MPIParticles. More...
 
void preparePositionAndVelocityUpdate ()
 Function that sends particle position and velocity data for ghost particles to other processors. More...
 
void finalisePositionAndVelocityUpdate (std::set< BaseParticle * > &ghostParticlesToBeDeleted)
 processes position and velocity data for ghost particles More...
 
void prepareVelocityUpdate ()
 Function that sends particle velocity data for ghost particles. More...
 
void finaliseVelocityUpdate ()
 Processes particle velocity data for ghost particles. More...
 
template<typename T >
void sendAndReceiveMPIData (MercuryMPITag tag, MercuryMPIType type, T *receiveData, unsigned receiveCount, T *sendData, unsigned sendCount, unsigned localIndexNeighbour)
 Function that sends transmissionData/positionData/velocityData to other processors. More...
 
void addNewParticles ()
 Initialises the MPIParticles by communicating newly found particles. More...
 
void addParticle (BaseParticle *particle)
 Initialises a single particle which is added during the simulation. More...
 
void updateStatus (std::set< BaseParticle * > &ghostParticlesToBeDeleted)
 Updates particles that are not in the current domain and communicates newly added particles. More...
 
void updateVelocity ()
 Updates MPI particle velocity at the half-time step. More...
 
unsigned int getNumberOfMPIParticles ()
 Obtains the number of particles in the particleHandler that are MPIParticles. More...
 
unsigned int getNumberOfTrueMPIParticles ()
 Obtains the number of particles in the particleHandler that are MPIParticles, but NOT periodic particles. More...
 
void flushParticles (std::set< BaseParticle * > &toBeDeletedList)
 Particles that are going to be deleted from the simulation are flushed out of the communication boundaries. More...
 
void flushParticlesFromList (std::vector< BaseParticle * > &list, std::set< BaseParticle * > &toBeDeletedList)
 Particles that are going to be deleted from the simulation are flushed out of a give communcation boundary. More...
 
Vec3D getMiddle () const
 Gives the middle of the domain. More...
 
void cleanCommunicationLists ()
 Removes nullptrs from boundaryParticleList_ and boundaryParticleListNeighbour_. More...
 
void cleanCommunicationList (std::vector< BaseParticle * > &list)
 Removes nullptr's from a given particle list. More...
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

Private Attributes

DomainHandlerdomainHandler_
 Pointer to the domain's DomainHandler container. More...
 
std::vector< double > domainMin_
 Minimum domain bounds in the x,y and z direction. More...
 
std::vector< double > domainMax_
 Maximum domain bounds in the x,y and z direction. More...
 
Vec3D middle_
 Middle of the closed domain. More...
 
int globalIndex_
 Global index of the domain in the mesh. More...
 
std::vector< unsignedglobalMeshIndex_
 Vector containing the global mesh indices i,j,k. More...
 
std::vector< int > localIndexToGlobalIndexTable_
 look-up table to get the global index given a local domain index More...
 
std::vector< int > localIndexToProcessorList_
 look-up table to get the processor of the domain given a local domain index More...
 
std::vector< bool > activeBoundaryList_
 A list of flags corresponding to an inactive or active boundary. More...
 
std::vector< int > boundaryList_
 A list of indices of all the active boundaries. More...
 
std::vector< std::vector
< BaseParticle * > > 
boundaryParticleList_
 A list of boundary particles in the communication zone that are ghost particles on other domains. More...
 
std::vector< std::vector
< BaseParticle * > > 
boundaryParticleListNeighbour_
 a list of ghost particles on the current domain, which are real on the neighbour domain More...
 
std::vector< std::vector
< BaseParticle * > > 
newBoundaryParticleList_
 Array that queues particles that need to be transmitted. More...
 
std::vector< std::vector
< BaseInteraction * > > 
newInteractionList_
 Array that queues interactions that need to be transmitted. More...
 
std::vector< unsignednumberOfParticlesSend_
 Counter that keeps track of the number of particles that are being send to other domains. More...
 
std::vector< unsignednumberOfParticlesReceive_
 Counter that keeps track of the number of particles that are being received by this domain. More...
 
std::vector< unsignednumNewInteractionsSend_
 Counter that keeps track of the number of interactions that are being send to other domains. More...
 
std::vector< unsignednumNewInteractionsReceive_
 Counter that keeps track of the number of interactions that are being received by this domain. More...
 
std::vector< std::vector
< MPIParticle > > 
boundaryParticleDataSend_
 Container that keeps a list of MPIParticles that are being send to other domains. More...
 
std::vector< std::vector
< MPIParticle > > 
boundaryParticleDataReceive_
 Container that keeps a list of MPIParticles that are being received by this domain. More...
 
std::vector< std::vector
< MPIParticlePosition > > 
updatePositionDataSend_
 Container that keeps a list of MPIParticlePositions that are being send to other domains. More...
 
std::vector< std::vector
< MPIParticlePosition > > 
updatePositionDataReceive_
 Container that keeps a list of MPIParticlePositions that are being received by this domain. More...
 
std::vector< std::vector
< MPIParticleVelocity > > 
updateVelocityDataSend_
 Container that keeps a list of MPIParticleVelocities that are being send to other domains. More...
 
std::vector< std::vector
< MPIParticleVelocity > > 
updateVelocityDataReceive_
 Container that keeps a list of MPIParticleVelocities that are being received by this domain. More...
 
std::vector< void * > interactionDataSend_
 Container that keeps a void array of all the interaction data that are being send to other domains, interpretation is done by the interaction handler. More...
 
std::vector< void * > interactionDataReceive_
 Container that keeps a void array of all the interaction data that is being received by this domain, interpretation is done by the interaction handler. More...
 
int rank_
 Rank of the domain which identifies to which processor it belongs. More...
 

Detailed Description

The simulation can be subdivided into Domain's used in parallel code.

The domain class defines a region in the simulation domain, given by a min vector and a max vector. The domain also as a processorID assigned to it. It has a check to see whether a given particle is in the domain or not.

Definition at line 63 of file Domain.h.

Constructor & Destructor Documentation

Domain::Domain ( )

Default Domain constructor.

Constructs an empty domain.

Constructor of the domain class. It creates a domain with infinite bounds and no processor or domainHandler assigned to it and initialises all communication lists

Definition at line 48 of file Domain.cc.

References constructor().

Referenced by copy().

49 {
50  constructor();
51 #ifdef DEBUG_CONSTRUCTOR
52  std::cout<<"Domain::Domain() finished"<<std::endl;
53 #endif
54 }
void constructor()
contructor of a domain
Definition: Domain.cc:133
Domain::Domain ( std::vector< unsigned globalMeshIndex)
explicit

Constructs an empty domain with a globalMeshIndex.

Constructor of the domain class. It creates a domain with infinite bounds and no processor or domainHandler assigned to it and initialises all communication lists

Definition at line 62 of file Domain.cc.

References constructor().

62  : globalMeshIndex_(std::move(globalMeshIndex))
63 {
64  constructor();
65 #ifdef DEBUG_CONSTRUCTOR
66  std::cout<<"Domain::Domain() finished"<<std::endl;
67 #endif
68 }
void constructor()
contructor of a domain
Definition: Domain.cc:133
std::vector< unsigned > globalMeshIndex_
Vector containing the global mesh indices i,j,k.
Definition: Domain.h:464
Domain::Domain ( const Domain b)

Constructor that copies the domain range and rank from a given domain.

Copies a domain.

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

This constructor copies all the private variables of the current domain into the input domain.

Definition at line 76 of file Domain.cc.

References activeBoundaryList_, boundaryList_, boundaryParticleDataReceive_, boundaryParticleDataSend_, boundaryParticleList_, boundaryParticleListNeighbour_, domainHandler_, domainMax_, domainMin_, globalMeshIndex_, interactionDataReceive_, interactionDataSend_, localIndexToGlobalIndexTable_, localIndexToProcessorList_, middle_, newBoundaryParticleList_, newInteractionList_, numberOfParticlesReceive_, numberOfParticlesSend_, numNewInteractionsReceive_, numNewInteractionsSend_, rank_, updatePositionDataReceive_, updatePositionDataSend_, updateVelocityDataReceive_, and updateVelocityDataSend_.

77  : BaseObject(b)
78 {
79  rank_ = b.rank_;
84  middle_ = b.middle_;
85 
86  //A cube has 3^3=27 neighbours
87  unsigned long numberOfNeighbours = 27;
88 
89  //Create all lists
90  localIndexToGlobalIndexTable_ = std::vector<int>(numberOfNeighbours);
91  localIndexToProcessorList_ = std::vector<int>(numberOfNeighbours);
92  boundaryParticleList_ = std::vector<std::vector<BaseParticle*> >(numberOfNeighbours, std::vector<BaseParticle*>(0));
93  boundaryParticleListNeighbour_ = std::vector<std::vector<BaseParticle*> >(numberOfNeighbours,
94  std::vector<BaseParticle*>(0));
95  newBoundaryParticleList_ = std::vector<std::vector<BaseParticle*> >(numberOfNeighbours,
96  std::vector<BaseParticle*>(0));
97  newInteractionList_ = std::vector<std::vector<BaseInteraction*> >(numberOfNeighbours,
98  std::vector<BaseInteraction*>(0));
99  numberOfParticlesSend_ = std::vector<unsigned>(numberOfNeighbours);
100  numberOfParticlesReceive_ = std::vector<unsigned>(numberOfNeighbours);
101  numNewInteractionsSend_ = std::vector<unsigned>(numberOfNeighbours);
102  numNewInteractionsReceive_ = std::vector<unsigned>(numberOfNeighbours);
103  boundaryParticleDataSend_ = std::vector<std::vector<MPIParticle> >(numberOfNeighbours);
104  boundaryParticleDataReceive_ = std::vector<std::vector<MPIParticle> >(numberOfNeighbours);
105  updatePositionDataSend_ = std::vector<std::vector<MPIParticlePosition> >(numberOfNeighbours);
106  updatePositionDataReceive_ = std::vector<std::vector<MPIParticlePosition> >(numberOfNeighbours);
107  updateVelocityDataSend_ = std::vector<std::vector<MPIParticleVelocity> >(numberOfNeighbours);
108  updateVelocityDataReceive_ = std::vector<std::vector<MPIParticleVelocity> >(numberOfNeighbours);
109  interactionDataSend_ = std::vector<void*>(numberOfNeighbours);
110  interactionDataReceive_ = std::vector<void*>(numberOfNeighbours);
111  activeBoundaryList_ = std::vector<bool>(numberOfNeighbours, true);
112  boundaryList_ = std::vector<int>(0);
113 #ifdef DEBUG_CONSTRUCTOR
114  std::cout<<"Domain::Domain(const Domain &b) finished"<<std::endl;
115 #endif
116 }
std::vector< void * > interactionDataSend_
Container that keeps a void array of all the interaction data that are being send to other domains...
Definition: Domain.h:562
std::vector< unsigned > numberOfParticlesReceive_
Counter that keeps track of the number of particles that are being received by this domain...
Definition: Domain.h:517
std::vector< bool > activeBoundaryList_
A list of flags corresponding to an inactive or active boundary.
Definition: Domain.h:481
std::vector< unsigned > numNewInteractionsSend_
Counter that keeps track of the number of interactions that are being send to other domains...
Definition: Domain.h:522
Vec3D middle_
Middle of the closed domain.
Definition: Domain.h:453
std::vector< double > domainMin_
Minimum domain bounds in the x,y and z direction.
Definition: Domain.h:443
std::vector< int > localIndexToGlobalIndexTable_
look-up table to get the global index given a local domain index
Definition: Domain.h:470
BaseObject()=default
Default constructor.
std::vector< int > localIndexToProcessorList_
look-up table to get the processor of the domain given a local domain index
Definition: Domain.h:476
std::vector< std::vector< BaseInteraction * > > newInteractionList_
Array that queues interactions that need to be transmitted.
Definition: Domain.h:507
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataReceive_
Container that keeps a list of MPIParticleVelocities that are being received by this domain...
Definition: Domain.h:557
std::vector< unsigned > globalMeshIndex_
Vector containing the global mesh indices i,j,k.
Definition: Domain.h:464
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< void * > interactionDataReceive_
Container that keeps a void array of all the interaction data that is being received by this domain...
Definition: Domain.h:567
std::vector< std::vector< MPIParticlePosition > > updatePositionDataSend_
Container that keeps a list of MPIParticlePositions that are being send to other domains.
Definition: Domain.h:542
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataSend_
Container that keeps a list of MPIParticleVelocities that are being send to other domains...
Definition: Domain.h:552
std::vector< unsigned > numberOfParticlesSend_
Counter that keeps track of the number of particles that are being send to other domains.
Definition: Domain.h:512
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
std::vector< std::vector< MPIParticlePosition > > updatePositionDataReceive_
Container that keeps a list of MPIParticlePositions that are being received by this domain...
Definition: Domain.h:547
int rank_
Rank of the domain which identifies to which processor it belongs.
Definition: Domain.h:572
std::vector< double > domainMax_
Maximum domain bounds in the x,y and z direction.
Definition: Domain.h:448
std::vector< std::vector< MPIParticle > > boundaryParticleDataReceive_
Container that keeps a list of MPIParticles that are being received by this domain.
Definition: Domain.h:537
std::vector< std::vector< BaseParticle * > > boundaryParticleList_
A list of boundary particles in the communication zone that are ghost particles on other domains...
Definition: Domain.h:492
std::vector< unsigned > numNewInteractionsReceive_
Counter that keeps track of the number of interactions that are being received by this domain...
Definition: Domain.h:527
std::vector< std::vector< MPIParticle > > boundaryParticleDataSend_
Container that keeps a list of MPIParticles that are being send to other domains. ...
Definition: Domain.h:532
Domain::~Domain ( )
override

Destructor, destroys the domain.

Destructor

Definition at line 121 of file Domain.cc.

122 {
123 #ifdef DEBUG_DESTRUCTOR
124  std::cout << "Domain::~Domain() finished"<<std::endl;
125 #endif
126 }

Member Function Documentation

void Domain::addNewParticles ( )

Initialises the MPIParticles by communicating newly found particles.

Adds new MPI ghost particles to the simulation. This is done in a three stage process where first the particles are located that generate ghosts, secondly their data is transmitted to the correct processor and thirdly that data is then used to create ghost particles.

Definition at line 1559 of file Domain.cc.

References finaliseBoundaryDataTransmission(), MPIContainer::Instance(), performBoundaryDataTransmission(), prepareBoundaryDataTransmission(), and MPIContainer::sync().

Referenced by DomainHandler::addNewParticles().

1560 {
1561  //Step 1: For every MPIDomain boundary, create a list of particles that have to be transmitted
1562  //queue send and receive instructions for the number of particles
1565 
1566  //Step 2: queue send and receive of data
1569 
1570  //Step 3: Add the received particles to the particleHandler of the current domain
1572 }
void prepareBoundaryDataTransmission()
Prepares the MPI transmission of particle and interaction data from particles in particleHandler.
Definition: Domain.cc:1117
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
void performBoundaryDataTransmission()
Collects data to be transmitted and then performs the transmission of the data.
Definition: Domain.cc:1192
void finaliseBoundaryDataTransmission()
This function processes the transmitted data.
Definition: Domain.cc:1233
void sync()
Process all pending asynchronous communication requests before continuing.
Definition: MpiContainer.h:148
void Domain::addParticle ( BaseParticle particle)

Initialises a single particle which is added during the simulation.

Initialises a single particle which was added by the user after the domain creation.

This function is used when a single particle is added during the simulation In that case it has to be added to the mpi domains manually using this function. Examples are insertion boundaries that occasionally add particles to the domain

Parameters
[in]particleThe single particle that has to be inserted into the domain

Definition at line 1581 of file Domain.cc.

References finaliseBoundaryDataTransmission(), MPIContainer::Instance(), performBoundaryDataTransmission(), prepareBoundaryDataTransmission(), and MPIContainer::sync().

Referenced by DPMBase::insertGhostParticle().

1582 {
1583  //Step1: check if the particle has to be sent to other processors
1586 
1587  //Step2: queue send and receive data. Note for an inserted particle, no interactions should be required
1590 
1591  //Step3: Add the received particles to the particleHandler of the current domain
1594 }
void prepareBoundaryDataTransmission()
Prepares the MPI transmission of particle and interaction data from particles in particleHandler.
Definition: Domain.cc:1117
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
void performBoundaryDataTransmission()
Collects data to be transmitted and then performs the transmission of the data.
Definition: Domain.cc:1192
void finaliseBoundaryDataTransmission()
This function processes the transmitted data.
Definition: Domain.cc:1233
void sync()
Process all pending asynchronous communication requests before continuing.
Definition: MpiContainer.h:148
void Domain::addParticlesToLists ( BaseParticle particle,
std::vector< std::vector< BaseParticle * > > &  list 
)

Function that adds the particles to the approriate boundary list.

Function that adds the particles to the approriate boundary lists.

This function computes the complexity of the particle. The complexity is defined by the number of boundaries the particle is close-by. Depending on this complexity value the particle has to be added to different boundary lists.

Parameters
[in]particlepointer to base particle
[in,out]lista list of lists of particles which the particle might be added to

Definition at line 683 of file Domain.cc.

References ERROR, findNearbyBoundaries(), getLocalIndex(), INFO, logger, and BaseParticle::setCommunicationComplexity().

Referenced by findNewMPIParticle().

684 {
685  std::vector<int> boundaryIndex = findNearbyBoundaries(particle);
686 
687  //Compute and set complexity of the particle
688  unsigned int complexity = boundaryIndex[0] + 3 * boundaryIndex[1] + 9 * boundaryIndex[2] + 13;
689  unsigned int list_complexity = 0;
690  for (int d = 0; d < 3; d++) //Loop over all directions
691  {
692  list_complexity += std::abs(boundaryIndex[d]);
693  }
694  particle->setCommunicationComplexity(complexity);
695  //particle->setCommunicationComplexity(list_complexity);
696 
697  //Based on the complexity of the particle, add it to the approriate list
698  switch (list_complexity)
699  {
700  //The particle is not close at all
701  case 0:
702  break;
703  //The particle is close to one side
704  // 1 side contribution
705  case 1 :
706  //Add the side contribution
707  list[getLocalIndex(boundaryIndex)].push_back(particle);
708  break;
709  //The particle is close to two neighbouring directions
710  //2 side and 1 rib contrubution
711  case 2 :
712  {
713  //Add the two side contributions
714  for (int d = 0; d < 3; d++)
715  {
716  std::vector<int> localMeshIndex = {0, 0, 0};
717  localMeshIndex[d] = boundaryIndex[d];
718  //Avoid adding the particle in the wrong direction by excluding localMeshIndex[d] = 0
719  if (localMeshIndex[d] != 0)
720  {
721  list[getLocalIndex(localMeshIndex)].push_back(particle);
722  }
723  }
724  }
725  //Add the rib contribution
726  list[getLocalIndex(boundaryIndex)].push_back(particle);
727  break;
728 
729  //The particle is close to three neighbouring directions
730  // 3 side, 3 rib and 1 corner contribution
731  case 3 :
732  {
733  //Add the three side contributions
734  for (int d = 0; d < 3; d++)
735  {
736  std::vector<int> localMeshIndex = {0, 0, 0};
737  //Reset index vector
738  localMeshIndex[d] = boundaryIndex[d];
739  list[getLocalIndex(localMeshIndex)].push_back(particle);
740  }
741 
742  //Add the three rib contributions
743  for (int d = 0; d < 3; d++)
744  {
745  std::vector<int> localMeshIndex = boundaryIndex;
746  //All rib boundary indices are given by the boundaryIndex and setting one of the components to zero
747  localMeshIndex[d] = 0;
748  list[getLocalIndex(localMeshIndex)].push_back(particle);
749  }
750  }
751 
752  //Add the corner contribution
753  list[getLocalIndex(boundaryIndex)].push_back(particle);
754  break;
755 
756  default :
757  logger(INFO, "boundaryIndex : %,%,% | list_complexity: %", boundaryIndex[0], boundaryIndex[1], boundaryIndex[2],
758  list_complexity);
759  logger(ERROR, "Particle is in contact with the wrong number of boundaries");
760  break;
761  }
762 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::vector< int > findNearbyBoundaries(BaseParticle *particle, Mdouble offset=0)
This function finds if a given particle is close to a given boundary.
Definition: Domain.cc:549
void setCommunicationComplexity(unsigned complexity)
Set the communication complexity of the particle.
int getLocalIndex(int i, int j, int k)
return the local index of a domain given local mesh indices i,j and k
Definition: Domain.cc:498
void Domain::cleanCommunicationList ( std::vector< BaseParticle * > &  list)

Removes nullptr's from a given particle list.

Removes nullptrs from a list of base particles efficiently by replacing the last entry to an empty nullptr space.m

Parameters
[in]listThe list that needs to be cleansed from nullptrs

Definition at line 1728 of file Domain.cc.

References constants::i.

Referenced by cleanCommunicationLists().

1729 {
1730  for (int i = 0; i < list.size(); i++)
1731  {
1732  if (list[i] == nullptr)
1733  {
1734  list[i] = list.back();
1735  list.pop_back();
1736  i--;
1737  }
1738  }
1739 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
void Domain::cleanCommunicationLists ( )

Removes nullptrs from boundaryParticleList_ and boundaryParticleListNeighbour_.

After particles have been updated, the communication lists contains nullptrs, remove these from the boundaryParticleList and boundaryParticleListNeighbour

Definition at line 1713 of file Domain.cc.

References boundaryList_, boundaryParticleList_, boundaryParticleListNeighbour_, cleanCommunicationList(), and constants::i.

Referenced by DPMBase::checkInteractionWithBoundaries(), PeriodicBoundaryHandler::clearCommunicationLists(), and DPMBase::deleteGhostParticles().

1714 {
1715  //For all active boundaries
1716  for (int i : boundaryList_)
1717  {
1720  }
1721 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
void cleanCommunicationList(std::vector< BaseParticle * > &list)
Removes nullptr's from a given particle list.
Definition: Domain.cc:1728
std::vector< std::vector< BaseParticle * > > boundaryParticleList_
A list of boundary particles in the communication zone that are ghost particles on other domains...
Definition: Domain.h:492
void Domain::collectBoundaryParticleData ( int  localIndex)

collects the data of a particle that has to be communicated to other processors

collects the data of a particles that has to be communicated to other processors

Only the relevant data of a baseParticle is being send to other processors, therefore this function collects the relevant data and puts it in a format compatible with data transmission

Parameters
[in]localIndexthe local index of a boundary

Definition at line 886 of file Domain.cc.

References boundaryParticleDataSend_, copyDataFromParticleToMPIParticle(), and newBoundaryParticleList_.

Referenced by performBoundaryDataTransmission().

887 {
888  //For all particles
889  for (BaseParticle* particle : newBoundaryParticleList_[localIndex])
890  {
891  //Add the data to the transmission list
892  boundaryParticleDataSend_[localIndex].push_back(copyDataFromParticleToMPIParticle(particle));
893  }
894 }
MPIParticle copyDataFromParticleToMPIParticle(BaseParticle *p)
Copies data from a SuperQuadricParticle to an MPIParticle class and returns this. ...
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
std::vector< std::vector< MPIParticle > > boundaryParticleDataSend_
Container that keeps a list of MPIParticles that are being send to other domains. ...
Definition: Domain.h:532
void Domain::collectInteractionData ( int  localIndex)

Collects the data of an interaction that has to be communicated to other processors.

Interactions have to be reformatted in an MPI-suitable format to transmit over to other processors

Parameters
[in]localIndexThe local index of a boundary

Definition at line 901 of file Domain.cc.

References interactionDataSend_, and newInteractionList_.

Referenced by performBoundaryDataTransmission().

902 {
903  //Copy interactions to the data array
904  unsigned int indexInteraction = 0;
905  for (BaseInteraction* interaction : newInteractionList_[localIndex])
906  {
907  interaction->getMPIInteraction(interactionDataSend_[localIndex], indexInteraction);
908  indexInteraction++;
909  }
910 }
std::vector< void * > interactionDataSend_
Container that keeps a void array of all the interaction data that are being send to other domains...
Definition: Domain.h:562
std::vector< std::vector< BaseInteraction * > > newInteractionList_
Array that queues interactions that need to be transmitted.
Definition: Domain.h:507
Stores information about interactions between two interactable objects; often particles but could be ...
void Domain::constructor ( )

contructor of a domain

constructs the domain

the boundaries are set to infinity, no processor is assigned. all lists that require a full 3D domain element to function are created

Definition at line 133 of file Domain.cc.

References activeBoundaryList_, boundaryList_, boundaryParticleDataReceive_, boundaryParticleDataSend_, boundaryParticleList_, boundaryParticleListNeighbour_, domainHandler_, domainMax_, domainMin_, constants::inf, interactionDataReceive_, interactionDataSend_, constants::intMax, localIndexToGlobalIndexTable_, localIndexToProcessorList_, newBoundaryParticleList_, newInteractionList_, numberOfParticlesReceive_, numberOfParticlesSend_, numNewInteractionsReceive_, numNewInteractionsSend_, rank_, updatePositionDataReceive_, updatePositionDataSend_, updateVelocityDataReceive_, and updateVelocityDataSend_.

Referenced by Domain().

134 {
136  domainHandler_ = nullptr;
137  domainMin_ = {-constants::inf, -constants::inf, -constants::inf};
138  domainMax_ = {constants::inf, constants::inf, constants::inf};
139 
140  //A cube has 3^3=27 neighbours
141  int numberOfNeighbours = 27;
142 
143  //Create all lists
144  localIndexToGlobalIndexTable_ = std::vector<int>(numberOfNeighbours);
145  localIndexToProcessorList_ = std::vector<int>(numberOfNeighbours);
146  boundaryParticleList_ = std::vector<std::vector<BaseParticle*> >(numberOfNeighbours, std::vector<BaseParticle*>(0));
147  boundaryParticleListNeighbour_ = std::vector<std::vector<BaseParticle*> >(numberOfNeighbours,
148  std::vector<BaseParticle*>(0));
149  newBoundaryParticleList_ = std::vector<std::vector<BaseParticle*> >(numberOfNeighbours,
150  std::vector<BaseParticle*>(0));
151  newInteractionList_ = std::vector<std::vector<BaseInteraction*> >(numberOfNeighbours,
152  std::vector<BaseInteraction*>(0));
153  numberOfParticlesSend_ = std::vector<unsigned>(numberOfNeighbours);
154  numberOfParticlesReceive_ = std::vector<unsigned>(numberOfNeighbours);
155  numNewInteractionsSend_ = std::vector<unsigned>(numberOfNeighbours);
156  numNewInteractionsReceive_ = std::vector<unsigned>(numberOfNeighbours);
157  boundaryParticleDataSend_ = std::vector<std::vector<MPIParticle> >(numberOfNeighbours);
158  boundaryParticleDataReceive_ = std::vector<std::vector<MPIParticle> >(numberOfNeighbours);
159  updatePositionDataSend_ = std::vector<std::vector<MPIParticlePosition> >(numberOfNeighbours);
160  updatePositionDataReceive_ = std::vector<std::vector<MPIParticlePosition> >(numberOfNeighbours);
161  updateVelocityDataSend_ = std::vector<std::vector<MPIParticleVelocity> >(numberOfNeighbours);
162  updateVelocityDataReceive_ = std::vector<std::vector<MPIParticleVelocity> >(numberOfNeighbours);
163  interactionDataSend_ = std::vector<void*>(numberOfNeighbours);
164  interactionDataReceive_ = std::vector<void*>(numberOfNeighbours);
165  activeBoundaryList_ = std::vector<bool>(numberOfNeighbours, true);
166  boundaryList_ = std::vector<int>(0);
167 }
std::vector< void * > interactionDataSend_
Container that keeps a void array of all the interaction data that are being send to other domains...
Definition: Domain.h:562
std::vector< unsigned > numberOfParticlesReceive_
Counter that keeps track of the number of particles that are being received by this domain...
Definition: Domain.h:517
std::vector< bool > activeBoundaryList_
A list of flags corresponding to an inactive or active boundary.
Definition: Domain.h:481
std::vector< unsigned > numNewInteractionsSend_
Counter that keeps track of the number of interactions that are being send to other domains...
Definition: Domain.h:522
std::vector< double > domainMin_
Minimum domain bounds in the x,y and z direction.
Definition: Domain.h:443
std::vector< int > localIndexToGlobalIndexTable_
look-up table to get the global index given a local domain index
Definition: Domain.h:470
std::vector< int > localIndexToProcessorList_
look-up table to get the processor of the domain given a local domain index
Definition: Domain.h:476
std::vector< std::vector< BaseInteraction * > > newInteractionList_
Array that queues interactions that need to be transmitted.
Definition: Domain.h:507
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataReceive_
Container that keeps a list of MPIParticleVelocities that are being received by this domain...
Definition: Domain.h:557
const Mdouble inf
Definition: GeneralDefine.h:44
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< void * > interactionDataReceive_
Container that keeps a void array of all the interaction data that is being received by this domain...
Definition: Domain.h:567
std::vector< std::vector< MPIParticlePosition > > updatePositionDataSend_
Container that keeps a list of MPIParticlePositions that are being send to other domains.
Definition: Domain.h:542
const int intMax
Definition: GeneralDefine.h:45
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataSend_
Container that keeps a list of MPIParticleVelocities that are being send to other domains...
Definition: Domain.h:552
std::vector< unsigned > numberOfParticlesSend_
Counter that keeps track of the number of particles that are being send to other domains.
Definition: Domain.h:512
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
std::vector< std::vector< MPIParticlePosition > > updatePositionDataReceive_
Container that keeps a list of MPIParticlePositions that are being received by this domain...
Definition: Domain.h:547
int rank_
Rank of the domain which identifies to which processor it belongs.
Definition: Domain.h:572
std::vector< double > domainMax_
Maximum domain bounds in the x,y and z direction.
Definition: Domain.h:448
std::vector< std::vector< MPIParticle > > boundaryParticleDataReceive_
Container that keeps a list of MPIParticles that are being received by this domain.
Definition: Domain.h:537
std::vector< std::vector< BaseParticle * > > boundaryParticleList_
A list of boundary particles in the communication zone that are ghost particles on other domains...
Definition: Domain.h:492
std::vector< unsigned > numNewInteractionsReceive_
Counter that keeps track of the number of interactions that are being received by this domain...
Definition: Domain.h:527
std::vector< std::vector< MPIParticle > > boundaryParticleDataSend_
Container that keeps a list of MPIParticles that are being send to other domains. ...
Definition: Domain.h:532
bool Domain::containsParticle ( BaseParticle particle,
Mdouble  offset = 0.0 
)

Check to see if a given particle is within the current domain.

Checks if a particle is in the domain.

Checks if the particle is in the domain, but with an offset. this offset is set to zero standard

Parameters
[in]particlePointer to a particle
[in]offsetoffset from the domain boundary
Returns
True if the particle is in the domain. False if it is outside

Definition at line 400 of file Domain.cc.

References domainMax_, domainMin_, Vec3D::getComponent(), BaseInteractable::getPosition(), and constants::i.

Referenced by PeriodicBoundaryHandler::getMPIFlags(), isInCommunicationZone(), isInGreaterDomain(), isInInnerDomain(), DPMBase::mpiInsertParticleCheck(), prepareBoundaryDataTransmission(), and updateParticles().

401 {
402  for (unsigned i = 0; i < 3; i++)
403  {
404  if (!(((domainMin_[i] + offset) < particle->getPosition().getComponent(i))
405  &&
406  ((domainMax_[i] - offset) >= particle->getPosition().getComponent(i)))
407  )
408  {
409  return false;
410  }
411  }
412  return true;
413 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
std::vector< double > domainMin_
Minimum domain bounds in the x,y and z direction.
Definition: Domain.h:443
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Definition: Vector.cc:194
std::vector< double > domainMax_
Maximum domain bounds in the x,y and z direction.
Definition: Domain.h:448
Domain * Domain::copy ( ) const
virtual

Function that creates a copy of this current domain, using the copy constructor.

Copy method.

Uses copy constructor to create a copy on the heap. Useful for polymorphism.

Returns
pointer to the domain's copy

Definition at line 175 of file Domain.cc.

References Domain().

176 {
177  return new Domain(*this);
178 }
Domain()
Default Domain constructor.
Definition: Domain.cc:48
void Domain::createLookUpTable ( )

Create a look up table between local index system to global index system.

Function that creates a lookup table from the local index system to the global index system

Definition at line 451 of file Domain.cc.

References domainHandler_, DomainHandler::getNumberOfDomains(), globalIndex_, globalMeshIndex_, constants::i, localIndexToGlobalIndexTable_, localIndexToProcessorList_, rank_, XAXIS, YAXIS, and ZAXIS.

452 {
453  int localIndex;
454  int globalIndex;
455  //Get the global decomposition vector, (nx,ny,nz) and compute the mesh multipliers: (1,nx,nx*ny)
456  std::vector<unsigned> numberOfDomains = domainHandler_->getNumberOfDomains();
457  std::vector<unsigned> globalMeshMultiplier = {1,
458  numberOfDomains[Direction::XAXIS],
459  numberOfDomains[Direction::XAXIS] *
460  numberOfDomains[Direction::YAXIS]};
461 
462  //Compute the globalIndex of this domain
464  globalMeshMultiplier[Direction::YAXIS] * globalMeshIndex_[Direction::YAXIS] +
465  globalMeshMultiplier[Direction::ZAXIS] * globalMeshIndex_[Direction::ZAXIS];
466 
467  //Create the lookup table from localIndex to globalIndex of the neihbours
468  for (int i = -1; i < 2; i++)
469  {
470  for (int j = -1; j < 2; j++)
471  {
472  for (int k = -1; k < 2; k++)
473  {
474  //Get the local index
475  localIndex = i + 3 * j + 9 * k + 13;
476  //Compute the global index
477  globalIndex = globalMeshMultiplier[Direction::XAXIS] * (globalMeshIndex_[Direction::XAXIS] + i) +
478  globalMeshMultiplier[Direction::YAXIS] * (globalMeshIndex_[Direction::YAXIS] + j) +
479  globalMeshMultiplier[Direction::ZAXIS] * (globalMeshIndex_[Direction::ZAXIS] + k);
480  //Fill in the look-up table
481  localIndexToGlobalIndexTable_[localIndex] = globalIndex;
482  }
483  }
484  }
485  //Create the lookup table from localIndex to processorRank
488 }
std::vector< int > localIndexToGlobalIndexTable_
look-up table to get the global index given a local domain index
Definition: Domain.h:470
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
std::vector< int > localIndexToProcessorList_
look-up table to get the processor of the domain given a local domain index
Definition: Domain.h:476
std::vector< unsigned > globalMeshIndex_
Vector containing the global mesh indices i,j,k.
Definition: Domain.h:464
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
int globalIndex_
Global index of the domain in the mesh.
Definition: Domain.h:459
std::vector< unsigned > getNumberOfDomains()
Gets the number of domains in the domain handler.
int rank_
Rank of the domain which identifies to which processor it belongs.
Definition: Domain.h:572
void Domain::debugInformation ( )

Definition at line 1067 of file Domain.cc.

References getHandler(), INFO, and logger.

1067  {
1068  std::stringstream s;
1069  std::stringstream m;
1070  for (auto p : getHandler()->getDPMBase()->particleHandler) {
1071  if (p->isMPIParticle())
1072  m << std::setw(4) << p->getId();
1073  else
1074  s << std::setw(4) << p->getId();
1075  }
1076  logger(INFO,"Particles %, MPI %",s.str(),m.str());
1077 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
DomainHandler * getHandler() const
Gets the domainHandler.
Definition: Domain.cc:1549
void Domain::disableBoundaries ( )

disables all domain boundaries that have no neighbour

This function can only disable a square mesh. If you want to make a concave mesh then this function has to be adapted, especially for the case when the numberOfDomains[d] = 1.

Definition at line 579 of file Domain.cc.

References activeBoundaryList_, boundaryList_, domainHandler_, getLocalIndex(), DomainHandler::getNumberOfDomains(), globalMeshIndex_, constants::i, XAXIS, YAXIS, and ZAXIS.

580 {
581  std::vector<unsigned> numberOfDomains = domainHandler_->getNumberOfDomains();
582  std::vector<int> localMeshIndex(3);
583  int localIndex;
584 
585  //disble own list
586  activeBoundaryList_[13] = false;
587 
588  //Special case when numberOfDomains[d] = 1 -> disable all d direction boundaries
589  for (unsigned d = 0; d < 3; d++) //Loop over all dimensions
590  {
591  //If there is only one domain in the d-direction, take action
592  if (numberOfDomains[d] == 1)
593  {
594  //Loop over all locaIndices
595  for (int i = -1; i < 2; i++)
596  {
597  localMeshIndex[Direction::XAXIS] = i;
598  for (int j = -1; j < 2; j++)
599  {
600  localMeshIndex[Direction::YAXIS] = j;
601  for (int k = -1; k < 2; k++)
602  {
603  localMeshIndex[Direction::ZAXIS] = k;
604  //Disable all boundaries that are not in the "middle" of the mesh in the d-direction
605  // i.e. a localMeshIndex[d] = -1 is a neighbour in the d-direction, however there is only one
606  // element in that direction so it can't be a real neighbour.
607  if (localMeshIndex[d] != 0)
608  {
609  //Disable the boundary
610  localIndex = getLocalIndex(localMeshIndex);
611  activeBoundaryList_[localIndex] = false;
612  }
613  }
614  }
615  }
616  }
617  }
618 
619  //Compute the boundaryIndex for all other cases where numberOfDomains is larger than 1
620  std::vector<int> boundaryIndex(3);
621  for (int d = 0; d < 3; d++)
622  {
623  //Check if the domain is on the simulationDomainMin boundary
624  if (globalMeshIndex_[d] == 0)
625  {
626  //Update boundary index
627  boundaryIndex[d] = -1;
628  }
629  //Check if the domain is on the simulationDomainMax boundary
630  else if (globalMeshIndex_[d] == (numberOfDomains[d] - 1))
631  {
632  //Update boundary index
633  boundaryIndex[d] = 1;
634  }
635  }
636 
637  //Disable the boundaries that are on the edge of the simulation domain
638  for (int d = 0; d < 3; d++)
639  {
640  //If boundary is on the edge of the simulation domain
641  if (boundaryIndex[d] != 0)
642  {
643  //Loop over all local indices
644  for (int i = -1; i < 2; i++)
645  {
646  for (int j = -1; j < 2; j++)
647  {
648  for (int k = -1; k < 2; k++)
649  {
650  localMeshIndex = {i, j, k};
651  //Set the localMeshIndex to the boundaryIndex in the d-direction
652  //Since we are only interested in the domains on this boundary
653  localMeshIndex[d] = boundaryIndex[d];
654  //Disable the boundary
655  localIndex = getLocalIndex(localMeshIndex);
656  activeBoundaryList_[localIndex] = false;
657  }
658  }
659  }
660  }
661  }
662 
663  //Create a list of the active boundaries
664  localIndex = 0;
665  for (bool active : activeBoundaryList_)
666  {
667  if (active)
668  {
669  boundaryList_.push_back(localIndex);
670  }
671  localIndex++;
672  }
673 }
std::vector< bool > activeBoundaryList_
A list of flags corresponding to an inactive or active boundary.
Definition: Domain.h:481
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
std::vector< unsigned > globalMeshIndex_
Vector containing the global mesh indices i,j,k.
Definition: Domain.h:464
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
std::vector< unsigned > getNumberOfDomains()
Gets the number of domains in the domain handler.
int getLocalIndex(int i, int j, int k)
return the local index of a domain given local mesh indices i,j and k
Definition: Domain.cc:498
void Domain::disableBoundary ( unsigned  localIndex)

Disables a boundary of the domain with a neighbouring domain.

This function disables the communication of a boundary. Each domain in the parallel code has 27 boundaries: (6 sides, 12 ribs, 8 corners) and for convenience one is associated with the domain itself (used for local indexing). Boundaries that are inactive, such as domains that extend to infinity, do not need to be considered in the parallel computation. This function disables that boundary.

Parameters
[in]localIndexThe local index of a neighbour of the current domain

Definition at line 378 of file Domain.cc.

References activeBoundaryList_.

379 {
380  activeBoundaryList_[localIndex] = false;
381 }
std::vector< bool > activeBoundaryList_
A list of flags corresponding to an inactive or active boundary.
Definition: Domain.h:481
void Domain::finaliseBoundaryDataTransmission ( )

This function processes the transmitted data.

copies the received mpi data into the particles/interacions and adds them to the particleHandler/interactionHandler All vectors that have been used in transmitting data are then cleaned up

Parameters
[in,out]particleHandlerHandles all particles in the current domain, on output contains the newly received particles
[in,out]interactionHandlerHandles all interactions in the current domain, on output contains the newly received interactions

Definition at line 1233 of file Domain.cc.

References boundaryList_, boundaryParticleDataReceive_, boundaryParticleDataSend_, InteractionHandler::deleteMPIInteractionDataArray(), BaseHandler< T >::getDPMBase(), getHandler(), interactionDataReceive_, interactionDataSend_, DPMBase::interactionHandler, newBoundaryParticleList_, newInteractionList_, numberOfParticlesReceive_, numberOfParticlesSend_, numNewInteractionsReceive_, numNewInteractionsSend_, processReceivedBoundaryParticleData(), processReceivedInteractionData(), and processSentBoundaryParticles().

Referenced by addNewParticles(), and addParticle().

1234  {
1235  //For all boundaries
1236  for (int localIndex : boundaryList_)
1237  {
1238  //copy the received data into the particleHandler and neighbour particle list
1239  std::vector<BaseParticle*> newParticles;
1240  processReceivedBoundaryParticleData(localIndex, newParticles);
1241  //All particles in the current domain that have been send to the other domains need to be flagged as communicating particles
1242  processSentBoundaryParticles(localIndex);
1243  //copy the received interaction data into the standard dpm structure
1244  processReceivedInteractionData(localIndex, newParticles);
1245 
1246  //Delete all send/receive data
1247  boundaryParticleDataSend_[localIndex].clear();
1248  boundaryParticleDataReceive_[localIndex].clear();
1251  interactionDataReceive_[localIndex]);
1252 
1253  //Reset all counters
1254  numberOfParticlesSend_[localIndex] = 0;
1255  numberOfParticlesReceive_[localIndex] = 0;
1256  numNewInteractionsSend_[localIndex] = 0;
1257  numNewInteractionsReceive_[localIndex] = 0;
1258 
1259  //Reset all lists
1260  newBoundaryParticleList_[localIndex].clear();
1261  newInteractionList_[localIndex].clear();
1262  }
1263  }
std::vector< void * > interactionDataSend_
Container that keeps a void array of all the interaction data that are being send to other domains...
Definition: Domain.h:562
std::vector< unsigned > numberOfParticlesReceive_
Counter that keeps track of the number of particles that are being received by this domain...
Definition: Domain.h:517
std::vector< unsigned > numNewInteractionsSend_
Counter that keeps track of the number of interactions that are being send to other domains...
Definition: Domain.h:522
std::vector< std::vector< BaseInteraction * > > newInteractionList_
Array that queues interactions that need to be transmitted.
Definition: Domain.h:507
void deleteMPIInteractionDataArray(void *dataArray)
deletes an MPIInteractionDataArray
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< void * > interactionDataReceive_
Container that keeps a void array of all the interaction data that is being received by this domain...
Definition: Domain.h:567
void processReceivedInteractionData(unsigned index, std::vector< BaseParticle * > &newParticles)
Processes the received interactions from newly added mpi particles.
Definition: Domain.cc:976
DomainHandler * getHandler() const
Gets the domainHandler.
Definition: Domain.cc:1549
std::vector< unsigned > numberOfParticlesSend_
Counter that keeps track of the number of particles that are being send to other domains.
Definition: Domain.h:512
void processReceivedBoundaryParticleData(unsigned index, std::vector< BaseParticle * > &newParticles)
Function that copies the mpi data format of a base particle to a real particle and adds it to the par...
Definition: Domain.cc:918
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
std::vector< std::vector< MPIParticle > > boundaryParticleDataReceive_
Container that keeps a list of MPIParticles that are being received by this domain.
Definition: Domain.h:537
void processSentBoundaryParticles(unsigned index)
Bookkeep the newly send particles.
Definition: Domain.cc:954
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
std::vector< unsigned > numNewInteractionsReceive_
Counter that keeps track of the number of interactions that are being received by this domain...
Definition: Domain.h:527
std::vector< std::vector< MPIParticle > > boundaryParticleDataSend_
Container that keeps a list of MPIParticles that are being send to other domains. ...
Definition: Domain.h:532
void Domain::finalisePositionAndVelocityUpdate ( std::set< BaseParticle * > &  ghostParticlesToBeDeleted)

processes position and velocity data for ghost particles

After the data has been received from other processors, this function will update the ghost particles with the new position and velocity data. Afterwards the status of the particles will be updated based on their new positions. Sometimes a particle needs to be removed from the simulation, however since this particle might still be active in the periodic boundary it is not deleted straight away but stored in ghostParticlesToBeDeleted. Finally the communication data is removed.

Parameters
[in,out]ghostParticlesToBeDeletedA vector containing particles that need to be removed from the simulation

Definition at line 1472 of file Domain.cc.

References boundaryList_, updateParticlePosition(), updateParticles(), updateParticleVelocity(), updatePositionDataReceive_, updatePositionDataSend_, updateVelocityDataReceive_, and updateVelocityDataSend_.

Referenced by updateStatus().

1473 {
1474 
1475  //For all active boundaries
1476  for (int localIndex : boundaryList_)
1477  {
1478  updateParticlePosition(localIndex);
1479  updateParticleVelocity(localIndex);
1480  }
1481 
1482  //Based on the new position, update the particle lists.
1483  //Remove particles that left the communication zone, they will be re-communicated in a later step
1484  updateParticles(ghostParticlesToBeDeleted);
1485 
1486  //For all active boundaries clear the data lists
1487  for (int localIndex : boundaryList_)
1488  {
1489  updatePositionDataSend_[localIndex].clear();
1490  updateVelocityDataSend_[localIndex].clear();
1491  updatePositionDataReceive_[localIndex].clear();
1492  updateVelocityDataReceive_[localIndex].clear();
1493  }
1494 
1495 }
void updateParticleVelocity(int localIndex)
Updates the velocity of particles which are flagged as MPIParticles.
Definition: Domain.cc:1412
void updateParticles(std::set< BaseParticle * > &ghostParticlesToBeDeleted)
This step updates all communication lists and particles in the communication zone.
Definition: Domain.cc:1279
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataReceive_
Container that keeps a list of MPIParticleVelocities that are being received by this domain...
Definition: Domain.h:557
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
void updateParticlePosition(int localIndex)
Updates the position of particles which are flagged as MPIParticles.
Definition: Domain.cc:1383
std::vector< std::vector< MPIParticlePosition > > updatePositionDataSend_
Container that keeps a list of MPIParticlePositions that are being send to other domains.
Definition: Domain.h:542
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataSend_
Container that keeps a list of MPIParticleVelocities that are being send to other domains...
Definition: Domain.h:552
std::vector< std::vector< MPIParticlePosition > > updatePositionDataReceive_
Container that keeps a list of MPIParticlePositions that are being received by this domain...
Definition: Domain.h:547
void Domain::finaliseVelocityUpdate ( )

Processes particle velocity data for ghost particles.

This function is not in use

Definition at line 1528 of file Domain.cc.

References boundaryList_, updateParticleVelocity(), updateVelocityDataReceive_, and updateVelocityDataSend_.

Referenced by updateVelocity().

1529 {
1530  //For all active boundaries
1531  for (int localIndex : boundaryList_)
1532  {
1533  updateParticleVelocity(localIndex);
1534  }
1535 
1536  //For all active boundaries clear the data lists
1537  for (int localIndex : boundaryList_)
1538  {
1539  updateVelocityDataSend_[localIndex].clear();
1540  updateVelocityDataReceive_[localIndex].clear();
1541  }
1542 }
void updateParticleVelocity(int localIndex)
Updates the velocity of particles which are flagged as MPIParticles.
Definition: Domain.cc:1412
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataReceive_
Container that keeps a list of MPIParticleVelocities that are being received by this domain...
Definition: Domain.h:557
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataSend_
Container that keeps a list of MPIParticleVelocities that are being send to other domains...
Definition: Domain.h:552
std::vector< int > Domain::findNearbyBoundaries ( BaseParticle particle,
Mdouble  offset = 0 
)

This function finds if a given particle is close to a given boundary.

This function detects in how many boundaries the particle is located and is stored in the boundaryIndex. The boundary Index in the x-direction: a) -1 if the particle is at the left boundary b) 0 if the particle is not at a boundary c) 1 if the particle is at the right boundary The same holds for the y and z direction as well

Parameters
[in]particlea base particle
[out]offsetthe L1 distance between the domain boundary and the wanted boundary
Returns
boundaryIndex a vector indicating at which boundary the particle is

Definition at line 549 of file Domain.cc.

References domainHandler_, domainMax_, domainMin_, Vec3D::getComponent(), DomainHandler::getInteractionDistance(), and BaseInteractable::getPosition().

Referenced by addParticlesToLists(), and updateParticles().

550 {
551  std::vector<int> boundaryIndex(3);
552  Mdouble interactionDistance = domainHandler_->getInteractionDistance();
553 
554  //for x,y,z directions, find if the particle is close to the left or right wall or not at all
555  for (int d = 0; d < 3; d++)
556  {
557  //Check if the particle is close to Lx
558  if ((particle->getPosition().getComponent(d)) < (domainMin_[d] + interactionDistance + offset))
559  {
560  //Update switch
561  boundaryIndex[d] = -1;
562  }
563  //Check if particle is close to Rx
564  else if ((particle->getPosition().getComponent(d)) >= (domainMax_[d] - interactionDistance - offset))
565  {
566  //Update switch
567  boundaryIndex[d] = 1;
568  }
569  }
570  return boundaryIndex;
571 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
double Mdouble
Definition: GeneralDefine.h:34
std::vector< double > domainMin_
Minimum domain bounds in the x,y and z direction.
Definition: Domain.h:443
Mdouble getInteractionDistance()
Gets the interaction distance of the domain handler.
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Definition: Vector.cc:194
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
std::vector< double > domainMax_
Maximum domain bounds in the x,y and z direction.
Definition: Domain.h:448
void Domain::findNewMPIInteractions ( )

Finds interactions that have to be send over to another domain.

Finds interactions that have to be sent over to another domain.

Newly added particles to the communication lists might have history interactions with the particles already there. The other domains need to be aware of these history interactions and this function collects the relevant interactions.

Definition at line 806 of file Domain.cc.

References boundaryList_, BaseWall::getDistanceAndNormal(), Vec3D::getLengthSquared(), BaseInteractable::getPosition(), BaseParticle::getSumOfInteractionRadii(), BaseParticle::isInMPIDomain(), isInNewBoundaryParticleList(), newBoundaryParticleList_, and newInteractionList_.

Referenced by prepareBoundaryDataTransmission().

807  {
808  //For all active boundaries
809  for (int localIndex : boundaryList_)
810  {
811  //Check all newly added particles for interactions with already known particles
812  for (BaseParticle* newBoundaryParticle : newBoundaryParticleList_[localIndex])
813  {
814  //Loop over all interactions of the new particle
815  std::vector<BaseInteraction*> interactions = newBoundaryParticle->getInteractions();
816  for (BaseInteraction* interaction : interactions)
817  {
818  //Find out what the new particle is interacting with
819  BaseParticle* particleP = dynamic_cast<BaseParticle*>(interaction->getP());
820  BaseParticle* objectI = dynamic_cast<BaseParticle*>(interaction->getI());
821 
822  //If the P in the interaction structure is the new particle, find I
823  if (newBoundaryParticle == particleP)
824  {
825  //Check if the new particle is interacting with a wall
826  if (!objectI)
827  {
828  //Check if the interaction is still valid
829  BaseWall* wall = dynamic_cast<BaseWall*>(interaction->getI());
830  Mdouble distance;
831  Vec3D normal;
832  wall->getDistanceAndNormal(*particleP, distance, normal);
833  if (distance <= particleP->getMaxInteractionRadius())
834  {
835  //Add the interaction to the list if there are still in contact (hence the if statement)
836  newInteractionList_[localIndex].push_back(interaction);
837  }
838  }
839  else //is I a particle
840  {
841  //check if particle is in mpi domain OR (TODO) if it is in the newBoundaryParticleList_
842  if (objectI->isInMPIDomain() || isInNewBoundaryParticleList(objectI, localIndex) ) {
843  //Is the particle still interacting after the position update?
844  Vec3D branchVector = particleP->getPosition() - objectI->getPosition();
845  //Get the square of the distance between particle i and particle j
846  Mdouble distanceSquared = Vec3D::getLengthSquared(branchVector);
847  Mdouble sumOfInteractionRadii =
848  objectI->getSumOfInteractionRadii(particleP);
849  if (distanceSquared < (sumOfInteractionRadii * sumOfInteractionRadii))
850  {
851  //Add the interaction to the list
852  newInteractionList_[localIndex].push_back(interaction);
853  }
854  }
855  }
856  }
857  else //newBoundaryParticle is I in the interaction, P can only be a particle
858  {
859  //it is "I" in the interaction structure, check if its in the mpi domain
860  if (particleP->isInMPIDomain() || isInNewBoundaryParticleList(particleP, localIndex))
861  {
862  //Is the particle still interacting after the position update?
863  Vec3D branchVector = particleP->getPosition() - objectI->getPosition();
864  //Get the square of the distance between particle i and particle j
865  Mdouble distanceSquared = Vec3D::getLengthSquared(branchVector);
866  Mdouble sumOfInteractionRadii =
867  objectI->getSumOfInteractionRadii(particleP);
868  if (distanceSquared < (sumOfInteractionRadii * sumOfInteractionRadii))
869  {
870  //Add the interaction to the list
871  newInteractionList_[localIndex].push_back(interaction);
872  }
873  }
874  }
875  }
876  }
877  }
878 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
double Mdouble
Definition: GeneralDefine.h:34
bool isInNewBoundaryParticleList(BaseParticle *object, int localIndex) const
Definition: Domain.cc:791
Mdouble getSumOfInteractionRadii(const BaseParticle *particle) const
returns the sum of the radii plus the interactionDistance
Definition: BaseParticle.h:376
std::vector< std::vector< BaseInteraction * > > newInteractionList_
Array that queues interactions that need to be transmitted.
Definition: Domain.h:507
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
Definition: Vector.cc:184
Stores information about interactions between two interactable objects; often particles but could be ...
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
bool isInMPIDomain()
Indicates if the particle is in the communication zone of the mpi domain.
virtual bool getDistanceAndNormal(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return) const =0
Pure virtual function that computes the distance of a BaseParticle to this wall and returns the norma...
Basic class for walls.
Definition: BaseWall.h:47
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
Definition: Vector.h:49
void Domain::findNewMPIParticle ( BaseParticle particle)

Function that check if a given particle should be added to the communication lists.

Function that checks if a given particle should be added to the communication lists and adds it accordingly.

Parameters
[in]particlepoint to a particle that is being checked if it should be added to the communication lists

Definition at line 782 of file Domain.cc.

References addParticlesToLists(), BaseParticle::isInMPIDomain(), BaseParticle::isPeriodicGhostParticle(), and newBoundaryParticleList_.

Referenced by findNewMPIParticles(), and prepareBoundaryDataTransmission().

783 {
784  //If the particle is an MPI particle
785  if (!particle->isInMPIDomain() && !particle->isPeriodicGhostParticle())
786  {
788  }
789 }
bool isInMPIDomain()
Indicates if the particle is in the communication zone of the mpi domain.
bool isPeriodicGhostParticle() const
Indicates if this particle is a ghost in the periodic boundary.
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
void addParticlesToLists(BaseParticle *particle, std::vector< std::vector< BaseParticle * > > &list)
Function that adds the particles to the approriate boundary list.
Definition: Domain.cc:683
void Domain::findNewMPIParticles ( const ParticleHandler particleHandler)

Function that finds new particles in the particle handler that should be added to the communication lists.

Parameters
[in]particleHandlerthe container that contains all particles

Definition at line 768 of file Domain.cc.

References findNewMPIParticle().

Referenced by prepareBoundaryDataTransmission().

769 {
770  //For all particles inside the given domain, loop over all the particles to
771  //see if we have to add the particles to the new particle list
772  for (BaseParticle* particle : particleHandler)
773  {
774  findNewMPIParticle(particle);
775  }
776 }
void findNewMPIParticle(BaseParticle *particle)
Function that check if a given particle should be added to the communication lists.
Definition: Domain.cc:782
BaseParticle * Domain::findParticleInList ( unsigned int  identification,
std::vector< BaseParticle * >  particleList 
)

Searches for a particle with a specific id in a list of particles.

When interactions are copied over MPI from an MPI particle, the unique id of the particles they interact with need to be looked up. This functions searches for the correct particle

Todo:
MX: This is probably not the fastest method
Parameters
[in]indentificationThe unique ID of a particle
[in]particleListList of particles
Returns
Either the particle with the id identification or a nullptr when the particle has not been found

Definition at line 524 of file Domain.cc.

525 {
526  for (BaseParticle* particle : particleList)
527  {
528  if (particle->getId() == identification)
529  {
530  return particle;
531  }
532  }
533  return nullptr;
534 }
void Domain::flushParticles ( std::set< BaseParticle * > &  toBeFlushedList)

Particles that are going to be deleted from the simulation are flushed out of the communication boundaries.

Parameters
[in]toBeDeletedListA list of particles that is going to be deleted

Definition at line 1669 of file Domain.cc.

References boundaryList_, boundaryParticleList_, boundaryParticleListNeighbour_, and flushParticlesFromList().

Referenced by DPMBase::checkInteractionWithBoundaries(), PeriodicBoundaryHandler::clearCommunicationLists(), and DPMBase::deleteGhostParticles().

1670 {
1671  //For all active boundaries
1672  for (int localIndex : boundaryList_)
1673  {
1674  flushParticlesFromList(boundaryParticleList_[localIndex], toBeFlushedList);
1675  flushParticlesFromList(boundaryParticleListNeighbour_[localIndex], toBeFlushedList);
1676  }
1677 }
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
void flushParticlesFromList(std::vector< BaseParticle * > &list, std::set< BaseParticle * > &toBeDeletedList)
Particles that are going to be deleted from the simulation are flushed out of a give communcation bou...
Definition: Domain.cc:1679
std::vector< std::vector< BaseParticle * > > boundaryParticleList_
A list of boundary particles in the communication zone that are ghost particles on other domains...
Definition: Domain.h:492
void Domain::flushParticlesFromList ( std::vector< BaseParticle * > &  list,
std::set< BaseParticle * > &  toBeDeletedList 
)

Particles that are going to be deleted from the simulation are flushed out of a give communcation boundary.

Definition at line 1679 of file Domain.cc.

References BaseInteractable::getPosition(), logger, and VERBOSE.

Referenced by flushParticles().

1680 {
1681  //Firstly: turn all particles that need to be flushed into nullptrs
1682  for (auto& p : list)
1683  {
1684  if (p != nullptr)
1685  {
1686  BaseParticle* particle1 = p;
1687  for (BaseParticle* particle2 : toBeFlushedList)
1688  {
1689  //If the particle was found in the list, make a nullptr
1690  if (particle1 == particle2)
1691  {
1692  logger(VERBOSE, "Removing particle from mpi domain at: %", particle1->getPosition());
1693  p = nullptr;
1694  }
1695  }
1696  }
1697  }
1698 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::vector< bool > Domain::getActiveBoundaryList ( )

Returns a list of boundaries that are active in mpi communication.

Returns a list of boundaries that are active in mpi communication

Returns
List of active mpi communication boundaries

Definition at line 387 of file Domain.cc.

References activeBoundaryList_.

388 {
389  return activeBoundaryList_;
390 }
std::vector< bool > activeBoundaryList_
A list of flags corresponding to an inactive or active boundary.
Definition: Domain.h:481
std::vector< double > Domain::getDomainMax ( )

Gets the maximum domain bounds.

Gets the domain's maximum domain bounds

Returns
Maximum bounds of the domain

Definition at line 319 of file Domain.cc.

References domainMax_.

Referenced by DomainHandler::setInteractionDistance().

320 {
321  return domainMax_;
322 }
std::vector< double > domainMax_
Maximum domain bounds in the x,y and z direction.
Definition: Domain.h:448
std::vector< double > Domain::getDomainMin ( )

Gets the minimum domain bounds.

Gets the domain's minimum domain bounds

Returns
Minimum bounds of the domain

Definition at line 310 of file Domain.cc.

References domainMin_.

Referenced by DomainHandler::setInteractionDistance().

311 {
312  return domainMin_;
313 }
std::vector< double > domainMin_
Minimum domain bounds in the x,y and z direction.
Definition: Domain.h:443
int Domain::getGlobalIndex ( )

Gets the global index of the domain.

Returns the global index of the domain in the whole simulation domain

Returns
Returns the global index of the domain

Definition at line 346 of file Domain.cc.

References globalIndex_.

347 {
348  return globalIndex_;
349 }
int globalIndex_
Global index of the domain in the mesh.
Definition: Domain.h:459
std::vector< unsigned > Domain::getGlobalMeshIndex ( )

Gets the global mesh index of the domain.

returns a vector with the globa mesh indices (i,j,k)

Returns
global mesh indices i,j and k

Definition at line 355 of file Domain.cc.

References globalMeshIndex_.

356 {
357  return globalMeshIndex_;
358 }
std::vector< unsigned > globalMeshIndex_
Vector containing the global mesh indices i,j,k.
Definition: Domain.h:464
DomainHandler * Domain::getHandler ( ) const

Gets the domainHandler.

Returns the pointer to the DomainHandler the domain belongs to

Returns
pointer to the handler

Definition at line 1549 of file Domain.cc.

References domainHandler_.

Referenced by debugInformation(), finaliseBoundaryDataTransmission(), performBoundaryDataTransmission(), prepareBoundaryDataTransmission(), processReceivedBoundaryParticleData(), processReceivedInteractionData(), setBounds(), setRange(), and updateParticlePosition().

1550 {
1551  return domainHandler_;
1552 }
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
int Domain::getLocalIndex ( int  i,
int  j,
int  k 
)

return the local index of a domain given local mesh indices i,j and k

Given i,j,k (where i=0,j=0,k=0 is the current domain), get the local index of a neighbouring domain

Parameters
[in]iIndex in the x-direction with i=0 corresponding to the current domain
[in]jIndex in the y-direction with j=0 corresponding to the current domain
[in]kIndex in the z-direction with k=0 corresponding to the current domain
Returns
The localIndex of the neighbour is returned.

Definition at line 498 of file Domain.cc.

Referenced by addParticlesToLists(), and disableBoundaries().

499 {
500  return i + 3 * j + 9 * k + 13;
501 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
int Domain::getLocalIndex ( std::vector< int >  localMeshIndex)

return the local index of a doman given the localMeshIndex vector

Given i,j,k (where i=0,j=0,k=0 is the current domain), get the local index of a neighbouring domain

Parameters
[in]localMeshIndex(i,j,k) where (0,0,0) corresponds to the current domain
Returns
The localIndex of the neighbour is returned.

Definition at line 509 of file Domain.cc.

References XAXIS, YAXIS, and ZAXIS.

510 {
511  return localMeshIndex[Direction::XAXIS] + 3 * localMeshIndex[Direction::YAXIS] +
512  9 * localMeshIndex[Direction::ZAXIS] + 13;
513 }
Vec3D Domain::getMiddle ( ) const

Gives the middle of the domain.

Returns the middle of this square domain, required for periodic particles

Returns
middle_ The middle position of a cubic domain

Definition at line 1704 of file Domain.cc.

References middle_.

Referenced by PeriodicBoundaryHandler::findTargetProcessor().

1705 {
1706  return middle_;
1707 }
Vec3D middle_
Middle of the closed domain.
Definition: Domain.h:453
std::string Domain::getName ( ) const
overridevirtual

Returns the name of the object.

Returns the object's class name (i.e. 'DeletionBoundary').

Returns
the object's class name

Implements BaseObject.

Definition at line 207 of file Domain.cc.

208 {
209  return "Domain";
210 }
unsigned int Domain::getNumberOfMPIParticles ( )

Obtains the number of particles in the particleHandler that are MPIParticles.

All the MPIParticles are located in the neighbour lists and we only need to take a sum of these lists to obtain the number of MPIParticles. This function is required to keep track of the number of real particles in the domain.

Definition at line 1635 of file Domain.cc.

References boundaryParticleListNeighbour_.

1636 {
1637  unsigned int count = 0;
1638  for (auto& index : boundaryParticleListNeighbour_)
1639  {
1640  count += index.size();
1641  }
1642  return count;
1643 }
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
unsigned int Domain::getNumberOfTrueMPIParticles ( )

Obtains the number of particles in the particleHandler that are MPIParticles, but NOT periodic particles.

All the MPIParticles are located in the neighbour lists and we only need to take a sum of these lists to obtain the number of MPIParticles. This function is required to keep track of the number of real particles in the domain.

Definition at line 1650 of file Domain.cc.

References boundaryParticleListNeighbour_.

Referenced by ParticleHandler::getNumberOfRealObjectsLocal().

1651 {
1652  unsigned int count = 0;
1653  for (auto& index : boundaryParticleListNeighbour_)
1654  {
1655  for (auto& p : index)
1656  {
1657  if (!p->isPeriodicGhostParticle())
1658  {
1659  count++;
1660  }
1661  }
1662  }
1663  return count;
1664 }
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
int Domain::getRank ( )

Gets the rank associated with the assigned processorID.

Gets the domain's rank, corresponding to a processorID.

Returns
rank of the domain

Definition at line 328 of file Domain.cc.

References rank_.

329 {
330  return rank_;
331 }
int rank_
Rank of the domain which identifies to which processor it belongs.
Definition: Domain.h:572
bool Domain::isInCommunicationZone ( BaseParticle particle)

Check if the particle is in the communication zone of the current domain.

Check if the particle is inside the communication zone

Parameters
[in]particlePointer to a particle
Returns
True if the particle is in the communication zone, i.e. in the domain, but not in the inner domain. False if it is outside the communication zone.

Definition at line 441 of file Domain.cc.

References containsParticle(), and isInInnerDomain().

Referenced by DPMBase::mpiIsInCommunicationZone().

442 {
443  //First check if the particle is actually in the domain
444  //Secondly check if the particle is in the inner domain
445  return containsParticle(particle) && !(isInInnerDomain(particle));
446 }
bool isInInnerDomain(BaseParticle *particle)
Check if the particle is in the current domain but not in the communication zone. ...
Definition: Domain.cc:430
bool containsParticle(BaseParticle *particle, Mdouble offset=0.0)
Check to see if a given particle is within the current domain.
Definition: Domain.cc:400
bool Domain::isInGreaterDomain ( BaseParticle particle)

Check to see if a given particle is in the current domain or in neighbouring communication zones.

Check if the particle is inside the domain + the communication zone around it

Parameters
[in]particlePointer to a particle
Returns
True if the particle is in the domain or the whole communication zone around it. False if it is outside

Definition at line 420 of file Domain.cc.

References containsParticle(), domainHandler_, and DomainHandler::getInteractionDistance().

Referenced by PeriodicBoundaryHandler::getMPIFlags().

421 {
423 }
bool containsParticle(BaseParticle *particle, Mdouble offset=0.0)
Check to see if a given particle is within the current domain.
Definition: Domain.cc:400
Mdouble getInteractionDistance()
Gets the interaction distance of the domain handler.
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
bool Domain::isInInnerDomain ( BaseParticle particle)

Check if the particle is in the current domain but not in the communication zone.

Parameters
[in]particlePointer to a particle
Returns
Returns true if the particle is in the inner domain (i.e. not in the communication zone of the domain)

Definition at line 430 of file Domain.cc.

References containsParticle(), domainHandler_, and DomainHandler::getInteractionDistance().

Referenced by PeriodicBoundaryHandler::getMPIFlags(), and isInCommunicationZone().

431 {
433 }
bool containsParticle(BaseParticle *particle, Mdouble offset=0.0)
Check to see if a given particle is within the current domain.
Definition: Domain.cc:400
Mdouble getInteractionDistance()
Gets the interaction distance of the domain handler.
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
bool Domain::isInNewBoundaryParticleList ( BaseParticle object,
int  localIndex 
) const

Definition at line 791 of file Domain.cc.

References newBoundaryParticleList_.

Referenced by findNewMPIInteractions().

792 {
793  for (BaseParticle *q : newBoundaryParticleList_[localIndex]) {
794  if (q == objectI)
795  return true;
796  }
797  return false;
798 }
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
void Domain::performBoundaryDataTransmission ( )

Collects data to be transmitted and then performs the transmission of the data.

The particles and interactions are copied into a data class that can be transmitted to other processors. The data is then accordingly send to the appropriate processors

Parameters
[in]interactionHandlerHandler that contains all interactions, required to collect interaction data

Definition at line 1192 of file Domain.cc.

References boundaryList_, boundaryParticleDataReceive_, boundaryParticleDataSend_, collectBoundaryParticleData(), collectInteractionData(), InteractionHandler::createMPIInteractionDataArray(), BaseHandler< T >::getDPMBase(), getHandler(), INTERACTION, INTERACTION_DATA, interactionDataReceive_, interactionDataSend_, DPMBase::interactionHandler, numberOfParticlesReceive_, numberOfParticlesSend_, numNewInteractionsReceive_, numNewInteractionsSend_, PARTICLE, PARTICLE_DATA, and sendAndReceiveMPIData().

Referenced by addNewParticles(), and addParticle().

1193  {
1194  //For all active boundaries
1195  for (int localIndex : boundaryList_)
1196  {
1197  //make sure enough memory is reserved to receive the data
1198  boundaryParticleDataReceive_[localIndex].resize(numberOfParticlesReceive_[localIndex]);
1199 
1200  //Collect the particle data
1201  collectBoundaryParticleData(localIndex);
1202 
1203  //Send the data
1205  boundaryParticleDataReceive_[localIndex].data(), numberOfParticlesReceive_[localIndex],
1206  boundaryParticleDataSend_[localIndex].data(), numberOfParticlesSend_[localIndex],
1207  localIndex);
1208 
1209 
1210  //create arrays for sending and receiving interaction data
1212  numNewInteractionsSend_[localIndex]);
1214  numNewInteractionsReceive_[localIndex]);
1215 
1216  //Collect the interaction data
1217  collectInteractionData(localIndex);
1218 
1219  //Send the data
1221  interactionDataReceive_[localIndex], numNewInteractionsReceive_[localIndex],
1222  interactionDataSend_[localIndex], numNewInteractionsSend_[localIndex], localIndex);
1223  }
1224  }
std::vector< void * > interactionDataSend_
Container that keeps a void array of all the interaction data that are being send to other domains...
Definition: Domain.h:562
std::vector< unsigned > numberOfParticlesReceive_
Counter that keeps track of the number of particles that are being received by this domain...
Definition: Domain.h:517
void collectInteractionData(int localIndex)
Collects the data of an interaction that has to be communicated to other processors.
Definition: Domain.cc:901
void * createMPIInteractionDataArray(unsigned int numberOfInteractions) const
creates an empty MPIInteractionDataArray
std::vector< unsigned > numNewInteractionsSend_
Counter that keeps track of the number of interactions that are being send to other domains...
Definition: Domain.h:522
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< void * > interactionDataReceive_
Container that keeps a void array of all the interaction data that is being received by this domain...
Definition: Domain.h:567
DomainHandler * getHandler() const
Gets the domainHandler.
Definition: Domain.cc:1549
void sendAndReceiveMPIData(MercuryMPITag tag, MercuryMPIType type, T *receiveData, unsigned receiveCount, T *sendData, unsigned sendCount, unsigned localIndexNeighbour)
Function that sends transmissionData/positionData/velocityData to other processors.
Definition: Domain.h:359
std::vector< unsigned > numberOfParticlesSend_
Counter that keeps track of the number of particles that are being send to other domains.
Definition: Domain.h:512
void collectBoundaryParticleData(int localIndex)
collects the data of a particle that has to be communicated to other processors
Definition: Domain.cc:886
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
std::vector< std::vector< MPIParticle > > boundaryParticleDataReceive_
Container that keeps a list of MPIParticles that are being received by this domain.
Definition: Domain.h:537
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
std::vector< unsigned > numNewInteractionsReceive_
Counter that keeps track of the number of interactions that are being received by this domain...
Definition: Domain.h:527
std::vector< std::vector< MPIParticle > > boundaryParticleDataSend_
Container that keeps a list of MPIParticles that are being send to other domains. ...
Definition: Domain.h:532
void Domain::prepareBoundaryDataTransmission ( )

Prepares the MPI transmission of particle and interaction data from particles in particleHandler.

This function checks all the particles in the particle handler to see if they have moved in the communication domain. If that is the case they are added to a list of particles that need to be send. After all particles are evaluated the number of new particles to be send is send to the appropriate processors The same is being done to the interactions of the newly found particles

Parameters
[in]particleHandlerhandles all the particles in the current domain

Definition at line 1117 of file Domain.cc.

References boundaryList_, findNewMPIInteractions(), findNewMPIParticles(), getHandler(), INTERACTION_COUNT, newBoundaryParticleList_, newInteractionList_, numberOfParticlesReceive_, numberOfParticlesSend_, numNewInteractionsReceive_, numNewInteractionsSend_, PARTICLE_COUNT, and sendAndReceiveCount().

Referenced by addNewParticles(), and addParticle().

1118  {
1119  //Find new particles that have entered the communication zone
1120  findNewMPIParticles(getHandler()->getDPMBase()->particleHandler);
1121 
1122  //Find interactions between new particles and other particles in the communication zone
1124 
1125  //Compute number of particles to send
1126  //For all boundaries
1127  for (int localIndex : boundaryList_)
1128  {
1129  numberOfParticlesSend_[localIndex] = newBoundaryParticleList_[localIndex].size();
1130  numNewInteractionsSend_[localIndex] = newInteractionList_[localIndex].size();
1131  }
1132 
1133  //For all active boundaries
1134  for (int localIndex : boundaryList_)
1135  {
1136  //Send and receive the number of new boundary particles
1138  (numberOfParticlesSend_[localIndex]), localIndex);
1139 
1140  //Send and receive the new interactions
1142  (numNewInteractionsSend_[localIndex]), localIndex);
1143  }
1144  }
std::vector< unsigned > numberOfParticlesReceive_
Counter that keeps track of the number of particles that are being received by this domain...
Definition: Domain.h:517
std::vector< unsigned > numNewInteractionsSend_
Counter that keeps track of the number of interactions that are being send to other domains...
Definition: Domain.h:522
void findNewMPIInteractions()
Finds interactions that have to be send over to another domain.
Definition: Domain.cc:806
std::vector< std::vector< BaseInteraction * > > newInteractionList_
Array that queues interactions that need to be transmitted.
Definition: Domain.h:507
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
void findNewMPIParticles(const ParticleHandler &particleHandler)
Function that finds new particles in the particle handler that should be added to the communication l...
Definition: Domain.cc:768
DomainHandler * getHandler() const
Gets the domainHandler.
Definition: Domain.cc:1549
void sendAndReceiveCount(MercuryMPITag tag, unsigned &countReceive, unsigned &countSend, unsigned localIndexNeighbour)
A symmetric communication between two domains exchanging a send/recieve count.
Definition: Domain.cc:1090
std::vector< unsigned > numberOfParticlesSend_
Counter that keeps track of the number of particles that are being send to other domains.
Definition: Domain.h:512
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
std::vector< unsigned > numNewInteractionsReceive_
Counter that keeps track of the number of interactions that are being received by this domain...
Definition: Domain.h:527
void Domain::prepareBoundaryDataTransmission ( BaseParticle particle)

Prepares the MPI transmission of a single particle and its interactions.

When a single particle has to be added to the communication zone (i.e. when the user adds a particle during the simulation) then all processors should be informed if they receive the particle or not. The functionality of this function is practically the same as that of prepareBoundaryDataTransmission(ParticleHandler &particleHandler) The same is being done to the interactions of the newly found particles

Parameters
[in]particleA base particle that needs to be transmitted

Definition at line 1154 of file Domain.cc.

References boundaryList_, containsParticle(), findNewMPIParticle(), INTERACTION_COUNT, newBoundaryParticleList_, newInteractionList_, numberOfParticlesReceive_, numberOfParticlesSend_, numNewInteractionsReceive_, numNewInteractionsSend_, PARTICLE_COUNT, and sendAndReceiveCount().

1155  {
1156  //Assign the particle to the correct lists if the particle belongs to this domain
1157  if (containsParticle(particle))
1158  {
1159  findNewMPIParticle(particle);
1160  }
1161 
1162  //Note: When inserting a single particle, it has no interactions, so no interactions to be copied either
1163 
1164  //Compute number of particles to send
1165  //For all boundaries
1166  for (int localIndex : boundaryList_)
1167  {
1168  numberOfParticlesSend_[localIndex] = newBoundaryParticleList_[localIndex].size();
1169  numNewInteractionsSend_[localIndex] = newInteractionList_[localIndex].size();
1170  }
1171 
1172 
1173  //For all active boundaries
1174  for (int localIndex : boundaryList_)
1175  {
1176  //Send and recieve the number of new boundary particles
1178  (numberOfParticlesSend_[localIndex]), localIndex);
1179 
1180  //Send and receive the new interactions
1182  (numNewInteractionsSend_[localIndex]), localIndex);
1183  }
1184  }
std::vector< unsigned > numberOfParticlesReceive_
Counter that keeps track of the number of particles that are being received by this domain...
Definition: Domain.h:517
std::vector< unsigned > numNewInteractionsSend_
Counter that keeps track of the number of interactions that are being send to other domains...
Definition: Domain.h:522
bool containsParticle(BaseParticle *particle, Mdouble offset=0.0)
Check to see if a given particle is within the current domain.
Definition: Domain.cc:400
std::vector< std::vector< BaseInteraction * > > newInteractionList_
Array that queues interactions that need to be transmitted.
Definition: Domain.h:507
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
void sendAndReceiveCount(MercuryMPITag tag, unsigned &countReceive, unsigned &countSend, unsigned localIndexNeighbour)
A symmetric communication between two domains exchanging a send/recieve count.
Definition: Domain.cc:1090
std::vector< unsigned > numberOfParticlesSend_
Counter that keeps track of the number of particles that are being send to other domains.
Definition: Domain.h:512
void findNewMPIParticle(BaseParticle *particle)
Function that check if a given particle should be added to the communication lists.
Definition: Domain.cc:782
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
std::vector< unsigned > numNewInteractionsReceive_
Counter that keeps track of the number of interactions that are being received by this domain...
Definition: Domain.h:527
void Domain::preparePositionAndVelocityUpdate ( )

Function that sends particle position and velocity data for ghost particles to other processors.

When the real particle moves on it's actual domain, it's ghost particles have to get an update this function sends the data to the processors that require the update

Definition at line 1431 of file Domain.cc.

References boundaryList_, boundaryParticleList_, boundaryParticleListNeighbour_, copyPositionFrom(), copyVelocityFrom(), numberOfParticlesReceive_, numberOfParticlesSend_, POSITION, POSITION_DATA, sendAndReceiveMPIData(), updatePositionDataReceive_, updatePositionDataSend_, updateVelocityDataReceive_, updateVelocityDataSend_, VELOCITY, and VELOCITY_DATA.

Referenced by updateStatus().

1432 {
1433  //For all active boundaries
1434  for (int localIndex : boundaryList_)
1435  {
1436  numberOfParticlesSend_[localIndex] = boundaryParticleList_[localIndex].size();
1437  numberOfParticlesReceive_[localIndex] = boundaryParticleListNeighbour_[localIndex].size();
1438 
1439  //Increase capacity for the receiving data files
1440  updatePositionDataReceive_[localIndex].resize(numberOfParticlesReceive_[localIndex]);
1441  updateVelocityDataReceive_[localIndex].resize(numberOfParticlesReceive_[localIndex]);
1442 
1443 
1444  //Collect data
1445  for (BaseParticle* particle : boundaryParticleList_[localIndex])
1446  {
1447  updatePositionDataSend_[localIndex].push_back(copyPositionFrom(particle));
1448  updateVelocityDataSend_[localIndex].push_back(copyVelocityFrom(particle));
1449  }
1450 
1451  //Send and receive the data
1453  updatePositionDataReceive_[localIndex].data(), numberOfParticlesReceive_[localIndex],
1454  updatePositionDataSend_[localIndex].data(), numberOfParticlesSend_[localIndex],
1455  localIndex);
1457  updateVelocityDataReceive_[localIndex].data(), numberOfParticlesReceive_[localIndex],
1458  updateVelocityDataSend_[localIndex].data(), numberOfParticlesSend_[localIndex],
1459  localIndex);
1460  }
1461 }
std::vector< unsigned > numberOfParticlesReceive_
Counter that keeps track of the number of particles that are being received by this domain...
Definition: Domain.h:517
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataReceive_
Container that keeps a list of MPIParticleVelocities that are being received by this domain...
Definition: Domain.h:557
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< std::vector< MPIParticlePosition > > updatePositionDataSend_
Container that keeps a list of MPIParticlePositions that are being send to other domains.
Definition: Domain.h:542
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataSend_
Container that keeps a list of MPIParticleVelocities that are being send to other domains...
Definition: Domain.h:552
void sendAndReceiveMPIData(MercuryMPITag tag, MercuryMPIType type, T *receiveData, unsigned receiveCount, T *sendData, unsigned sendCount, unsigned localIndexNeighbour)
Function that sends transmissionData/positionData/velocityData to other processors.
Definition: Domain.h:359
std::vector< unsigned > numberOfParticlesSend_
Counter that keeps track of the number of particles that are being send to other domains.
Definition: Domain.h:512
MPIParticlePosition copyPositionFrom(BaseParticle *particle)
Copies the position from a particle to an MPIParticlePosition class.
std::vector< std::vector< MPIParticlePosition > > updatePositionDataReceive_
Container that keeps a list of MPIParticlePositions that are being received by this domain...
Definition: Domain.h:547
std::vector< std::vector< BaseParticle * > > boundaryParticleList_
A list of boundary particles in the communication zone that are ghost particles on other domains...
Definition: Domain.h:492
MPIParticleVelocity copyVelocityFrom(BaseParticle *particle)
Copies the velocity from a particle to an MPIParticleVelocity class.
void Domain::prepareVelocityUpdate ( )

Function that sends particle velocity data for ghost particles.

This function is not in use

Definition at line 1500 of file Domain.cc.

References boundaryList_, boundaryParticleList_, boundaryParticleListNeighbour_, copyVelocityFrom(), numberOfParticlesReceive_, numberOfParticlesSend_, sendAndReceiveMPIData(), updateVelocityDataReceive_, updateVelocityDataSend_, VELOCITY, and VELOCITY_DATA.

Referenced by updateVelocity().

1501 {
1502  //For all active boundaries
1503  for (int localIndex : boundaryList_)
1504  {
1505  numberOfParticlesSend_[localIndex] = boundaryParticleList_[localIndex].size();
1506  numberOfParticlesReceive_[localIndex] = boundaryParticleListNeighbour_[localIndex].size();
1507 
1508  //Resize the vector to the correct size
1509  updateVelocityDataReceive_[localIndex].resize(numberOfParticlesReceive_[localIndex]);
1510 
1511  //Collect data
1512  for (BaseParticle* particle : boundaryParticleList_[localIndex])
1513  {
1514  updateVelocityDataSend_[localIndex].push_back(copyVelocityFrom(particle));
1515  }
1516 
1517  //Send the data
1519  updateVelocityDataReceive_[localIndex].data(), numberOfParticlesReceive_[localIndex],
1520  updateVelocityDataSend_[localIndex].data(), numberOfParticlesSend_[localIndex],
1521  localIndex);
1522  }
1523 }
std::vector< unsigned > numberOfParticlesReceive_
Counter that keeps track of the number of particles that are being received by this domain...
Definition: Domain.h:517
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataReceive_
Container that keeps a list of MPIParticleVelocities that are being received by this domain...
Definition: Domain.h:557
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataSend_
Container that keeps a list of MPIParticleVelocities that are being send to other domains...
Definition: Domain.h:552
void sendAndReceiveMPIData(MercuryMPITag tag, MercuryMPIType type, T *receiveData, unsigned receiveCount, T *sendData, unsigned sendCount, unsigned localIndexNeighbour)
Function that sends transmissionData/positionData/velocityData to other processors.
Definition: Domain.h:359
std::vector< unsigned > numberOfParticlesSend_
Counter that keeps track of the number of particles that are being send to other domains.
Definition: Domain.h:512
std::vector< std::vector< BaseParticle * > > boundaryParticleList_
A list of boundary particles in the communication zone that are ghost particles on other domains...
Definition: Domain.h:492
MPIParticleVelocity copyVelocityFrom(BaseParticle *particle)
Copies the velocity from a particle to an MPIParticleVelocity class.
void Domain::processReceivedBoundaryParticleData ( unsigned  index,
std::vector< BaseParticle * > &  newParticles 
)

Function that copies the mpi data format of a base particle to a real particle and adds it to the particleHandler.

When adding a particle with this function it's always a ghost particle and therefor gets the MPIParticle flag

Parameters
[in]indexThe boundary index of the boundary list currently being treated
[in,out]particleHandlerContainer containing the particles of the current domain, will contain the new MPI particles as well

Definition at line 918 of file Domain.cc.

References ParticleHandler::addGhostObject(), boundaryParticleDataReceive_, boundaryParticleListNeighbour_, copyDataFromMPIParticleToParticle(), BaseHandler< T >::getDPMBase(), getHandler(), BaseObject::getId(), BaseHandler< T >::getLastObject(), BaseInteractable::getPosition(), constants::i, logger, MPISphericalParticle::newParticle(), numberOfParticlesReceive_, DPMBase::particleHandler, BaseParticle::setInMPIDomain(), BaseParticle::setMPIParticle(), BaseParticle::setPreviousPosition(), and VERBOSE.

Referenced by finaliseBoundaryDataTransmission().

919 {
920 
921  ParticleHandler& particleHandler = getHandler()->getDPMBase()->particleHandler;
922  //for all MPIPparticles that have been received on the other side
923  for (int i = 0; i < numberOfParticlesReceive_[index]; i++)
924  {
925  //copy data from data
927  copyDataFromMPIParticleToParticle(&(boundaryParticleDataReceive_[index][i]), p0, &particleHandler);
928 
929  //Flag that the particle is a ghost particle of a real particle in the neighbour domain
930  p0->setMPIParticle(true);
931  //Flag that the particle is list as a particle in the mpi domain
932  p0->setInMPIDomain(true);
933  //add particle to handler
934  particleHandler.addGhostObject(p0);
935  //Set previous position as current position
936  BaseParticle* pGhost = particleHandler.getLastObject();
937  pGhost->setPreviousPosition(particleHandler.getLastObject()->getPosition());
938  //Add to the newParticle list
939  newParticles.push_back(pGhost);
940  logger(VERBOSE, "Adding mpi particle % at: %", particleHandler.getLastObject()->getId(),
941  particleHandler.getLastObject()->getPosition());
942 
943  //add pointer to the particle to the list and set the status to idle
944  boundaryParticleListNeighbour_[index].push_back(particleHandler.getLastObject());
945  }
946 }
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
std::vector< unsigned > numberOfParticlesReceive_
Counter that keeps track of the number of particles that are being received by this domain...
Definition: Domain.h:517
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void setInMPIDomain(bool flag)
Flags the status of the particle if wether it is in the communication zone or not.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
void addGhostObject(int fromPrcessor, int toProcessor, BaseParticle *p)
Adds a ghost particle located at fromProcessor to toProcessor.
void copyDataFromMPIParticleToParticle(MPIParticle *bP, BaseParticle *p, ParticleHandler *particleHandler)
Copies data from an MPIParticle class to a BaseParticle and sets the particleHandler and species...
static BaseParticle * newParticle()
void setPreviousPosition(const Vec3D &pos)
Sets the particle's position in the previous time step.
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
DomainHandler * getHandler() const
Gets the domainHandler.
Definition: Domain.cc:1549
Container to store all BaseParticle.
void setMPIParticle(bool flag)
Flags the mpi particle status.
std::vector< std::vector< MPIParticle > > boundaryParticleDataReceive_
Container that keeps a list of MPIParticles that are being received by this domain.
Definition: Domain.h:537
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
void Domain::processReceivedInteractionData ( unsigned  index,
std::vector< BaseParticle * > &  newParticles 
)

Processes the received interactions from newly added mpi particles.

The received interaction data is scanned for interaction id's P and I they are then matches to the actual particle or wall and the interaction is created. The history details of the interaction are filled in after creation.

Bug:
There is a subtle and very rare bug in here, where two particles with an interaction across a periodic boundary pass into the next domain at the same time step. In this case, the interactions should be copied over before the ghost-particles are constructed. However, since the interaction is with the ghost particle, this cannot be done. That is why there is a 'continue' if one of the particles of the interaction is not found. An illustration of this situation is given in PeriodicBoundaryEnteringMpiDomainMPI2Test.
Parameters
[in]localIndexThe boundary index of the boundary list currently being treated
[in,out]interactionHandlerHandler containing all interactions on the current domain

Definition at line 976 of file Domain.cc.

References BaseHandler< T >::getDPMBase(), getHandler(), InteractionHandler::getInteractionDetails(), BaseInteractable::getInteractionWith(), BaseParticle::getInteractionWith(), BaseHandler< T >::getObjectById(), DPMBase::hGridGetInteractingParticleList(), interactionDataReceive_, DPMBase::interactionHandler, logger, numNewInteractionsReceive_, BaseInteraction::setMPIInteraction(), VERBOSE, DPMBase::wallHandler, and WARN.

Referenced by finaliseBoundaryDataTransmission().

977 {
979  for (unsigned int l = 0; l < numNewInteractionsReceive_[localIndex]; l++)
980  {
981  unsigned int identificationP;
982  unsigned int identificationI;
983  bool isWallInteraction;
984  unsigned timeStamp;
985 
986  //Get the general information required to setup a new interaction
988  l, identificationP, identificationI,
989  isWallInteraction, timeStamp);
990 
991  logger(VERBOSE, "interaction details: %, %, idP %, idI %, wall %, time %", interactionDataReceive_[localIndex],
992  l, identificationP, identificationI,
993  isWallInteraction, timeStamp);
994 
995  //Find the particle in the newParticle list
996  BaseParticle* pGhost = nullptr;
997  int idOther;
998  for (BaseParticle* particle : newParticles)
999  {
1000  if (particle->getId() == identificationP)
1001  {
1002  pGhost = particle;
1003  idOther = identificationI;
1004  break;
1005  }
1006 
1007  if (particle->getId() == identificationI)
1008  {
1009  pGhost = particle;
1010  idOther = identificationP;
1011  break;
1012  }
1013  }
1014  if (pGhost == nullptr)
1015  {
1016  logger(WARN, "In Domain::processReceivedInteractionData: pGhost (id %) is nullptr, the interaction data is not copied. Two particles possibly moved into domain simultaneously.", identificationP);
1017  continue;
1018  }
1019 
1020  //If it is a wall interaction, do stuff
1021  if (isWallInteraction)
1022  {
1023  BaseInteractable* I = getHandler()->getDPMBase()->wallHandler.getObjectById(identificationI);
1024  //Create interactions
1025  BaseInteraction* j = I->getInteractionWith(pGhost, timeStamp, &iH);
1026  if (j!= nullptr) j->setMPIInteraction(interactionDataReceive_[localIndex], l, false);
1027 
1028  }
1029  else
1030  {
1031  //Obtain potential interaction particles
1032  std::vector<BaseParticle*> interactingParticleList;
1033  getHandler()->getDPMBase()->hGridGetInteractingParticleList(pGhost, interactingParticleList);
1034 
1035  //Find the other interacting particle
1036  BaseParticle* otherParticle = nullptr;
1037  for (BaseParticle* p2 : interactingParticleList)
1038  {
1039  if (p2->getId() == idOther)
1040  {
1041  otherParticle = p2;
1042  break;
1043  }
1044  }
1045  if (otherParticle == nullptr) {
1046  //search for the other particle in the newParticles list
1047  for (BaseParticle *particle : newParticles) {
1048  if (particle->getId() == idOther) {
1049  otherParticle = particle;
1050  break;
1051  }
1052  }
1053  if (otherParticle == nullptr) {
1054  logger(WARN,
1055  "In Domain::processReceivedInteractionData: otherParticle (id %) is nullptr, the interaction data with pGhost (id %) is not copied. Two particles possibly moved into domain simultaneously. nt = %",
1056  identificationI, identificationP, getHandler()->getDPMBase()->getNumberOfTimeSteps());
1057  continue;
1058  }
1059  }
1060  //Add the interaction
1061  BaseInteraction* j = pGhost->getInteractionWith(otherParticle, timeStamp, &iH);
1062  if (j!= nullptr) j->setMPIInteraction(interactionDataReceive_[localIndex], l, false);
1063  }
1064  }
1065 }
virtual void hGridGetInteractingParticleList(BaseParticle *obj, std::vector< BaseParticle * > &list)
Creates a list of neighbour particles obtained from the hgrid.
Definition: DPMBase.h:936
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
BaseInteraction * getInteractionWith(BaseParticle *P, unsigned timeStamp, InteractionHandler *interactionHandler) override
Checks if particle is in interaction with given particle P, and if so, returns vector of pointer to t...
T * getObjectById(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:565
virtual BaseInteraction * getInteractionWith(BaseParticle *P, unsigned timeStamp, InteractionHandler *interactionHandler)=0
Returns the interaction between this object and a given BaseParticle.
Stores information about interactions between two interactable objects; often particles but could be ...
std::vector< void * > interactionDataReceive_
Container that keeps a void array of all the interaction data that is being received by this domain...
Definition: Domain.h:567
void getInteractionDetails(void *interactionData, unsigned int index, unsigned int &identificationP, unsigned int &identificationI, bool &isWallInteraction, unsigned &timeStamp)
reads the basic interaction details from an MPIInteractionDataArray
Container to store Interaction objects.
DomainHandler * getHandler() const
Gets the domainHandler.
Definition: Domain.cc:1549
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1339
Defines the basic properties that a interactable object can have.
virtual void setMPIInteraction(void *interactionDataArray, unsigned int index, bool resetPointers)
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
std::vector< unsigned > numNewInteractionsReceive_
Counter that keeps track of the number of interactions that are being received by this domain...
Definition: Domain.h:527
void Domain::processSentBoundaryParticles ( unsigned  index)

Bookkeep the newly send particles.

Each domain keeps a list of particles that have copies on other domains. The order of these lists is exactly the same order of the neighbour particle lists of the neighbour domain.

Parameters
[in]indexThe boundary index of the boundary list currently being treated

Definition at line 954 of file Domain.cc.

References boundaryParticleList_, and newBoundaryParticleList_.

Referenced by finaliseBoundaryDataTransmission().

955 {
956  for (BaseParticle* particle : newBoundaryParticleList_[index])
957  {
958  boundaryParticleList_[index].push_back(particle);
959  particle->setInMPIDomain(true);
960  }
961 }
std::vector< std::vector< BaseParticle * > > newBoundaryParticleList_
Array that queues particles that need to be transmitted.
Definition: Domain.h:502
std::vector< std::vector< BaseParticle * > > boundaryParticleList_
A list of boundary particles in the communication zone that are ghost particles on other domains...
Definition: Domain.h:492
void Domain::read ( std::istream &  is)
overridevirtual

This function does nothing.

Reads the object from a given istream.

Reads the object's id_ from the given istream

Parameters
[in,out]isistream the id_ is read from
Todo:
MX: why would this function be called?

Implements BaseObject.

Definition at line 186 of file Domain.cc.

References logger, and WARN.

187 {
188  logger(WARN, "[Domain::read] should not be called");
189  //BaseObject::read(is);
190 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void Domain::sendAndReceiveCount ( MercuryMPITag  tag,
unsigned countReceive,
unsigned countSend,
unsigned  localIndexNeighbour 
)

A symmetric communication between two domains exchanging a send/recieve count.

Before real data (i.e. particle data) can be transmitted to other processors, these receiving processors need to know how many data objects they are receiving. This function facilitates a symmetric send mechanism between two domains to communicate how much objects they get from eachother

Parameters
[in]tagA MercuryMPITag that indicates what type of count is being send
[out]countReceiveunsigned integer containing the receiving count
[in]countSendunsigned integer containing the sending count
[in]localIndexNeighbourthe local index of the domain with which the communication is being done

Definition at line 1090 of file Domain.cc.

References globalIndex_, MPIContainer::Instance(), localIndexToGlobalIndexTable_, localIndexToProcessorList_, logger, MAX_PROC, MPIContainer::receive(), and MPIContainer::send().

Referenced by prepareBoundaryDataTransmission().

1092  {
1093  int globalIndexNeighbour = localIndexToGlobalIndexTable_[localIndexNeighbour];
1094  int processor = localIndexToProcessorList_[localIndexNeighbour];
1095 
1096  //Create communication tags
1097  int tagReceive = globalIndexNeighbour * MAX_PROC + globalIndex_ * 10 + tag;
1098  int tagSend = globalIndex_ * MAX_PROC + globalIndexNeighbour * 10 + tag;
1099 
1100  logger.assert(tagSend > 0, "Send tag is wrong. Tag: %", tagSend);
1101  logger.assert(tagReceive > 0, "Receive tag is wrong. Tag: %", tagReceive);
1102  logger.assert(processor >= 0, "Processor is wrong. processor: %", processor);
1103 
1104  //Communicate the requests
1105  MPIContainer::Instance().receive(countReceive, processor, tagReceive);
1106  MPIContainer::Instance().send(countSend, processor, tagSend);
1107  }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::vector< int > localIndexToGlobalIndexTable_
look-up table to get the global index given a local domain index
Definition: Domain.h:470
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:213
std::vector< int > localIndexToProcessorList_
look-up table to get the processor of the domain given a local domain index
Definition: Domain.h:476
#define MAX_PROC
Definition: GeneralDefine.h:51
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:167
int globalIndex_
Global index of the domain in the mesh.
Definition: Domain.h:459
template<typename T >
void Domain::sendAndReceiveMPIData ( MercuryMPITag  tag,
MercuryMPIType  type,
T *  receiveData,
unsigned  receiveCount,
T *  sendData,
unsigned  sendCount,
unsigned  localIndexNeighbour 
)
inline

Function that sends transmissionData/positionData/velocityData to other processors.

This function is heavily templated on the type of data that can be send. All the types that are located in the MercuryMPIType enum class can be used to transmit data. Examples are MPIParticle and MPIParticlePosition data types

Parameters
[in]tagA MercuryMPITag that indicates what type of data is being send
[in]typeA MercuryMPIType that tells the MPI what MPI_Data structure to use
[out]receiveDataThe data that will be received by the current domain
[in]receiveCountThe number of items that are being received by the current domain
[in]sendDataThe data that will be send by the current domain
[in]sendCountThe number of items that are being send by the current domain
[in]localIndexNeighbourthe local index to the neighbouring domain

Definition at line 359 of file Domain.h.

References globalIndex_, MPIContainer::Instance(), localIndexToGlobalIndexTable_, localIndexToProcessorList_, MAX_PROC, MPIContainer::receive(), and MPIContainer::send().

Referenced by performBoundaryDataTransmission(), preparePositionAndVelocityUpdate(), and prepareVelocityUpdate().

362  {
363  int globalIndexNeighbour = localIndexToGlobalIndexTable_[localIndexNeighbour];
364  int processor = localIndexToProcessorList_[localIndexNeighbour];
365  int tagReceive = globalIndexNeighbour * MAX_PROC + globalIndex_ * 10 + tag;
366  int tagSend = globalIndex_ * MAX_PROC + globalIndexNeighbour * 10 + tag;
367 
368  //Communicate the requests
369  if (receiveCount != 0)
370  {
371  MPIContainer::Instance().receive(receiveData, type, receiveCount, processor, tagReceive);
372  }
373  if (sendCount != 0)
374  {
375  MPIContainer::Instance().send(sendData, type, sendCount, processor, tagSend);
376  }
377  }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
std::vector< int > localIndexToGlobalIndexTable_
look-up table to get the global index given a local domain index
Definition: Domain.h:470
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:213
std::vector< int > localIndexToProcessorList_
look-up table to get the processor of the domain given a local domain index
Definition: Domain.h:476
#define MAX_PROC
Definition: GeneralDefine.h:51
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:167
int globalIndex_
Global index of the domain in the mesh.
Definition: Domain.h:459
void Domain::setBounds ( std::vector< double >  domainMin,
std::vector< double >  domainMax,
bool  computeMiddle 
)

Sets the domain bounds.

This function sets the bound for the domain, it also computes the middle of the square domain, useful for mixed periodic/mpi particles.

Parameters
[in]domainMinMinimum values of the domain in x-,y-,z-direction
[in]domainMaxMaximum values of the domain in x-,y-,z-direction

Definition at line 268 of file Domain.cc.

References domainMax_, domainMin_, Vec3D::getComponent(), BaseHandler< T >::getDPMBase(), getHandler(), DPMBase::getMax(), DPMBase::getMin(), constants::i, constants::inf, middle_, and Vec3D::setComponent().

Referenced by DomainHandler::createDomains(), and DomainHandler::initialise().

269 {
270  domainMin_ = domainMin;
271  domainMax_ = domainMax;
272 
273  //Compute the middle of the closed domain
274  if (computeMiddle)
275  {
276  double minClosed;
277  double maxClosed;
278  for (int i = 0; i < 3; i++)
279  {
280  minClosed = domainMin_[i];
281  maxClosed = domainMax_[i];
282  if (domainMin_[i] == -constants::inf)
283  {
284  minClosed = getHandler()->getDPMBase()->getMin().getComponent(i);
285  }
286 
287  if (domainMax_[i] == constants::inf)
288  {
289  maxClosed = getHandler()->getDPMBase()->getMax().getComponent(i);
290  }
291 
292  middle_.setComponent(i, minClosed + (maxClosed - minClosed) / 2.0);
293  }
294  }
295 }
Vec3D getMin() const
Definition: DPMBase.h:623
Vec3D middle_
Middle of the closed domain.
Definition: Domain.h:453
std::vector< double > domainMin_
Minimum domain bounds in the x,y and z direction.
Definition: Domain.h:443
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
const Mdouble inf
Definition: GeneralDefine.h:44
void setComponent(int index, double val)
Sets the requested component of this Vec3D to the requested value.
Definition: Vector.cc:217
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Definition: Vector.cc:194
DomainHandler * getHandler() const
Gets the domainHandler.
Definition: Domain.cc:1549
Vec3D getMax() const
Definition: DPMBase.h:629
std::vector< double > domainMax_
Maximum domain bounds in the x,y and z direction.
Definition: Domain.h:448
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
void Domain::setGlobalMeshIndex ( std::vector< unsigned globalMeshIndex)

Sets the global mesh index of theh domain.

sets the global mesh index

global mesh index has the shape of (i,j,k)

Parameters
[in]globalMeshIndexthe mesh index vector i,j,k

Definition at line 365 of file Domain.cc.

References globalMeshIndex_.

366 {
367  globalMeshIndex_ = globalMeshIndex;
368 }
std::vector< unsigned > globalMeshIndex_
Vector containing the global mesh indices i,j,k.
Definition: Domain.h:464
void Domain::setHandler ( DomainHandler domainHandler)

Sets the domainHandler.

Sets the pointer to the DomainHandler the domain belongs to

Parameters
[in]domainHandlerpointer to the DomainHandler

Definition at line 337 of file Domain.cc.

References domainHandler_.

Referenced by DomainHandler::addObject(), DomainHandler::createDomains(), and DomainHandler::initialise().

338 {
339  domainHandler_ = domainHandler;
340 }
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
void Domain::setRange ( Direction  direction,
Mdouble  min,
Mdouble  max 
)

Sets the domain range in a given direction.

Sets the domain's range in a given direction.

Parameters
[in]directionDirection 0,1,2 corresponds to direction x,y,z respectively
[in]minMinimum domain bound
[in]maxMaximum domain bound

Definition at line 219 of file Domain.cc.

References domainMax_, domainMin_, ERROR, Vec3D::getComponent(), BaseHandler< T >::getDPMBase(), getHandler(), DPMBase::getMax(), DPMBase::getMin(), constants::inf, logger, middle_, Vec3D::X, XAXIS, Vec3D::Y, YAXIS, Vec3D::Z, and ZAXIS.

220 {
221  if (min > max)
222  {
223  logger(ERROR, "[MercuryMPI ERROR]: min is larger than max. (%,%)", min, max);
224  }
225 
226  double maxClosed;
227  double minClosed;
228  if (min == -constants::inf)
229  {
230  minClosed = getHandler()->getDPMBase()->getMin().getComponent(direction);
231  }
232 
233  if (max == constants::inf)
234  {
235  maxClosed = getHandler()->getDPMBase()->getMax().getComponent(direction);
236  }
237 
238 
239  switch (direction)
240  {
241  case Direction::XAXIS :
242  domainMin_[0] = min;
243  domainMax_[0] = max;
244  middle_.X = minClosed + (maxClosed - minClosed) / 2.0;
245  break;
246  case Direction::YAXIS :
247  domainMin_[1] = min;
248  domainMax_[1] = max;
249  middle_.Y = minClosed + (maxClosed - minClosed) / 2.0;
250  break;
251  case Direction::ZAXIS :
252  domainMin_[2] = min;
253  domainMax_[2] = max;
254  middle_.Z = minClosed + (maxClosed - minClosed) / 2.0;
255  break;
256  default :
257  logger(ERROR, "Direction is not a valid direction. (%)", direction);
258  break;
259  }
260 }
Mdouble X
the vector components
Definition: Vector.h:65
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Vec3D getMin() const
Definition: DPMBase.h:623
Vec3D middle_
Middle of the closed domain.
Definition: Domain.h:453
std::vector< double > domainMin_
Minimum domain bounds in the x,y and z direction.
Definition: Domain.h:443
const Mdouble inf
Definition: GeneralDefine.h:44
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Definition: Vector.cc:194
DomainHandler * getHandler() const
Gets the domainHandler.
Definition: Domain.cc:1549
Vec3D getMax() const
Definition: DPMBase.h:629
Mdouble Y
Definition: Vector.h:65
std::vector< double > domainMax_
Maximum domain bounds in the x,y and z direction.
Definition: Domain.h:448
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble Z
Definition: Vector.h:65
void Domain::setRank ( int  rank)

Sets the rank associated with the assigned processorID.

Sets the domain's rank, corresponding to a processorID.

Parameters
[in]rankInteger corresponding to a processorID

Definition at line 301 of file Domain.cc.

References rank_.

302 {
303  rank_ = rank;
304 }
int rank_
Rank of the domain which identifies to which processor it belongs.
Definition: Domain.h:572
void Domain::updateParticlePosition ( int  localIndex)

Updates the position of particles which are flagged as MPIParticles.

Manually updates the position of the particles, the displacement and the orientation It additionally updates the position of the particle in the hGrid

Parameters
[in]localIndexan index to the boundary being updated

Definition at line 1383 of file Domain.cc.

References boundaryParticleListNeighbour_, BaseHandler< T >::getDPMBase(), getHandler(), Vec3D::getLengthSquared(), DPMBase::hGridUpdateMove(), logger, and updatePositionDataReceive_.

Referenced by finalisePositionAndVelocityUpdate().

1384  {
1385  //process the updated information
1386  unsigned int index = 0;
1387  for (BaseParticle* particle : boundaryParticleListNeighbour_[localIndex])
1388  {
1389  logger.assert(particle->getId() == updatePositionDataReceive_[localIndex][index].id,
1390  "MPI particle lists are not in sync");
1391 
1392  //set position
1393  particle->setPreviousPosition(particle->getPosition());
1394  particle->setPosition(updatePositionDataReceive_[localIndex][index].position);
1395  particle->setOrientation(updatePositionDataReceive_[localIndex][index].orientation);
1396  if (std::is_base_of<MPILiquidFilmParticle,MPIParticle>())
1397  static_cast<LiquidFilmParticle*>(particle)->setLiquidVolume(updatePositionDataReceive_[localIndex][index].liquidVolume);
1398 
1399  //Update hGrid
1400  Vec3D displacement = particle->getPreviousPosition() - particle->getPosition();
1401  getHandler()->getDPMBase()->hGridUpdateMove(particle, displacement.getLengthSquared());
1402 
1403  index++;
1404  }
1405 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
DomainHandler * getHandler() const
Gets the domainHandler.
Definition: Domain.cc:1549
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
std::vector< std::vector< MPIParticlePosition > > updatePositionDataReceive_
Container that keeps a list of MPIParticlePositions that are being received by this domain...
Definition: Domain.h:547
virtual void hGridUpdateMove(BaseParticle *, Mdouble)
Definition: DPMBase.cc:1893
Definition: Vector.h:49
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
void Domain::updateParticles ( std::set< BaseParticle * > &  ghostParticlesToBeDeleted)

This step updates all communication lists and particles in the communication zone.

After all the mpi particles have received a position and velocity update, a check is required to see if the particle needs to be treated differently. Comments inside the code show all possible options. Note that when a particle needs to be deleted, it will not be deleted straight away, but added to a list to be deleted later. Additionally the location in the communication lists will not be emptied by assigning a nullptr to it. When all particles are considered this nullptrs are removed from the list, to ensure that the mirror list on another processor keeps the same order in particles. A) The particle moves from the Neighbour domain to the current domain B) The particle moves out of the communication zone, into the neighbouring domain C) The particle moves out of the communication zone, into the current domain D) The particle changes complexity: A special case where the particle required a re-evaluation in which boundary list it belongs

Parameters
[in]particleHandlerHandler that takes care of all particles in this domain

Definition at line 1279 of file Domain.cc.

References boundaryList_, boundaryParticleList_, boundaryParticleListNeighbour_, containsParticle(), domainHandler_, findNearbyBoundaries(), BaseParticle::getCommunicationComplexity(), BaseHandler< T >::getDPMBase(), BaseObject::getId(), BaseHandler< T >::getObject(), DPMBase::getTime(), globalIndex_, localIndexToGlobalIndexTable_, logger, BaseParticle::setCommunicationComplexity(), BaseParticle::setInMPIDomain(), BaseParticle::setMPIParticle(), and VERBOSE.

Referenced by finalisePositionAndVelocityUpdate().

1280  {
1281  int complexityNew;
1282  std::vector<int> boundaryIndex;
1283 
1284  //For all active boundaries
1285  for (int localIndex : boundaryList_)
1286  {
1287  //Step 1A: Remove the particles from the boundaryParticleList_ which require re-assignment
1288  //or have just moved away from the region
1289  for (int p = 0; p < boundaryParticleList_[localIndex].size(); p++)
1290  {
1291  BaseParticle* particle = boundaryParticleList_[localIndex][p];
1292  //Check if the particle is still in the domain, but not in the communication zone
1293  if (containsParticle(particle))
1294  {
1295  //check if the complexity has changed
1296  boundaryIndex = findNearbyBoundaries(particle);
1297  complexityNew = boundaryIndex[0] + 3 * boundaryIndex[1] + 9 * boundaryIndex[2] + 13;
1298  if (particle->getCommunicationComplexity() != complexityNew)
1299  {
1300  logger(VERBOSE, "time: % | global index: % in list % | particle % | CURRENT DOMAIN - CHANGES "
1301  "COMPLEXITY", domainHandler_->getDPMBase()->getTime(), globalIndex_,
1302  localIndexToGlobalIndexTable_[localIndex], particle->getId());
1303  //Flag the particle that it no longer participates in the communication layer
1304  //so it can be reintroduced in the transmission step
1305  particle->setMPIParticle(false);
1306  particle->setInMPIDomain(false);
1307  particle->setCommunicationComplexity(0);
1308  boundaryParticleList_[localIndex][p] = nullptr;
1309  }
1310  }
1311  else
1312  {
1313  logger(VERBOSE, "time: % | global index: % in list % | particle % | CURRENT DOMAIN - TO NEIGHBOURING "
1314  "DOMAIN", domainHandler_->getDPMBase()->getTime(), globalIndex_,
1315  localIndexToGlobalIndexTable_[localIndex], particle->getId());
1316 
1317  ghostParticlesToBeDeleted.insert(particle);
1318  boundaryParticleList_[localIndex][p] = nullptr;
1319  }
1320  }
1321 
1322  //Step 1B: Remove the particles from the boundaryParticleListNeightbour_ which require re-assignment
1323  //or have just moved away from the region
1324  for (int p = 0; p < boundaryParticleListNeighbour_[localIndex].size(); p++)
1325  {
1326  BaseParticle* particle = boundaryParticleListNeighbour_[localIndex][p];
1327  //Check if the particle moved out of the neighbour domain
1328  if (!(domainHandler_->getObject(localIndexToGlobalIndexTable_[localIndex])->containsParticle(particle)))
1329  {
1330  //The particle has moved to this domain
1331  if (containsParticle(particle))
1332  {
1333  logger(VERBOSE,
1334  "time: % | global index: % in list % | particle % | NEIGHBOURING DOMAIN - TO CURRENT DOMAIN",
1336  localIndexToGlobalIndexTable_[localIndex], particle->getId());
1337 
1338  //Flag the particle as not yet communicated
1339  particle->setMPIParticle(false);
1340  particle->setInMPIDomain(false);
1341  particle->setCommunicationComplexity(0);
1342  boundaryParticleListNeighbour_[localIndex][p] = nullptr;
1343  }
1344  //The particle has moved to a different domain
1345  else
1346  {
1347  logger(VERBOSE,
1348  "time: % | global index: % in list % | particle % | NEIGBOURING DOMAIN - TO OTHER DOMAIN",
1350  localIndexToGlobalIndexTable_[localIndex], particle->getId());
1351  //Cruelly destroy the particle without any mercy.
1352  ghostParticlesToBeDeleted.insert(particle);
1353  boundaryParticleListNeighbour_[localIndex][p] = nullptr;
1354  }
1355  }
1356  else
1357  {
1358  //check if the complexity has changed
1359  boundaryIndex = domainHandler_->getObject(
1360  localIndexToGlobalIndexTable_[localIndex])->findNearbyBoundaries(particle);
1361  complexityNew = boundaryIndex[0] + 3 * boundaryIndex[1] + 9 * boundaryIndex[2] + 13;
1362  if (particle->getCommunicationComplexity() != complexityNew)
1363  {
1364  logger(VERBOSE,
1365  "time: % | global index: % in list % | particle % | NEIGHBOURING DOMAIN - CHANGES COMPLEXITY",
1367  localIndexToGlobalIndexTable_[localIndex], particle->getId());
1368  //Cruelly destroy the particle without any mercy.
1369  ghostParticlesToBeDeleted.insert(particle);
1370  boundaryParticleListNeighbour_[localIndex][p] = nullptr;
1371  }
1372  }
1373  }
1374  }
1375  }
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
void setInMPIDomain(bool flag)
Flags the status of the particle if wether it is in the communication zone or not.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::vector< int > findNearbyBoundaries(BaseParticle *particle, Mdouble offset=0)
This function finds if a given particle is close to a given boundary.
Definition: Domain.cc:549
std::vector< int > localIndexToGlobalIndexTable_
look-up table to get the global index given a local domain index
Definition: Domain.h:470
void setCommunicationComplexity(unsigned complexity)
Set the communication complexity of the particle.
bool containsParticle(BaseParticle *particle, Mdouble offset=0.0)
Check to see if a given particle is within the current domain.
Definition: Domain.cc:400
std::vector< int > boundaryList_
A list of indices of all the active boundaries.
Definition: Domain.h:487
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
DomainHandler * domainHandler_
Pointer to the domain's DomainHandler container.
Definition: Domain.h:438
unsigned getCommunicationComplexity()
Obtains the communication complexity of the particle.
void setMPIParticle(bool flag)
Flags the mpi particle status.
int globalIndex_
Global index of the domain in the mesh.
Definition: Domain.h:459
std::vector< std::vector< BaseParticle * > > boundaryParticleList_
A list of boundary particles in the communication zone that are ghost particles on other domains...
Definition: Domain.h:492
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:797
void Domain::updateParticleVelocity ( int  localIndex)

Updates the velocity of particles which are flagged as MPIParticles.

Updates the translation but also the angular velocity

Parameters
[in]localIndexan index to the boundary being updated

Definition at line 1412 of file Domain.cc.

References boundaryParticleListNeighbour_, and updateVelocityDataReceive_.

Referenced by finalisePositionAndVelocityUpdate(), and finaliseVelocityUpdate().

1413 {
1414  //process the updated information
1415  unsigned int index = 0;
1416  for (BaseParticle* particle: boundaryParticleListNeighbour_[localIndex])
1417  {
1418  //set velocity
1419  particle->setVelocity(updateVelocityDataReceive_[localIndex][index].velocity);
1420  particle->setAngularVelocity(updateVelocityDataReceive_[localIndex][index].angularVelocity);
1421  index++;
1422  }
1423 }
std::vector< std::vector< MPIParticleVelocity > > updateVelocityDataReceive_
Container that keeps a list of MPIParticleVelocities that are being received by this domain...
Definition: Domain.h:557
std::vector< std::vector< BaseParticle * > > boundaryParticleListNeighbour_
a list of ghost particles on the current domain, which are real on the neighbour domain ...
Definition: Domain.h:497
void Domain::updateStatus ( std::set< BaseParticle * > &  ghostParticlesToBeDeleted)

Updates particles that are not in the current domain and communicates newly added particles.

First the newly positions of the ghost particles are communicated, based on the new positions these particles will be updated accordingly. Secondly a new sweep through all particles is performed to see if we need to add any particles to the list which have moved into the communication zone. Particles that need to be removed from the simulation are stored in a vector and will be destroyed at a later point in the code.

Parameters
[in,out]ghostParticlesToBeDeletedA list of particles which will be deleted afterwards

Definition at line 1604 of file Domain.cc.

References finalisePositionAndVelocityUpdate(), MPIContainer::Instance(), preparePositionAndVelocityUpdate(), and MPIContainer::sync().

Referenced by DomainHandler::updateStatus().

1605 {
1606  //Collect new positions and velocities and send them to the other domains
1609 
1610  //Receive the new positions and velocities from other domains
1611  //and update the mpi flagged particles accordingly. removes and switched particles in the lists
1612  finalisePositionAndVelocityUpdate(ghostParticlesToBeDeleted);
1614 }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
void preparePositionAndVelocityUpdate()
Function that sends particle position and velocity data for ghost particles to other processors...
Definition: Domain.cc:1431
void finalisePositionAndVelocityUpdate(std::set< BaseParticle * > &ghostParticlesToBeDeleted)
processes position and velocity data for ghost particles
Definition: Domain.cc:1472
void sync()
Process all pending asynchronous communication requests before continuing.
Definition: MpiContainer.h:148
void Domain::updateVelocity ( )

Updates MPI particle velocity at the half-time step.

: not in use

Definition at line 1619 of file Domain.cc.

References finaliseVelocityUpdate(), MPIContainer::Instance(), prepareVelocityUpdate(), and MPIContainer::sync().

Referenced by DomainHandler::updateVelocity().

1620 {
1621  //collect new velocity data and send
1624 
1625  //process the received data
1628 }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
void finaliseVelocityUpdate()
Processes particle velocity data for ghost particles.
Definition: Domain.cc:1528
void sync()
Process all pending asynchronous communication requests before continuing.
Definition: MpiContainer.h:148
void prepareVelocityUpdate()
Function that sends particle velocity data for ghost particles.
Definition: Domain.cc:1500
void Domain::write ( std::ostream &  os) const
overridevirtual

This function does nothing.

Adds the object's id_ to the given ostream

Parameters
[in]osostream the id_ is added to
Todo:
MX: why would this function be called?

Implements BaseObject.

Definition at line 197 of file Domain.cc.

References logger, and WARN.

198 {
199  logger(WARN, "[Domain::write] should not be called");
200  //BaseObject::write(os);
201 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Data Documentation

std::vector<bool> Domain::activeBoundaryList_
private

A list of flags corresponding to an inactive or active boundary.

Definition at line 481 of file Domain.h.

Referenced by constructor(), disableBoundaries(), disableBoundary(), Domain(), and getActiveBoundaryList().

std::vector<std::vector<MPIParticle> > Domain::boundaryParticleDataReceive_
private

Container that keeps a list of MPIParticles that are being received by this domain.

Definition at line 537 of file Domain.h.

Referenced by constructor(), Domain(), finaliseBoundaryDataTransmission(), performBoundaryDataTransmission(), and processReceivedBoundaryParticleData().

std::vector<std::vector<MPIParticle> > Domain::boundaryParticleDataSend_
private

Container that keeps a list of MPIParticles that are being send to other domains.

Definition at line 532 of file Domain.h.

Referenced by collectBoundaryParticleData(), constructor(), Domain(), finaliseBoundaryDataTransmission(), and performBoundaryDataTransmission().

std::vector<std::vector<BaseParticle*> > Domain::boundaryParticleList_
private

A list of boundary particles in the communication zone that are ghost particles on other domains.

Definition at line 492 of file Domain.h.

Referenced by cleanCommunicationLists(), constructor(), Domain(), flushParticles(), preparePositionAndVelocityUpdate(), prepareVelocityUpdate(), processSentBoundaryParticles(), and updateParticles().

std::vector<std::vector<BaseParticle*> > Domain::boundaryParticleListNeighbour_
private
DomainHandler* Domain::domainHandler_
private
std::vector<double> Domain::domainMax_
private

Maximum domain bounds in the x,y and z direction.

Definition at line 448 of file Domain.h.

Referenced by constructor(), containsParticle(), Domain(), findNearbyBoundaries(), getDomainMax(), setBounds(), and setRange().

std::vector<double> Domain::domainMin_
private

Minimum domain bounds in the x,y and z direction.

Definition at line 443 of file Domain.h.

Referenced by constructor(), containsParticle(), Domain(), findNearbyBoundaries(), getDomainMin(), setBounds(), and setRange().

int Domain::globalIndex_
private

Global index of the domain in the mesh.

Note
for a standard decomposition this compares straight to the rank of the processor

Definition at line 459 of file Domain.h.

Referenced by createLookUpTable(), getGlobalIndex(), sendAndReceiveCount(), sendAndReceiveMPIData(), and updateParticles().

std::vector<unsigned> Domain::globalMeshIndex_
private

Vector containing the global mesh indices i,j,k.

Definition at line 464 of file Domain.h.

Referenced by createLookUpTable(), disableBoundaries(), Domain(), getGlobalMeshIndex(), and setGlobalMeshIndex().

std::vector<void*> Domain::interactionDataReceive_
private

Container that keeps a void array of all the interaction data that is being received by this domain, interpretation is done by the interaction handler.

Definition at line 567 of file Domain.h.

Referenced by constructor(), Domain(), finaliseBoundaryDataTransmission(), performBoundaryDataTransmission(), and processReceivedInteractionData().

std::vector<void*> Domain::interactionDataSend_
private

Container that keeps a void array of all the interaction data that are being send to other domains, interpretation is done by the interaction handler.

Definition at line 562 of file Domain.h.

Referenced by collectInteractionData(), constructor(), Domain(), finaliseBoundaryDataTransmission(), and performBoundaryDataTransmission().

std::vector<int> Domain::localIndexToGlobalIndexTable_
private

look-up table to get the global index given a local domain index

Todo:
TW should this be unsigned int

Definition at line 470 of file Domain.h.

Referenced by constructor(), createLookUpTable(), Domain(), sendAndReceiveCount(), sendAndReceiveMPIData(), and updateParticles().

std::vector<int> Domain::localIndexToProcessorList_
private

look-up table to get the processor of the domain given a local domain index

Todo:
TW should this be unsigned int

Definition at line 476 of file Domain.h.

Referenced by constructor(), createLookUpTable(), Domain(), sendAndReceiveCount(), and sendAndReceiveMPIData().

Vec3D Domain::middle_
private

Middle of the closed domain.

Definition at line 453 of file Domain.h.

Referenced by Domain(), getMiddle(), setBounds(), and setRange().

std::vector<std::vector<BaseParticle*> > Domain::newBoundaryParticleList_
private
std::vector<std::vector<BaseInteraction*> > Domain::newInteractionList_
private

Array that queues interactions that need to be transmitted.

Definition at line 507 of file Domain.h.

Referenced by collectInteractionData(), constructor(), Domain(), finaliseBoundaryDataTransmission(), findNewMPIInteractions(), and prepareBoundaryDataTransmission().

std::vector<unsigned> Domain::numberOfParticlesReceive_
private

Counter that keeps track of the number of particles that are being received by this domain.

Definition at line 517 of file Domain.h.

Referenced by constructor(), Domain(), finaliseBoundaryDataTransmission(), performBoundaryDataTransmission(), prepareBoundaryDataTransmission(), preparePositionAndVelocityUpdate(), prepareVelocityUpdate(), and processReceivedBoundaryParticleData().

std::vector<unsigned> Domain::numberOfParticlesSend_
private

Counter that keeps track of the number of particles that are being send to other domains.

Definition at line 512 of file Domain.h.

Referenced by constructor(), Domain(), finaliseBoundaryDataTransmission(), performBoundaryDataTransmission(), prepareBoundaryDataTransmission(), preparePositionAndVelocityUpdate(), and prepareVelocityUpdate().

std::vector<unsigned> Domain::numNewInteractionsReceive_
private

Counter that keeps track of the number of interactions that are being received by this domain.

Definition at line 527 of file Domain.h.

Referenced by constructor(), Domain(), finaliseBoundaryDataTransmission(), performBoundaryDataTransmission(), prepareBoundaryDataTransmission(), and processReceivedInteractionData().

std::vector<unsigned> Domain::numNewInteractionsSend_
private

Counter that keeps track of the number of interactions that are being send to other domains.

Definition at line 522 of file Domain.h.

Referenced by constructor(), Domain(), finaliseBoundaryDataTransmission(), performBoundaryDataTransmission(), and prepareBoundaryDataTransmission().

int Domain::rank_
private

Rank of the domain which identifies to which processor it belongs.

Definition at line 572 of file Domain.h.

Referenced by constructor(), createLookUpTable(), Domain(), getRank(), and setRank().

std::vector<std::vector<MPIParticlePosition> > Domain::updatePositionDataReceive_
private

Container that keeps a list of MPIParticlePositions that are being received by this domain.

Definition at line 547 of file Domain.h.

Referenced by constructor(), Domain(), finalisePositionAndVelocityUpdate(), preparePositionAndVelocityUpdate(), and updateParticlePosition().

std::vector<std::vector<MPIParticlePosition> > Domain::updatePositionDataSend_
private

Container that keeps a list of MPIParticlePositions that are being send to other domains.

Definition at line 542 of file Domain.h.

Referenced by constructor(), Domain(), finalisePositionAndVelocityUpdate(), and preparePositionAndVelocityUpdate().

std::vector<std::vector<MPIParticleVelocity> > Domain::updateVelocityDataReceive_
private

Container that keeps a list of MPIParticleVelocities that are being received by this domain.

Definition at line 557 of file Domain.h.

Referenced by constructor(), Domain(), finalisePositionAndVelocityUpdate(), finaliseVelocityUpdate(), preparePositionAndVelocityUpdate(), prepareVelocityUpdate(), and updateParticleVelocity().

std::vector<std::vector<MPIParticleVelocity> > Domain::updateVelocityDataSend_
private

Container that keeps a list of MPIParticleVelocities that are being send to other domains.

Definition at line 552 of file Domain.h.

Referenced by constructor(), Domain(), finalisePositionAndVelocityUpdate(), finaliseVelocityUpdate(), preparePositionAndVelocityUpdate(), and prepareVelocityUpdate().


The documentation for this class was generated from the following files: