-
Notifications
You must be signed in to change notification settings - Fork 29
/
Sph.h
352 lines (339 loc) · 12 KB
/
Sph.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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
/* Classes to describe smooth functions needed for SPH */
#ifndef __SPH_H
#define __SPH_H
#ifdef DIFFUSION
#if defined(FEEDBACKDIFFLIMIT) && !defined(DIFFUSIONHARMONIC)
#define DIFFUSIONHARMONIC
#endif
#endif
/// @brief Parameters and functions for the first SPH smooth: density
/// and velocity derivatives.
class DenDvDxSmoothParams : public SmoothParams
{
protected:
double a, H; // Cosmological parameters
int bActiveOnly;
int bConstantDiffusion;
double dTime;
double dAlphaMax; ///< Maximum SPH alpha
int bStarting; ///< We are starting (or restarting)
/// the simulation
int bHaveAlpha; ///< Alpha has been read in.
virtual void fcnSmooth(GravityParticle *p, int nSmooth,
pqSmoothNode *nList);
virtual int isSmoothActive(GravityParticle *p);
virtual void initTreeParticle(GravityParticle *p);
virtual void postTreeParticle(GravityParticle *p);
virtual void initSmoothParticle(GravityParticle *p);
virtual void initSmoothCache(GravityParticle *p);
virtual void combSmoothCache(GravityParticle *p1,
ExternalSmoothParticle *p2);
public:
DenDvDxSmoothParams() {}
/// @param _iType Type of particle to operate on
/// @param am Active rung
/// @param csm Cosmology information
/// @param _dTime Current time
/// @param _bActiveOnly Only operate on active particles.
/// @param _bConstantDiffusion Fixed diffusion constant
/// @param _bStarting Simulation is starting
/// @param _bHaveAlpha No need to calculate alpha
/// @param _dAlphaMax Maximum SPH alpha
DenDvDxSmoothParams(int _iType, int am, CSM csm, double _dTime,
int _bActiveOnly, int _bConstantDiffusion,
int _bStarting, int _bHaveAlpha, double _dAlphaMax) {
iType = _iType;
activeRung = am;
bActiveOnly = _bActiveOnly;
bConstantDiffusion = _bConstantDiffusion;
bStarting = _bStarting;
bHaveAlpha = _bHaveAlpha;
dAlphaMax = _dAlphaMax;
dTime = _dTime;
if(csm->bComove) {
H = csmTime2Hub(csm,dTime);
a = csmTime2Exp(csm,dTime);
}
else {
H = 0.0;
a = 1.0;
}
}
PUPable_decl(DenDvDxSmoothParams);
DenDvDxSmoothParams(CkMigrateMessage *m) : SmoothParams(m) {}
virtual void pup(PUP::er &p) {
SmoothParams::pup(p);//Call base class
p|dTime;
p|a;
p|H;
p|bActiveOnly;
p|bConstantDiffusion;
p|bStarting;
p|bHaveAlpha;
p|dAlphaMax;
}
};
/// @brief Get density and velocity derivatives of "Neighbor of
/// Active" particles
///
/// Like the above class, but only does non active particles marked
/// "Neighbor of Active" for the "fast gas" option.
/// Also, marking of neighbors is not complete. This is used in the
/// "FastGas" step. It uses the same fcnSmooth() as DenDvDxSmoothParams.
class DenDvDxNeighborSmParams : public DenDvDxSmoothParams
{
virtual int isSmoothActive(GravityParticle *p);
virtual void initTreeParticle(GravityParticle *p) {}
virtual void postTreeParticle(GravityParticle *p);
virtual void initSmoothParticle(GravityParticle *p) {}
virtual void initSmoothCache(GravityParticle *p) {}
virtual void combSmoothCache(GravityParticle *p1,
ExternalSmoothParticle *p2) {}
public:
DenDvDxNeighborSmParams() {}
/// @param _iType Type of particle to operate on
/// @param am Active rung
/// @param csm Cosmology information
/// @param dTime Current time
/// @param bConstantDiffusion Fixed diffusion constant
/// @param dAlphaMax Maximum SPH alpha
/// This calls the DenDvDx constructor, and we assume bActiveOnly,
/// bStarting, and bHaveAlpha are not set.
DenDvDxNeighborSmParams(int _iType, int am, CSM csm, double dTime,
int bConstDiffusion, double dAlphaMax)
: DenDvDxSmoothParams(_iType, am, csm, dTime, 0, bConstDiffusion,
0, 0, dAlphaMax) {}
PUPable_decl(DenDvDxNeighborSmParams);
DenDvDxNeighborSmParams(CkMigrateMessage *m) : DenDvDxSmoothParams(m) {}
virtual void pup(PUP::er &p) {
DenDvDxSmoothParams::pup(p);//Call base class
}
};
/// @brief Parameters for "Mark Smooth", used to find inverse nearest
/// neighbors.
class MarkSmoothParams : public SmoothParams
{
virtual void fcnSmooth(GravityParticle *p, int nSmooth,
pqSmoothNode *nList) {}
virtual int isSmoothActive(GravityParticle *p);
virtual void initTreeParticle(GravityParticle *p) {}
virtual void postTreeParticle(GravityParticle *p) {}
virtual void initSmoothParticle(GravityParticle *p) {}
virtual void initSmoothCache(GravityParticle *p) {}
virtual void combSmoothCache(GravityParticle *p1,
ExternalSmoothParticle *p2);
public:
MarkSmoothParams() {}
/// @param _iType Type of particle to operate on
/// @param am Active rung
MarkSmoothParams(int _iType, int am) {
iType = _iType;
activeRung = am;
}
PUPable_decl(MarkSmoothParams);
MarkSmoothParams(CkMigrateMessage *m) : SmoothParams(m) {}
virtual void pup(PUP::er &p) {
SmoothParams::pup(p);//Call base class
}
};
/// @brief Second pass in SPH: calculate pressure forces.
class PressureSmoothParams : public SmoothParams
{
double dTime;
double a, H; // Cosmological parameters
double alpha, beta; // SPH viscosity parameters
double dThermalDiffusionCoeff;
double dMetalDiffusionCoeff;
double dtFacCourant; // Courant timestep factor
double dtFacDiffusion; // Diffusion timestep factor
virtual void fcnSmooth(GravityParticle *p, int nSmooth,
pqSmoothNode *nList);
virtual int isSmoothActive(GravityParticle *p);
virtual void initTreeParticle(GravityParticle *p) {}
virtual void postTreeParticle(GravityParticle *p) {}
virtual void initSmoothParticle(GravityParticle *p);
virtual void initSmoothCache(GravityParticle *p);
virtual void combSmoothCache(GravityParticle *p1,
ExternalSmoothParticle *p2);
public:
PressureSmoothParams() {}
/// @param _iType Type of particles to smooth
/// @param am Active rung
/// @param csm Cosmological parameters
/// @param dTime Current time
/// @param _alpha Artificial viscosity parameter
/// @param _beta Artificial viscosity parameter
PressureSmoothParams(int _iType, int am, CSM csm, double _dTime,
double _alpha, double _beta,
double _dThermalDiff, double _dMetalDiff,
double dEtaCourant, double dEtaDiffusion) {
iType = _iType;
activeRung = am;
dTime = _dTime;
if(csm->bComove) {
H = csmTime2Hub(csm,dTime);
a = csmTime2Exp(csm,dTime);
}
else {
H = 0.0;
a = 1.0;
}
alpha = _alpha;
beta = _beta;
dThermalDiffusionCoeff = _dThermalDiff;
dMetalDiffusionCoeff = _dMetalDiff;
dtFacCourant = dEtaCourant*a*2.0/1.6;
dtFacDiffusion = 2.0*dEtaDiffusion;
}
PUPable_decl(PressureSmoothParams);
PressureSmoothParams(CkMigrateMessage *m) : SmoothParams(m) {}
virtual void pup(PUP::er &p) {
SmoothParams::pup(p);//Call base class
p|dTime;
p|a;
p|H;
p|alpha;
p|beta;
p|dThermalDiffusionCoeff;
p|dMetalDiffusionCoeff;
p|dtFacCourant;
p|dtFacDiffusion;
}
};
///
/// @brief SmoothParams class for distributing deleted gas to neighboring
/// particles.
///
class DistDeletedGasSmoothParams : public SmoothParams
{
virtual void fcnSmooth(GravityParticle *p, int nSmooth,
pqSmoothNode *nList);
virtual int isSmoothActive(GravityParticle *p);
virtual void initSmoothParticle(GravityParticle *p) {};
virtual void initTreeParticle(GravityParticle *p) {}
virtual void postTreeParticle(GravityParticle *p) {}
virtual void initSmoothCache(GravityParticle *p);
virtual void combSmoothCache(GravityParticle *p1,
ExternalSmoothParticle *p2);
public:
DistDeletedGasSmoothParams() {}
/// @param _iType Type of particles to smooth
/// @param am Active rung
DistDeletedGasSmoothParams(int _iType, int am) {
iType = _iType;
activeRung = am;
bUseBallMax = 0;
}
PUPable_decl(DistDeletedGasSmoothParams);
DistDeletedGasSmoothParams(CkMigrateMessage *m) : SmoothParams(m) {}
virtual void pup(PUP::er &p) {
SmoothParams::pup(p);//Call base class
}
};
#ifdef SUPERBUBBLE
///
/// @brief SmoothParams class for the sub-grid evaporation,
/// promoting cold neighbours to hot.
///
/// This method selects which particles cold particles are
/// to be evaporated.
///
class PromoteToHotGasSmoothParams : public SmoothParams
{
double dEvapCoeff;
double dEvapMinTemp;
double dErgPerGmUnit;
double dGmPerCcUnit;
double dDeltaStarForm;
double dTime;
virtual void fcnSmooth(GravityParticle *p, int nSmooth,
pqSmoothNode *nList);
virtual int isSmoothActive(GravityParticle *p);
virtual void initSmoothParticle(GravityParticle *p) ;
virtual void initTreeParticle(GravityParticle *p) ;
virtual void postTreeParticle(GravityParticle *p) {}
virtual void initSmoothCache(GravityParticle *p);
virtual void combSmoothCache(GravityParticle *p1,
ExternalSmoothParticle *p2) ;
public:
PromoteToHotGasSmoothParams() {}
/// @param _iType Type of particles to smooth
/// @param am Active rung
/// @param _dEvapCoeff evaporation/conduction rate coefficient
/// @param _dEvapMinTemp lowest temperature to allow evaporation
/// @param _dErgPerGmUnit specific energy in code units
/// @param _dGmPerCcUnit density in code units
/// @param _dDeltaStarForm starformation timestep
/// @param _dTime Current time
PromoteToHotGasSmoothParams(int _iType, int am, double _dEvapCoeff, double _dEvapMinTemp,
double _dErgPerGmUnit, double _dGmPerCcUnit, double _dDeltaStarForm, double _dTime) {
iType = _iType;
activeRung = am;
bUseBallMax = 0;
dEvapCoeff = _dEvapCoeff;
dEvapMinTemp = _dEvapMinTemp;
dErgPerGmUnit = _dErgPerGmUnit;
dGmPerCcUnit = _dGmPerCcUnit;
dDeltaStarForm = _dDeltaStarForm;
dTime = _dTime;
}
PUPable_decl(PromoteToHotGasSmoothParams);
PromoteToHotGasSmoothParams(CkMigrateMessage *m) : SmoothParams(m) {}
virtual void pup(PUP::er &p) {
SmoothParams::pup(p);//Call base class
p|dEvapCoeff;
p|dEvapMinTemp;
p|dErgPerGmUnit;
p|dGmPerCcUnit;
p|dDeltaStarForm;
p|dTime;
}
};
///
/// @brief SmoothParams class for the sub-grid evaporation,
/// promoting cold neighbours to hot.
///
/// This method takes cold particles marked to be promoted,
/// and averages their internal energy with the hot promoter.
///
class ShareWithHotGasSmoothParams : public SmoothParams
{
double dEvapMinTemp;
double dErgPerGmUnit;
double dGmPerCcUnit;
virtual void fcnSmooth(GravityParticle *p, int nSmooth,
pqSmoothNode *nList);
virtual int isSmoothActive(GravityParticle *p);
virtual void initSmoothParticle(GravityParticle *p) {}
virtual void initTreeParticle(GravityParticle *p) {}
virtual void postTreeParticle(GravityParticle *p) {}
virtual void initSmoothCache(GravityParticle *p);
virtual void combSmoothCache(GravityParticle *p1,
ExternalSmoothParticle *p2) ;
public:
ShareWithHotGasSmoothParams() {}
/// @param _iType Type of particles to smooth
/// @param am Active rung
/// @param _dEvapMinTemp lowest temperature to allow evaporation
/// @param _dErgPerGmUnit specific energy in code units
/// @param _dGmPerCcUnit density in code units
ShareWithHotGasSmoothParams(int _iType, int am, double _dEvapMinTemp,
double _dErgPerGmUnit, double _dGmPerCcUnit ){
iType = _iType;
activeRung = am;
bUseBallMax = 0;
dEvapMinTemp = _dEvapMinTemp;
dErgPerGmUnit = _dErgPerGmUnit;
dGmPerCcUnit = _dGmPerCcUnit;
}
PUPable_decl(ShareWithHotGasSmoothParams);
ShareWithHotGasSmoothParams(CkMigrateMessage *m) : SmoothParams(m) {}
virtual void pup(PUP::er &p) {
SmoothParams::pup(p);//Call base class
p|dEvapMinTemp;
p|dErgPerGmUnit;
p|dGmPerCcUnit;
}
};
#endif
#endif