Emdee
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
processor_mpi.h
Go to the documentation of this file.
1 #ifndef PROCESSOR_H
2 #define PROCESSOR_H
3 
4 #include <range.h>
5 #ifdef USE_MPI
6 #include <boost/mpi.hpp>
7 namespace mpi = boost::mpi;
8 #endif
9 #include <vector>
10 #include <armadillo>
11 using namespace std;
12 using namespace arma;
13 
14 class MoleculeSystem;
15 class MoleculeSystemCell;
16 class Atom;
17 
19 public:
21 
22  vector<MoleculeSystemCell*> cells;
23 // vector<MoleculeSystemCell*> cellsToReceive;
24  irowvec direction;
25  irowvec coordinates;
26  int rank;
27 };
28 
29 class Processor
30 {
31 public:
32  Processor(MoleculeSystem* moleculeSystem);
33 
34  void setupProcessors();
35 
36  int rank();
37  void communicateAtoms();
38 
39  const vector<MoleculeSystemCell *> &localCells() const;
40  const vector<MoleculeSystemCell *> &localAndGhostCells() const;
41  bool shouldSendFirst(const irowvec &direction);
42  int nAtoms();
43  int nProcessors();
44  void clearForcesInNeighborCells();
45 protected:
46 
47  void receiveAtomsFromNeighbor(const ProcessorNeighbor &neighbor);
48  void sendAtomsToNeighbor(const ProcessorNeighbor &neighbor);
49 
51 
52 #ifdef USE_MPI
53  mpi::communicator world;
54  mpi::timer m_communicationTimer;
55  mpi::timer pureCommunicationTimer;
56 #endif
57 
59 
63 
67 
71 
72  vector<MoleculeSystemCell*> m_localCells;
73  vector<MoleculeSystemCell*> m_localAndGhostCells;
74 
77 
78  vector<ProcessorNeighbor> m_sendNeighbors;
79  vector<ProcessorNeighbor> m_receiveNeighbors;
80 
81  vector<ProcessorNeighbor> forceSendNeighbors;
82  vector<ProcessorNeighbor> forceReceiveNeighbors;
83 
84  vector<irowvec> m_directions;
85  vector<irowvec> forceDirections;
86 };
87 
88 inline const vector<MoleculeSystemCell *> &Processor::localCells() const {
89  return m_localCells;
90 }
91 
92 inline const vector<MoleculeSystemCell *> &Processor::localAndGhostCells() const
93 {
94  return m_localAndGhostCells;
95 }
96 
97 #endif // PROCESSOR_H