Merge branch 'charm' of charmgit:charm into charm
[charm.git] / examples / charm++ / Molecular / cell.h
1 /*
2  University of Illinois at Urbana-Champaign
3  Department of Computer Science
4  Parallel Programming Lab
5  2008
6 */
7
8 #ifndef __CELL_H__
9 #define __CELL_H__
10
11 #include "common.h"
12
13 // Class representing a cell in the grid. We consider each cell as a square of LxL units
14 class Cell : public CBase_Cell {
15   private:
16     CkVec<Particle> particles;
17     CkVec<Particle> incomingParticles;
18     int forceCount; // to count the returns from interactions
19     int stepCount;  // to count the number of steps, and decide when to stop
20                 int updateCount;
21                 bool updateFlag;
22                 bool incomingFlag;
23
24                 void updateProperties();  // updates properties after receiving forces from interactions
25                 void checkNextStep();             // checks whether to continue with next step
26                 void print();                                             // prints all its particles
27
28   public:
29     Cell();
30     Cell(CkMigrateMessage *msg);
31     ~Cell();
32
33     void start();
34     void updateParticles(CkVec<Particle>&);
35     void updateForces(CkVec<Particle>&);
36     void limitVelocity(Particle&);
37     Particle& wrapAround(Particle &);
38     void stepDone();
39     void requestNextFrame(liveVizRequestMsg *m);
40 };
41
42 // Class representing the interaction agents between a couple of cells
43 class Interaction : public CBase_Interaction {
44   private:
45     int cellCount;  // to count the number of interact() calls
46     CkVec<Particle> bufferedParticles;
47     int bufferedX;
48                 int bufferedY;
49
50                 void interact(CkVec<Particle> &first, CkVec<Particle> &second);
51                 void interact(Particle &first, Particle &second);
52
53   public:
54     Interaction();
55     Interaction(CkMigrateMessage *msg);
56
57     void interact(CkVec<Particle> particles, int i, int j);
58
59
60 };
61
62 #endif