MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 MERCURY_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

Definition in file MpiContainer.h.

Macro Definition Documentation

#define MERCURY_ASSERTS   true

Definition at line 52 of file MpiContainer.h.

Enumeration Type Documentation

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 

Definition at line 76 of file MpiContainer.h.

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 

Definition at line 65 of file MpiContainer.h.

Function Documentation

void initialiseMPI ( )

Inialises the MPI library.

Definition at line 133 of file MpiContainer.cc.

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

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

134 {
135 #ifdef MERCURY_USE_MPI
136  //Check if MPI is already initialised
137  if (!MPI::Is_initialized())
138  {
139  MPI::Init();
140  MPIContainer& communicator = MPIContainer::Instance();
141  if (PROCESSOR_ID == 0)
142  {
143  std::cout << "MPI has been initialised" << std::endl;
144  }
145 
146  //MPI should be finalised at the end of any program.
147  std::atexit([]()
148  {
149  MPIContainer& communicator = MPIContainer::Instance();
150  communicator.deleteMercuryMPITypes();
151  MPI::Finalize();
152  if (PROCESSOR_ID == 0)
153  {
154  std::cout << "MPI has been finalised" << std::endl;
155  }
156  });
157  }
158 #endif
159 }
This class contains all information and functions required for communication between processors...
Definition: MpiContainer.h:125
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
void deleteMercuryMPITypes()
Deletes the MercuryMPITypes.
Definition: MpiContainer.h:565