-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPatch.h
138 lines (118 loc) · 2.9 KB
/
Patch.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef __PATCH_H__
#define __PATCH_H__
extern /*readonly*/ int numNbrs;
class loc{
public:
BigReal x;
BigReal y;
BigReal z;
void pup(PUP::er &p){
p|x; p|y; p|z;
}
};
class partData{
public:
loc coord;
BigReal charge;
void pup(PUP::er &p){
p|coord; p|charge;
}
};
class ParticleDataMsg : public CkMcastBaseMsg, public CMessage_ParticleDataMsg {
public:
partData* part;
int lengthAll;
int x;
int y;
int z;
bool updateList;
bool deleteList;
bool doAtSync;
bool lbOn;
void pup(PUP::er &p){
CMessage_ParticleDataMsg::pup(p);
p | lengthAll;
p | x; p | y; p | z;
p | updateList;
p | deleteList;
p | doAtSync;
p | lbOn;
if (p.isUnpacking()){
part = new partData[lengthAll];
}
PUParray(p, part, lengthAll);
}
};
/** \class Patch
* Class representing a cell in the grid.
* We consider each cell as a square of LxL units
*/
class Patch : public CBase_Patch {
private:
CkVec<Particle> particles;
CkVec<Particle> incomingParticles;
int forceCount; // to count the returns from interactions
int stepCount; // to count the number of steps, and decide when to stop
int updateCount;
int myNumParts;
bool updateFlag;
bool incomingFlag;
bool pause;
int **computesList;
int resumeCount;
double loadTime;
int inbrs;
void migrateToPatch(Particle p, int &px, int &py, int &pz);
void updateProperties(); // updates properties after receiving forces from computes
void applyForces();
void limitVelocity(Particle &p);
Particle& wrapAround(Particle &p);
void print(); // prints all its particles
CProxySection_Compute mCastSecProxy;
public:
Patch();
Patch(CkMigrateMessage *msg);
~Patch();
void start();
void createComputes();
void createSection();
void localCreateSection();
void receiveParticles(CkVec<Particle> &);
void reduceForces(CkReductionMsg *msg);
void ResumeFromSync();
void resume();
void ftresume();
void receiveForces(ParticleForceMsg *updates);
void checkNextStep(); // checks whether to continue with next step
void pup(PUP::er &p){
CBase_Patch::pup(p);
p | particles;
p | incomingParticles;
p | forceCount;
p | stepCount;
p | updateCount;
p | myNumParts;
p | updateFlag;
p | incomingFlag;
p | pause;
p | resumeCount;
p | loadTime;
p | inbrs;
if (p.isUnpacking()){
computesList = new int*[inbrs];
for (int i = 0; i < inbrs; i++){
computesList[i] = new int[6];
}
}
for (int i = 0; i < inbrs; i++){
PUParray(p, computesList[i], 6);
}
#ifdef USE_SECTION_MULTICAST
if (p.isUnpacking()){
//need to recreate ckmulticast section proxy
localCreateSection();
}
#endif
}
};
#endif