-
Notifications
You must be signed in to change notification settings - Fork 0
/
Communicator.h
62 lines (50 loc) · 1.88 KB
/
Communicator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _COMMUNICATOR_H_
#define _COMMUNICATOR_H_
// This class implements the Grid-type Domain Decomposition Parallelization of General Molecular Dynamics and Monte Carlo Simulations
//
// 2017-11-06
#include <vector>
#include <memory>
#include "Atom.h"
#include "Type.h"
#include "InputManager.h"
namespace Hamilton_Space {
struct Swap
{
int sendToProc; // For each communication, the IDs of proc I will send my atoms to
int recvFromProc; // For each communication, the IDs of proc I will receive atoms from
int sendNum;
int recvNum;
int pbcFlags; // Whether any PBC is enforced on this swap
// It is a bit flag
int dim; // Dimension of this swap
HS_float slablo;
HS_float slabhi;
HS_float* bufferSend;
HS_float* bufferRecv;
int* sendList;
int recvStartIndex;
};
class Communicator
{
public:
Communicator(std::shared_ptr<InputManager> input);
~Communicator();
void setup(HS_float, std::shared_ptr<class Atom>);
void generateGhosts(std::shared_ptr<class Atom>); // Generate the ghost lists after building neighborlist
void exchangeAtoms(std::shared_ptr<class Atom>); // Exchange Atoms to neighbors after building neighborlist
void communicateGhosts(std::shared_ptr<class Atom>); // communicate ghost list information each step
void reverseCommunicateGhosts(std::shared_ptr<class Atom>); // communicate ghost atom forces each step if using Newton 3rd
private:
std::vector<int> processorGrid;
int rank;
int numSwaps; // Total number of ghost atoms communication swap
std::vector<Swap> swap; // Swap data structure
// The Map to store neighbor Proc IDs, this is used for exchange only
std::vector<std::vector<int> > neighbor;
// The buffer for atom exchange
HS_float* bufferExchangeSend;
HS_float* bufferExchangeRecv;
};
}
#endif