MpiContainer.h File Reference
#include <cstddef>
#include <functional>
#include <vector>
#include "Math/Vector.h"

Go to the source code of this file.

Classes

class  MPIContainer
 This class contains all information and functions required for communication between processors. More...
 

Namespaces

 Detail
 

Macros

#define MERCURYDPM_ASSERTS   true
 

Enumerations

enum  MercuryMPIType {
  PARTICLE = 0 , POSITION = 1 , VELOCITY = 2 , FORCE = 3 ,
  INTERACTION = 4 , SUPERQUADRIC = 5
}
 An enum that indicates what type of data is being send over MPI. More...
 
enum  MercuryMPITag {
  PARTICLE_COUNT = 0 , PARTICLE_DATA = 1 , POSITION_DATA = 2 , PERIODIC_POSITION_DATA = 3 ,
  VELOCITY_DATA = 4 , INTERACTION_COUNT = 5 , INTERACTION_DATA = 6 , PERIODIC_COMPLEXITY = 7 ,
  PARTICLE_INDEX = 8 , SUPERQUADRIC_DATA = 9
}
 An enum that facilitates the creation of unique communication tags in the parallel code. More...
 

Functions

void initialiseMPI ()
 Inialises the MPI library. More...
 

Detailed Description

Class MPIContainer

Macro Definition Documentation

◆ MERCURYDPM_ASSERTS

#define MERCURYDPM_ASSERTS   true

Enumeration Type Documentation

◆ MercuryMPITag

An enum that facilitates the creation of unique communication tags in the parallel code.

The MercuryMPITag is the last digit of a communication tag in the parallel code. This ensures that when various data types are queued simultationously, there is no communication confusion. Additionally this is a useful feature for developers so they can trace back what message was being send if something went wrong.

Enumerator
PARTICLE_COUNT 
PARTICLE_DATA 
POSITION_DATA 
PERIODIC_POSITION_DATA 
VELOCITY_DATA 
INTERACTION_COUNT 
INTERACTION_DATA 
PERIODIC_COMPLEXITY 
PARTICLE_INDEX 
SUPERQUADRIC_DATA 
77 {
78  PARTICLE_COUNT = 0,
79  PARTICLE_DATA = 1,
80  POSITION_DATA = 2,
82  VELOCITY_DATA = 4,
84  INTERACTION_DATA = 6,
86  PARTICLE_INDEX = 8,
88 };
@ SUPERQUADRIC_DATA
Definition: MpiContainer.h:87
@ INTERACTION_DATA
Definition: MpiContainer.h:84
@ VELOCITY_DATA
Definition: MpiContainer.h:82
@ INTERACTION_COUNT
Definition: MpiContainer.h:83
@ PARTICLE_INDEX
Definition: MpiContainer.h:86
@ PERIODIC_POSITION_DATA
Definition: MpiContainer.h:81
@ PARTICLE_COUNT
Definition: MpiContainer.h:78
@ POSITION_DATA
Definition: MpiContainer.h:80
@ PARTICLE_DATA
Definition: MpiContainer.h:79
@ PERIODIC_COMPLEXITY
Definition: MpiContainer.h:85

◆ MercuryMPIType

An enum that indicates what type of data is being send over MPI.

MPI requires knowledge on the memory lay out of a data object that is being send. Various types of data are being send in the parallel code, i.e. a whole particle or only the position. This enum indicates what type is being send

Enumerator
PARTICLE 
POSITION 
VELOCITY 
FORCE 
INTERACTION 
SUPERQUADRIC 
66 {
67  PARTICLE = 0, POSITION = 1, VELOCITY = 2, FORCE = 3, INTERACTION = 4, SUPERQUADRIC = 5
68 };
@ VELOCITY
Definition: MpiContainer.h:67
@ FORCE
Definition: MpiContainer.h:67
@ SUPERQUADRIC
Definition: MpiContainer.h:67
@ INTERACTION
Definition: MpiContainer.h:67
@ PARTICLE
Definition: MpiContainer.h:67
@ POSITION
Definition: MpiContainer.h:67

Function Documentation

◆ initialiseMPI()

void initialiseMPI ( )

Inialises the MPI library.

138 {
139 #ifdef MERCURYDPM_USE_MPI
140  //Check if MPI is already initialised
141  int Mpi_init_flag = 0;
142  MPI_Initialized(&Mpi_init_flag);
143  if(!Mpi_init_flag)
144  {
145  MPI_Init(NULL,NULL);
146  MPIContainer& communicator = MPIContainer::Instance();
147  if (PROCESSOR_ID == 0)
148  {
149  std::cout << "MPI has been initialised" << std::endl;
150  }
151 
152  //MPI should be finalised at the end of any program.
153  std::atexit([]()
154  {
155  MPIContainer& communicator = MPIContainer::Instance();
156  communicator.deleteMercuryMPITypes();
157  MPI_Finalize();
158  if (PROCESSOR_ID == 0)
159  {
160  std::cout << "MPI has been finalised" << std::endl;
161  }
162  });
163  }
164 #endif
165 }
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
This class contains all information and functions required for communication between processors.
Definition: MpiContainer.h:130
void deleteMercuryMPITypes()
Deletes the MercuryMPITypes.
Definition: MpiContainer.h:578
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134

References MPIContainer::deleteMercuryMPITypes(), MPIContainer::Instance(), and PROCESSOR_ID.

Referenced by DPMBase::constructor(), printError(), printFatalError(), printInfo(), and printWarn().