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 
56 {
57  PARTICLE_COUNT = 0,
58  PARTICLE_DATA = 1,
59  POSITION_DATA = 2,
61  VELOCITY_DATA = 4,
63  INTERACTION_DATA = 6,
65  PARTICLE_INDEX = 8,
67 };
@ SUPERQUADRIC_DATA
Definition: MpiContainer.h:66
@ INTERACTION_DATA
Definition: MpiContainer.h:63
@ VELOCITY_DATA
Definition: MpiContainer.h:61
@ INTERACTION_COUNT
Definition: MpiContainer.h:62
@ PARTICLE_INDEX
Definition: MpiContainer.h:65
@ PERIODIC_POSITION_DATA
Definition: MpiContainer.h:60
@ PARTICLE_COUNT
Definition: MpiContainer.h:57
@ POSITION_DATA
Definition: MpiContainer.h:59
@ PARTICLE_DATA
Definition: MpiContainer.h:58
@ PERIODIC_COMPLEXITY
Definition: MpiContainer.h:64

◆ 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 
45 {
46  PARTICLE = 0, POSITION = 1, VELOCITY = 2, FORCE = 3, INTERACTION = 4, SUPERQUADRIC = 5
47 };
@ VELOCITY
Definition: MpiContainer.h:46
@ FORCE
Definition: MpiContainer.h:46
@ SUPERQUADRIC
Definition: MpiContainer.h:46
@ INTERACTION
Definition: MpiContainer.h:46
@ PARTICLE
Definition: MpiContainer.h:46
@ POSITION
Definition: MpiContainer.h:46

Function Documentation

◆ initialiseMPI()

void initialiseMPI ( )

Inialises the MPI library.

117 {
118 #ifdef MERCURYDPM_USE_MPI
119  //Check if MPI is already initialised
120  int Mpi_init_flag = 0;
121  MPI_Initialized(&Mpi_init_flag);
122  if(!Mpi_init_flag)
123  {
124  MPI_Init(NULL,NULL);
125  MPIContainer& communicator = MPIContainer::Instance();
126  if (PROCESSOR_ID == 0)
127  {
128  std::cout << "MPI has been initialised" << std::endl;
129  }
130 
131  //MPI should be finalised at the end of any program.
132  std::atexit([]()
133  {
134  MPIContainer& communicator = MPIContainer::Instance();
135  communicator.deleteMercuryMPITypes();
136  MPI_Finalize();
137  if (PROCESSOR_ID == 0)
138  {
139  std::cout << "MPI has been finalised" << std::endl;
140  }
141  });
142  }
143 #endif
144 }
#define PROCESSOR_ID
Definition: GeneralDefine.h:42
This class contains all information and functions required for communication between processors.
Definition: MpiContainer.h:109
void deleteMercuryMPITypes()
Deletes the MercuryMPITypes.
Definition: MpiContainer.h:557
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:113

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

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