-
Notifications
You must be signed in to change notification settings - Fork 37
/
globalVars.h
executable file
·237 lines (210 loc) · 5.69 KB
/
globalVars.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#ifndef GLOBALVARS_H
#define GLOBALVARS_H
#include "vect.h"
#include <vector>
#include <blitz/array.h>
#include <sys/time.h>
#define GLOBAL_CUSTOM_BUFFER_SIZE 9
class CglobalVars {
public:
CglobalVars() {
sphStep = 0;
time = 0;
dt = 0;
newDt = 0;
#ifdef LIQ_DEM
demDt = 0;
#endif
angMom = 0;
linMom = 0;
eElast = 0;
eElastExact = 0;
eKE = 0;
eFF = 0;
eViscF = 0;
eViscB = 0;
eBForce = 0;
eTotal = 0;
edElastdt = 0;
edFFdt = 0;
edViscFdt = 0;
#ifdef SLK
slkIndex0 = 0;
slkIndexLast = SLK_NUM_TIMESTEPS-1;
#endif
maxdt = 0;
procNeighbrs.resize(3);
procNeighbrs = -1;
for (int i=0;i<NDIM;i++) {
procDomain[2*i] = RMIN[i];
procDomain[2*i+1] = RMAX[i];
}
mpiSize = 1;
mpiRank = 0;
n = 0;
nSph = 0;
maxV = 0;
maxF = 0;
maxFF = 0;
};
CglobalVars(const CglobalVars &g) {
angMom = g.angMom;
linMom = g.linMom;
eBForce = g.eBForce;
eElast = g.eElast;
eElastExact = g.eElastExact;
eKE = g.eKE;
eViscF = g.eViscF;
eViscB = g.eViscB;
eTotal = g.eTotal;
eFF = g.eFF;
edElastdt = g.edElastdt;
edFFdt = g.edFFdt;
edViscFdt = g.edViscFdt;
dt = g.dt;
newDt = g.newDt;
#ifdef LIQ_DEM
demDt = g.demDt;
#endif
time = g.time;
sphStep = g.sphStep;
for (int i=0;i<GLOBAL_CUSTOM_BUFFER_SIZE;i++) {
custom[i] = g.custom[i];
}
mpiRank = g.mpiRank;
mpiSize = g.mpiSize;
n = g.n;
nSph = g.nSph;
maxV = g.maxV;
maxF = g.maxF;
maxFF = g.maxFF;
aveDens = g.aveDens;
aveDensFromMass = g.aveDensFromMass;
varDens = g.varDens;
rmsFF = g.rmsFF;
wtTotalMPI = g.wtTotalMPI;
wtTotalUpdateDomain = g.wtTotalUpdateDomain;
wtTotalOutStep = g.wtTotalOutStep;
wtTotalForceCalc = g.wtTotalForceCalc;
wtTotalDddtCalc = g.wtTotalDddtCalc;
wtTotalReset = g.wtTotalReset;
#ifdef SMOOTHING
wtTotalSmooth = g.wtTotalSmooth;
wtTotalSmoothMPI = g.wtTotalSmoothMPI;
#endif
}
CglobalVars& operator+=(CglobalVars &g) {
angMom += g.angMom;
linMom += g.linMom;
eBForce += g.eBForce;
eElast += g.eElast;
eElastExact += g.eElastExact;
eKE += g.eKE;
eViscF += g.eViscF;
eViscB += g.eViscB;
eFF += g.eFF;
eTotal += g.eTotal;
edElastdt += g.edElastdt;
edFFdt += g.edFFdt;
edViscFdt += g.edViscFdt;
maxV = max(maxV,g.maxV);
maxF = max(maxF,g.maxF);
maxFF = max(maxFF,g.maxFF);
for (int i=0;i<GLOBAL_CUSTOM_BUFFER_SIZE;i++) {
custom[i] += g.custom[i];
}
return *this;
}
void init(CglobalVars &g) {
time = g.time;
sphStep = g.sphStep;
dt = g.dt;
newDt = g.newDt;
#ifdef LIQ_DEM
demDt = g.demDt;
#endif
maxdt = g.maxdt;
mpiSize = g.mpiSize;
aveDens = g.aveDens;
aveDensFromMass = g.aveDensFromMass;
varDens = g.varDens;
rmsFF = g.rmsFF;
n = g.n;
nSph = g.nSph;
wtTotalMPI = g.wtTotalMPI;
wtTotalUpdateDomain = g.wtTotalUpdateDomain;
wtTotalOutStep = g.wtTotalOutStep;
wtTotalForceCalc = g.wtTotalForceCalc;
wtTotalDddtCalc = g.wtTotalDddtCalc;
wtTotalReset = g.wtTotalReset;
#ifdef SMOOTHING
wtTotalSmooth = g.wtTotalSmooth;
wtTotalSmoothMPI = g.wtTotalSmoothMPI;
#endif
}
void startOutStep() {
wtTotalMPI.tv_sec = 0;
wtTotalMPI.tv_usec = 0;
wtTotalUpdateDomain.tv_sec = 0;
wtTotalUpdateDomain.tv_usec = 0;
gettimeofday(&wtTotalOutStep,NULL);
wtTotalForceCalc.tv_sec = 0;
wtTotalForceCalc.tv_usec = 0;
wtTotalDddtCalc.tv_sec = 0;
wtTotalDddtCalc.tv_usec = 0;
wtTotalReset.tv_sec = 0;
wtTotalReset.tv_usec = 0;
#ifdef SMOOTHING
wtTotalSmooth.tv_sec = 0;
wtTotalSmooth.tv_usec = 0;
wtTotalSmoothMPI.tv_sec = 0;
wtTotalSmoothMPI.tv_usec = 0;
#endif
}
void endOutStep() {
timeval tmp;
gettimeofday(&tmp,NULL);
wtTotalOutStep.tv_sec = tmp.tv_sec-wtTotalOutStep.tv_sec;
wtTotalOutStep.tv_usec = tmp.tv_usec-wtTotalOutStep.tv_usec;
}
double angMom;
vect linMom;
double eBForce,eElast,eElastExact,eKE,eViscF,eViscB,eFF,eTotal;
double edElastdt,edViscFdt,edFFdt;
double maxV, aveDens, varDens, aveDensFromMass;
double maxF, maxFF,rmsFF;
double dt,newDt,maxdt;
#ifdef LIQ_DEM
double demDt;
#endif
int n,nSph;
#ifdef SPH_SMOOTHING
vect alpha,beta,residual2,alphaDenom;
#endif
#ifdef DIRECT_SMOOTHING
vect residual;
int DSTmpInt;
#endif
#ifdef SMOOTHING
timeval wtTotalSmooth,wtTotalSmoothMPI;
#endif
#ifdef GRID_SMOOTHING
double itError2;
#endif
#ifdef SLK
unsigned int slkIndex0;
unsigned int slkIndexLast;
#endif
double time;
int sphStep;
double custom[GLOBAL_CUSTOM_BUFFER_SIZE];
double procDomain[NDIM*2];
Array<int,NDIM> procNeighbrs;
int mpiRank;
int mpiSize;
double tmp;
double tmpArray[5];
int outstep;
timeval wtTotalMPI,wtTotalUpdateDomain,wtTotalOutStep,wtTotalForceCalc,wtTotalDddtCalc,wtTotalReset;
};
#endif