changa 3.5
Loading...
Searching...
No Matches
GravityParticle.h
Go to the documentation of this file.
1
4#ifndef GRAVITYPARTICLE_H
5#define GRAVITYPARTICLE_H
6
7#include <charm.h> /* for CkAssert */
8#include "cooling.h"
9#include "cosmoType.h"
10#include "SFC.h"
11#include <vector>
12
13#if defined(DTADJUST) || defined(SUPERBUBBLE)
14#define NEED_DT
15#endif
16
18class BucketGravityRequest {
19public:
20
21 int finished;
22
23 BucketGravityRequest(unsigned int bucketSize = 0) : finished(0) {
24 }
25
26};
27
34 public:
35
36 cosmoType mass;
37 cosmoType soft;
38 Vector3D<cosmoType> position;
39
40#ifdef __CHARMC__
41 void pup(PUP::er &p) {
42 p | position;
43 p | mass;
44 p | soft;
45 }
46#endif
47};
48
51{
52 private:
53 double _u; /* Internal Energy */
54 double _fMetals; /* Metalicity */
55#ifdef SPLITGAS
56 int64_t _iSplitOrder; /* Gas from which this particle split*/
57#endif
58 double _fMFracOxygen; /* Oxygen mass fraction */
59 double _fMFracIron; /* Iron mass fraction */
60 double _fESNrate; /* SN energy rate */
61 double _fTimeCoolIsOffUntil;/* time cooling is turned back on */
62#ifndef COLLISION
63 Vector3D<cosmoType> _vPred; /* Predicted velocities for velocity
64 dependent forces */
65#endif
66 double _uPred; /* Predicted internal energy */
67 double _divv; /* Diverence of the velocity */
68 Vector3D<double> _curlv; /* Curl of the velocity */
69 double _mumax; /* */
70 double _PdV;
71 double _uDotPdV;
72 double _uDotAV;
73 double _uDotDiff;
74 double _c; /* Speed of Sound */
75 double _PoverRho2; /* Pressure/rho^2 */
76 double _BalsaraSwitch; /* Pressure/rho^2 */
77 double _fBallMax; /* Radius for inverse neighbor finding */
78#ifdef CULLENALPHA
79 double _CullenAlpha; /* Alpha from Cullen & Dehnen 2010 */
80 double _TimeDivV; /* Time at which dvds was last updated */
81 double _dvds;
82 double _dvdsOnSFull;
83 double _dvds_old;
84#endif
85#ifdef DTADJUST
86 double _dtNew; /* New timestep from gas pressure */
87#endif
88 double _dTimeFB; /* Track feedback time */
89#ifndef COOLING_NONE
90 double _uDot; /* Rate of change of u, for
91 predicting u */
92 COOLPARTICLE _CoolParticle; /* Abundances and any other cooling
93 internal variables */
94#endif
95#ifdef DIFFUSION
96 double _diff; /* Diffusion coefficient, based on Smagorinski */
97 double _fMetalsDot;
98 double _fMetalsPred;
99 double _fMFracOxygenDot;
100 double _fMFracIronDot;
101 double _fMFracOxygenPred;
102 double _fMFracIronPred;
103#endif
104#ifdef SUPERBUBBLE
105 COOLPARTICLE _CoolParticleHot;
106 int _cpHotInit; /* Do we need to initialize the Hot Coolparticle? */
107 double _uHot; /* Hot phase energy */
108 double _uHotDot; /* Hot phase rate of energy change */
109 double _uHotPred; /* Hot phase predicted energy */
110 double _massHot; /* Hot phase mass*/
111 double _fDensityU; /* Energy-scaled density */
112 double _fThermalCond; /* Conduction rate */
113 double _fPromoteSum; /* Total evaporated mass */
114 double _fPromoteSumuPred; /* Total evaporating energy */
115 double _fPromoteuPredInit; /* Original energy pre-evaporation */
116#endif
117
118 public:
119 inline double& u() {return _u;}
120#ifdef SPLITGAS
121 inline int64_t& iSplitOrder() {return _iSplitOrder;}
122#endif
123 inline double& fMetals() {return _fMetals;}
124 inline double& fMFracOxygen() {return _fMFracOxygen;}
125 inline double& fMFracIron() {return _fMFracIron;}
126 inline double& fESNrate() {return _fESNrate;}
127 inline double& fTimeCoolIsOffUntil() {return _fTimeCoolIsOffUntil;}
128#ifndef COLLISION
129 inline Vector3D<cosmoType>& vPred() {return _vPred;}
130#endif
131 inline double& uPred() {return _uPred;}
132 inline double& divv() {return _divv;}
133 inline Vector3D<double>& curlv() {return _curlv;}
134 inline double& mumax() {return _mumax;}
135 inline double& PdV() {return _PdV;}
136 inline double& uDotPdV() {return _uDotPdV;}
137 inline double& uDotAV() {return _uDotAV;}
138 inline double& uDotDiff() {return _uDotDiff;}
139 inline double& c() {return _c;}
140 inline double& PoverRho2() {return _PoverRho2;}
141 inline double& BalsaraSwitch() {return _BalsaraSwitch;}
142 inline double& fBallMax() {return _fBallMax;}
143#ifdef CULLENALPHA
144 inline double CullenAlpha() const {return _CullenAlpha;}
145 inline double& CullenAlpha() {return _CullenAlpha;}
146 inline double& TimeDivV() {return _TimeDivV;}
147 inline double& dvds() {return _dvds;}
148 inline double& dvdsOnSFull() {return _dvdsOnSFull;}
149 inline double& dvds_old() {return _dvds_old;}
150#endif
151#ifdef DTADJUST
152 inline double& dtNew() {return _dtNew;}
153#endif
154 inline double& dTimeFB() {return _dTimeFB;}
155#ifndef COOLING_NONE
156 inline double& uDot() {return _uDot;}
157 inline COOLPARTICLE& CoolParticle() {return _CoolParticle;}
158#endif
159#ifdef DIFFUSION
160 inline double& diff() {return _diff;}
161 inline double& fMetalsDot() {return _fMetalsDot;}
162 inline double& fMetalsPred() {return _fMetalsPred;}
163 inline double& fMFracOxygenDot() {return _fMFracOxygenDot;}
164 inline double& fMFracOxygenPred() {return _fMFracOxygenPred;}
165 inline double& fMFracIronDot() {return _fMFracIronDot;}
166 inline double& fMFracIronPred() {return _fMFracIronPred;}
167#endif
168#ifdef SUPERBUBBLE
169 inline COOLPARTICLE& CoolParticleHot() {return _CoolParticleHot;}
170 inline int& cpHotInit() {return _cpHotInit;}
171 inline double& uHot() {return _uHot;}
172 inline double& uHotPred() {return _uHotPred;}
173 inline double& uHotDot() {return _uHotDot;}
174 inline double& massHot() {return _massHot;}
175 inline double& fDensityU() {return _fDensityU;}
176 inline double& fThermalCond() {return _fThermalCond;}
177 inline double& fPromoteSum() {return _fPromoteSum;}
178 inline double& fPromoteSumuPred() {return _fPromoteSumuPred;}
179 inline double& fPromoteuPredInit() {return _fPromoteuPredInit;}
180#endif
181#ifdef __CHARMC__
182 void pup(PUP::er &p) {
183 p | _u;
184#ifdef SPLITGAS
185 p | _iSplitOrder;
186#endif
187 p | _fMetals;
188 p | _fMFracIron;
189 p | _fMFracOxygen;
190 p | _fESNrate;
191 p | _fTimeCoolIsOffUntil;
192#ifndef COLLISION
193 p | _vPred;
194#endif
195 p | _uPred;
196 p | _divv;
197 p | _curlv;
198 p | _mumax;
199 p | _PdV;
200 p | _uDotPdV;
201 p | _uDotAV;
202 p | _uDotDiff;
203 p | _c;
204 p | _PoverRho2;
205 p | _BalsaraSwitch;
206 p | _fBallMax;
207#ifdef CULLENALPHA
208 p | _CullenAlpha;
209 p | _TimeDivV;
210 p | _dvds;
211 p | _dvdsOnSFull;
212 p | _dvds_old;
213#endif
214#ifdef DTADJUST
215 p | _dtNew;
216#endif
217 p | _dTimeFB;
218#ifndef COOLING_NONE
219 p | _uDot;
220 p((char *) &_CoolParticle, sizeof(_CoolParticle)); /* PUPs as bytes */
221#endif
222#ifdef DIFFUSION
223 p| _diff;
224 p| _fMetalsDot;
225 p| _fMetalsPred;
226 p| _fMFracOxygenDot;
227 p| _fMFracOxygenPred;
228 p| _fMFracIronDot;
229 p| _fMFracIronPred;
230#endif
231#ifdef SUPERBUBBLE
232 p((char *) &_CoolParticleHot, sizeof(_CoolParticleHot)); /* PUPs as bytes */
233 p| _cpHotInit;
234 p| _uHot;
235 p| _uHotDot;
236 p| _uHotPred;
237 p| _massHot;
238 p| _fDensityU;
239 p| _fThermalCond;
240 p| _fPromoteSum;
241 p| _fPromoteSumuPred;
242 p| _fPromoteuPredInit;
243#endif
244 }
245#endif
246 };
247
250{
251 private:
252 double _fMetals; /* Metalicity */
253 double _fTimeForm; /* Formation time */
254 double _fMassForm; /* Formation mass */
255 double _fESNrate; /* SN energy rate */
256 double _fNSN; /* number of SN exploding */
257 double _fMSN; /* mass of feedback ejecta */
258 double _fMFracOxygen; /* Oxygen mass fraction */
259 double _fMFracIron; /* Iron mass fraction */
260 double _fSNMetals; /* Ejected metals from feedback */
261 double _fMOxygenOut; /* Ejected oxygen */
262 double _fMIronOut; /* Ejected iron */
263 int64_t _iGasOrder; /* Gas from which this star formed */
264#ifdef STOCH12
265 double _rgfHMStars[12]; /* High mass stars (if using stochastic IMF) */
266 double _fLowNorm; /* Normalization for low-mass imf */
267#elif STOCH24
268 double _rgfHMStars[24]; /* High mass stars (if using stochastic IMF) */
269 double _fLowNorm; /* Normalization for low-mass imf */
270#endif
271 int64_t _iEaterOrder; /* iOrder for merging black holes */
272 double _dMDot; /* Accretion rate of black holes */
273 double _dDeltaM; /* Actual Mass Accreted on black holes */
274#ifdef COOLING_MOLECULARH
275 double _dStarLymanWerner; /* Lyman Werner radiation emmited from star particles */
276#ifdef SHIELDSF
277 double _fShieldForm; /* Fraction of gas particle unshielded at time of formation*/
278#endif
279#endif /*COOLING_MOLECULARH*/
280 public:
281 inline double& fMetals() {return _fMetals;}
282 inline double& fTimeForm() {return _fTimeForm;}
283 inline double& fMassForm() {return _fMassForm;}
284 inline double& fESNrate() {return _fESNrate;}
285 inline double& fNSN() {return _fNSN;}
286 inline double& fMSN() {return _fMSN;}
287 inline double& fMFracOxygen() {return _fMFracOxygen;}
288 inline double& fMFracIron() {return _fMFracIron;}
289 inline double& fMIronOut() {return _fMIronOut;}
290 inline double& fMOxygenOut() {return _fMOxygenOut;}
291 inline double& fSNMetals() {return _fSNMetals;}
292 inline int64_t& iGasOrder() {return _iGasOrder;}
293#ifdef STOCH12
294 inline double& rgfHMStars(int i) {
295 CkAssert(i<12);
296 return _rgfHMStars[i];
297 }
298 inline double* rgfHMStars() {return _rgfHMStars;}
299 inline double& fLowNorm() {return _fLowNorm;}
300#elif STOCH24
301 inline double& rgfHMStars(int i) {
302 CkAssert(i<24);
303 return _rgfHMStars[i];
304 }
305 inline double* rgfHMStars() {return _rgfHMStars;}
306 inline double& fLowNorm() {return _fLowNorm;}
307#else
308 inline double& rgfHMStars(int i) {CkAbort("Call rgfHMStars but stochasticity not built in"); return _fMetals;}
309 inline double* rgfHMStars() {CkAbort("Call rgfHMStars but stochasticity not built in"); return NULL;}
310 inline double& fLowNorm() {CkAbort("Call fLowNorm but stochasticity not built in"); return _fMetals;}
311#endif
312 inline int64_t& iEaterOrder() {return _iEaterOrder;}
313 inline double& dMDot() {return _dMDot;}
314 inline double& dDeltaM() {return _dDeltaM;}
315#ifdef COOLING_MOLECULARH
316 inline double dStarLymanWerner() const {return _dStarLymanWerner;}
317 inline double& dStarLymanWerner() {return _dStarLymanWerner;}
318#ifdef SHIELDSF
319 inline double& fShieldForm() {return _fShieldForm;}
320#endif
321#endif /*COOLING_MOLECULARH*/
322 void pup(PUP::er &p) {
323 p | _fMetals;
324 p | _fTimeForm;
325 p | _fMassForm;
326 p | _fESNrate;
327 p | _fNSN;
328 p | _fMSN;
329 p | _fMFracOxygen;
330 p | _fMFracIron;
331 p | _fSNMetals;
332 p | _fMOxygenOut;
333 p | _fMIronOut;
334 p | _iGasOrder;
335#ifdef STOCH12
336 p | _fLowNorm;
337 PUParray(p,_rgfHMStars,12);
338#elif STOCH24
339 p | _fLowNorm;
340 PUParray(p,_rgfHMStars,24);
341#endif
342 p | _iEaterOrder;
343 p | _dMDot;
344 p | _dDeltaM;
345#ifdef COOLING_MOLECULARH
346 p | _dStarLymanWerner;
347#ifdef SHIELDSF
348 p | _fShieldForm;
349#endif
350#endif /*COOLINg_MOLECULARH*/
351 }
352 };
353
354class GravityParticle;
355int TYPETest(const GravityParticle *a, unsigned int b);
356
358
363
364class GravityParticle : public ExternalGravityParticle {
365#ifdef COLLISION
366private:
367 // Necessary for gas drag forces on solid bodies
368 Vector3D<cosmoType> _vPred;
369#endif
370
371public:
372 Vector3D<cosmoType> velocity;
373 Vector3D<cosmoType> treeAcceleration;
374#ifdef COLLISION
375 cosmoType dtCol;
376 int64_t iOrderCol;
377 Vector3D<cosmoType> w;
378 cosmoType dtKep;
379 // For consistency with non-collision version
380 inline Vector3D<cosmoType>& vPred() {return _vPred;}
381#endif
382 cosmoType potential;
383 cosmoType dtGrav;
387 cosmoType fBall;
388 cosmoType fDensity;
389 int rung;
390 unsigned int iType;
391#ifdef SIDMINTERACT
392 int iNSIDMInteractions; // SIDM number of interactions
393#endif
394#ifdef CHANGESOFT
395 cosmoType fSoft0;
396#endif
397#ifdef NEED_DT
398 cosmoType dt;
399#endif
400 cosmoType interMass;
401
402 SFC::Key key;
403 int64_t iOrder;
404 void *extraData; /* SPH or Star particle data */
405
406#if COSMO_STATS > 1
407 double intcellmass;
408 double intpartmass;
409 double extcellmass;
410 double extpartmass;
411#endif
412
413 GravityParticle(SFC::Key k) : ExternalGravityParticle() {
414 key = k;
415 }
417 }
418
420 inline bool operator<(const GravityParticle& p) const {
421 return key < p.key;
422 }
423
424#ifdef __CHARMC__
425 void pup(PUP::er &p) {
426 ExternalGravityParticle::pup(p);
427 p | key;
428 p | velocity;
429 p | treeAcceleration;
430#ifdef COLLISION
431 p | dtCol;
432 p | iOrderCol;
433 p | _vPred;
434 p | dtKep;
435 p | w;
436#endif
437 p | dtGrav;
438 p | fDensity;
439 p | fBall;
440 p | iOrder;
441 p | rung;
442 p | iType;
443#ifdef SIDMINTERACT
444 p | iNSIDMInteractions; // SIDM
445#endif
446#ifdef CHANGESOFT
447 p | fSoft0;
448#endif
449#ifdef NEED_DT
450 p | dt;
451#endif
452 }
453#endif
454
455// Debugging macros for the extra data fields.
456// To enable, define GP_DEBUG_EXTRAS
457
458#define GP_DEBUG_EXTRAS
459
460#ifdef GP_DEBUG_EXTRAS
463#define IMAGAS CkAssert(isGas())
466#define IMASTAR CkAssert(isStar())
467#else
468#define IMAGAS
469#define IMASTAR
470#endif
471
472 // Access SPH quantities
475 inline double& u() { IMAGAS; return (((extraSPHData*)extraData)->u());}
476#ifdef SPLITGAS
477 inline int64_t& iSplitOrder() { IMAGAS; return (((extraSPHData*)extraData)->iSplitOrder());}
478#endif
479 inline double& fMetals() { IMAGAS; return (((extraSPHData*)extraData)->fMetals());}
480 inline double& fMFracOxygen() {IMAGAS; return (((extraSPHData*)extraData)->fMFracOxygen());}
481 inline double& fMFracIron() {IMAGAS; return (((extraSPHData*)extraData)->fMFracIron());}
482 inline double& fESNrate() {IMAGAS; return (((extraSPHData*)extraData)->fESNrate());}
483 inline double& fTimeCoolIsOffUntil() {IMAGAS; return (((extraSPHData*)extraData)->fTimeCoolIsOffUntil());}
484#ifndef COLLISION
485 inline Vector3D<cosmoType>& vPred() { IMAGAS; return (((extraSPHData*)extraData)->vPred());}
486#endif
487 inline double& uPred() {IMAGAS; return (((extraSPHData*)extraData)->uPred());}
488 inline double& divv() { IMAGAS; return (((extraSPHData*)extraData)->divv());}
489 inline Vector3D<double>& curlv() { IMAGAS; return (((extraSPHData*)extraData)->curlv());}
490 inline double& mumax() { IMAGAS; return (((extraSPHData*)extraData)->mumax());}
491 inline double& PdV() { IMAGAS; return (((extraSPHData*)extraData)->PdV());}
492 inline double& uDotPdV() { IMAGAS; return (((extraSPHData*)extraData)->uDotPdV());}
493 inline double& uDotAV() { IMAGAS; return (((extraSPHData*)extraData)->uDotAV());}
494 inline double& uDotDiff() { IMAGAS; return (((extraSPHData*)extraData)->uDotDiff());}
495 inline double& c() { IMAGAS; return (((extraSPHData*)extraData)->c());}
496 inline double& PoverRho2() { IMAGAS; return (((extraSPHData*)extraData)->PoverRho2());}
497 inline double& BalsaraSwitch() { IMAGAS; return (((extraSPHData*)extraData)->BalsaraSwitch());}
498 inline double& fBallMax() { IMAGAS; return (((extraSPHData*)extraData)->fBallMax());}
499#ifdef CULLENALPHA
500 inline double CullenAlpha() const {IMAGAS; return (((extraSPHData*)extraData)->CullenAlpha());}
501 inline double& CullenAlpha() {IMAGAS; return (((extraSPHData*)extraData)->CullenAlpha());}
502 inline double& TimeDivV() {IMAGAS; return (((extraSPHData*)extraData)->TimeDivV());}
503 inline double& dvds() {IMAGAS; return (((extraSPHData*)extraData)->dvds());}
504 inline double& dvdsOnSFull() {IMAGAS; return (((extraSPHData*)extraData)->dvdsOnSFull());}
505 inline double& dvds_old() {IMAGAS; return (((extraSPHData*)extraData)->dvds_old());}
506#endif
507#ifdef DTADJUST
508 inline double& dtNew() { IMAGAS; return (((extraSPHData*)extraData)->dtNew());}
509#endif
510 inline double& dTimeFB() { IMAGAS; return (((extraSPHData*)extraData)->dTimeFB());}
511#ifndef COOLING_NONE
512 inline double& uDot() { IMAGAS; return (((extraSPHData*)extraData)->uDot());}
513 inline COOLPARTICLE& CoolParticle() { IMAGAS; return (((extraSPHData*)extraData)->CoolParticle());}
514#endif
515#ifdef DIFFUSION
516 inline double& diff() { IMAGAS; return (((extraSPHData*)extraData)->diff());}
517 inline double& fMetalsDot() { IMAGAS; return (((extraSPHData*)extraData)->fMetalsDot());}
518 inline double& fMetalsPred() { IMAGAS; return (((extraSPHData*)extraData)->fMetalsPred());}
519 inline double& fMFracOxygenDot() { IMAGAS; return (((extraSPHData*)extraData)->fMFracOxygenDot());}
520 inline double& fMFracIronDot() { IMAGAS; return (((extraSPHData*)extraData)->fMFracIronDot());}
521 inline double& fMFracOxygenPred() { IMAGAS; return (((extraSPHData*)extraData)->fMFracOxygenPred());}
522 inline double& fMFracIronPred() { IMAGAS; return (((extraSPHData*)extraData)->fMFracIronPred());}
523#endif
524#ifdef SUPERBUBBLE
525 inline COOLPARTICLE& CoolParticleHot() { IMAGAS; return (((extraSPHData*)extraData)->CoolParticleHot());}
526 inline int& cpHotInit() { IMAGAS; return (((extraSPHData*)extraData)->cpHotInit());}
527 inline double& uHot() { IMAGAS; return (((extraSPHData*)extraData)->uHot());}
528 inline double& uHotPred() { IMAGAS; return (((extraSPHData*)extraData)->uHotPred());}
529 inline double& uHotDot() { IMAGAS; return (((extraSPHData*)extraData)->uHotDot());}
530 inline double& massHot() { IMAGAS; return (((extraSPHData*)extraData)->massHot());}
531 inline double& fDensityU() { IMAGAS; return (((extraSPHData*)extraData)->fDensityU());}
532 inline double& fThermalCond() { IMAGAS; return (((extraSPHData*)extraData)->fThermalCond());}
533 inline double& fPromoteSum() { IMAGAS; return (((extraSPHData*)extraData)->fPromoteSum());}
534 inline double& fPromoteSumuPred() { IMAGAS; return (((extraSPHData*)extraData)->fPromoteSumuPred());}
535 inline double& fPromoteuPredInit() { IMAGAS; return (((extraSPHData*)extraData)->fPromoteuPredInit());}
536#endif
537 // Access Star Quantities
538 // XXX Beware overlaps with SPH; we could fix this by aligning
539 // all common variables up at the start of the extraData structure.
540 inline double& fStarMetals() { IMASTAR; return (((extraStarData*)extraData)->fMetals());}
541 inline double& fStarMFracOxygen() {IMASTAR; return (((extraStarData*)extraData)->fMFracOxygen());}
542 inline double& fStarMFracIron() {IMASTAR; return (((extraStarData*)extraData)->fMFracIron());}
543 inline double& fTimeForm() { IMASTAR; return (((extraStarData*)extraData)->fTimeForm());}
544 inline double& fMassForm() { IMASTAR; return (((extraStarData*)extraData)->fMassForm());}
545 inline double& fStarESNrate() {IMASTAR; return (((extraStarData*)extraData)->fESNrate());}
546 inline double& fNSN() {IMASTAR; return (((extraStarData*)extraData)->fNSN());}
547 inline double& fMSN() {IMASTAR; return (((extraStarData*)extraData)->fMSN());}
548 inline double& fMIronOut() {IMASTAR; return (((extraStarData*)extraData)->fMIronOut());}
549 inline double& fMOxygenOut() {IMASTAR; return (((extraStarData*)extraData)->fMOxygenOut());}
550 inline double& fSNMetals() {IMASTAR; return (((extraStarData*)extraData)->fSNMetals());}
551 inline int64_t& iGasOrder() { IMASTAR; return (((extraStarData*)extraData)->iGasOrder());}
552
553 /* The following three are not wrapped in a compiler macro because
554 * they call a function that is.*/
555 inline double& rgfHMStars(int i) { IMASTAR; return (((extraStarData*)extraData)->rgfHMStars(i));}
556 inline double* rgfHMStars() { IMASTAR; return (((extraStarData*)extraData)->rgfHMStars());}
557 inline double& fLowNorm() {IMASTAR; return (((extraStarData*)extraData)->fLowNorm());}
558
559 inline int64_t& iEaterOrder() { IMASTAR; return (((extraStarData*)extraData)->iEaterOrder());}
560 inline double& dDeltaM() { IMASTAR; return (((extraStarData*)extraData)->dDeltaM());}
561 inline double& dMDot() { IMASTAR; return (((extraStarData*)extraData)->dMDot());}
562#ifdef COOLING_MOLECULARH
563 inline double dStarLymanWerner() const { IMASTAR; return (((extraStarData*)extraData)->dStarLymanWerner());}
564 inline double& dStarLymanWerner() { IMASTAR; return (((extraStarData*)extraData)->dStarLymanWerner());}
565#ifdef SHIELDSF
566 inline double& fShieldForm() { IMASTAR; return (((extraStarData*)extraData)->fShieldForm());}
567#endif
568#endif /*COOLING_MOLECULARH*/
569
570// See above debugging macros
571#undef IMAGAS
572#undef IMASTAR
573
574/* Particle Type Masks */
575
576#define TYPE_GAS (1<<0)
577#define TYPE_DARK (1<<1)
578#define TYPE_STAR (1<<2)
579
580#define TYPE_DELETED (1<<3)
581
582#define TYPE_PHOTOGENIC (1<<4)
583#define TYPE_NbrOfACTIVE (1<<5)
584#define TYPE_SMOOTHACTIVE (1<<6)
585
586#define TYPE_SINK (1<<7)
587#define TYPE_SINKING (1<<8)
588#define TYPE_NEWSINKING (1<<9)
589#define TYPE_PROMOTED (1<<10)
590#define TYPE_FEEDBACK (1<<11)
591#define TYPE_MAXTYPE (1<<12)
592
593 inline bool isDark() const { return TYPETest(this, TYPE_DARK);}
594 inline bool isGas() const { return TYPETest(this, TYPE_GAS);}
595 inline bool isStar() const { return TYPETest(this, TYPE_STAR);}
596
597 GravityParticle &operator=(const ExternalGravityParticle &p){
598 mass = p.mass;
599 soft = p.soft;
600 position = p.position;
601 return *this;
602 }
603};
604
606inline int TYPETest(const GravityParticle *a, unsigned int b) {
607 return a->iType & b;
608 }
609
610inline int TYPESet(GravityParticle *a, unsigned int b) {
611 return a->iType |= b;
612 }
613
614inline int TYPEReset(GravityParticle *a, unsigned int b) {
615 return a->iType &= (~b);
616 }
617inline int TYPEClear(GravityParticle *a) {
618 return a->iType = 0;
619 }
620
623{
624 CkAssert(TYPETest(p, TYPE_DELETED));
625
626 TYPEReset(p, TYPE_DELETED);
627 }
628
631{
632 TYPESet(p, TYPE_DELETED);
633 }
634
638{
639 GravityParticle starp = *p;
640 TYPESet(&starp, TYPE_STAR);
641 starp.extraData = new extraStarData;
642 starp.fStarMetals() = p->fMetals();
643 starp.fStarMFracOxygen() = p->fMFracOxygen();
644 starp.fStarMFracIron() = p->fMFracIron();
645 return starp;
646 }
647
649class ExternalSmoothParticle {
650 public:
651
652 cosmoType mass;
653 double fBall;
654 double fDensity;
655 Vector3D<cosmoType> position;
656 Vector3D<double> velocity;
657 int64_t iOrder;
658 unsigned int iType; // Bitmask to hold particle type information
659 int rung;
660#ifdef DTADJUST
661 double dt;
662 double dtNew;
663#endif
664#ifdef COLLISION
665 double soft;
666 double dtCol;
667 int64_t iOrderCol;
668#endif
669 Vector3D<cosmoType> vPred;
670 Vector3D<cosmoType> treeAcceleration;
671 double mumax;
672 double PdV;
673 double uDotPdV;
674 double uDotAV;
675 double uDotDiff;
676 double c;
677 double PoverRho2;
678 double BalsaraSwitch;
679 double fBallMax;
680#ifdef CULLENALPHA
681 double CullenAlpha;
682 double TimeDivV;
683 double dvds;
684 double dvds_old;
685#endif
686 double u;
687 double uPred;
688 double uDot;
689 double fESNrate;
690 double fMetals;
691 double fMFracOxygen;
692 double fMFracIron;
693 double fTimeCoolIsOffUntil;
694 Vector3D<double> curlv; /* Curl of the velocity */
695#ifdef DIFFUSION
696 double diff;
697 double fMetalsDot;
698 double fMFracOxygenDot;
699 double fMFracIronDot;
700#endif
701#ifdef SUPERBUBBLE
702 COOLPARTICLE CoolParticle;
703 double uHot;
704 double uHotDot;
705 double uHotPred;
706 double massHot;
707 double fDensityU;
708 double fThermalCond;
709 double fPromoteSum;
710 double fPromoteSumuPred;
711 double fPromoteuPredInit;
712#endif
713 double fNSN;
714 int64_t iEaterOrder;
715 double dTimeFB;
716 int iBucketOff; /* Used by the Cache */
717
718 ExternalSmoothParticle() {}
719
720 ExternalSmoothParticle(GravityParticle *p)
721 {
722 mass = p->mass;
723 fBall = p->fBall;
724 fDensity = p->fDensity;
725 position = p->position;
726 velocity = p->velocity;
727 iOrder = p->iOrder;
728 iType = p->iType;
729 rung = p->rung;
730 treeAcceleration = p->treeAcceleration;
731#ifdef COLLISION
732 soft = p->soft;
733 dtCol = p->dtCol;
734 iOrderCol = p->iOrderCol;
735#endif
736 if(TYPETest(p, TYPE_GAS)) {
737 vPred = p->vPred();
738 mumax = p->mumax();
739 PdV = p->PdV();
740 uDotPdV = p->uDotPdV();
741 uDotAV = p->uDotAV();
742 uDotDiff = p->uDotDiff();
743 c = p->c();
744 PoverRho2 = p->PoverRho2();
745 BalsaraSwitch = p->BalsaraSwitch();
746 fBallMax = p->fBallMax();
747#ifdef CULLENALPHA
748 CullenAlpha = p->CullenAlpha();
749 TimeDivV = p->TimeDivV();
750 dvds = p->dvds();
751 dvds_old = p->dvds_old();
752#endif
753 curlv = p->curlv();
754 u = p->u();
755#ifndef COOLING_NONE
756 uDot = p->uDot();
757#endif
758 uPred = p->uPred();
759 fMetals = p->fMetals();
760 fESNrate = p->fESNrate();
761 fMFracOxygen = p->fMFracOxygen();
762 fMFracIron = p->fMFracIron();
763 fTimeCoolIsOffUntil = p->fTimeCoolIsOffUntil();
764#ifdef DIFFUSION
765 diff = p->diff();
766 fMetalsDot = p->fMetalsDot();
767 fMFracOxygenDot = p->fMFracOxygenDot();
768 fMFracIronDot = p->fMFracIronDot();
769#endif
770#ifdef SUPERBUBBLE
771 CoolParticle = p->CoolParticle();
772 uHot = p->uHot();
773 uHotPred = p->uHotPred();
774 uHotDot = p->uHotDot();
775 massHot = p->massHot();
776 fDensityU = p->fDensityU();
777 fThermalCond = p->fThermalCond();
778 fPromoteSum = p->fPromoteSum();
779 fPromoteSumuPred = p->fPromoteSumuPred();
780 fPromoteuPredInit = p->fPromoteuPredInit();
781#endif
782#ifdef DTADJUST
783 dt = p->dt;
784 dtNew = p->dtNew();
785#endif
786 dTimeFB = p->dTimeFB();
787 }
788 if(TYPETest(p, TYPE_STAR)) {
789 fNSN = p->fNSN();
790 iEaterOrder = p->iEaterOrder();
791 }
792 }
793
795 inline void getParticle(GravityParticle *tmp) const {
796 tmp->mass = mass;
797 tmp->fBall = fBall;
798 tmp->fDensity = fDensity;
799 tmp->position = position;
800 tmp->velocity = velocity;
801 tmp->iOrder = iOrder;
802 tmp->iType = iType;
803 tmp->rung = rung;
804 tmp->treeAcceleration = treeAcceleration;
805#ifdef COLLISION
806 tmp->soft = soft;
807 tmp->dtCol = dtCol;
808 tmp->iOrderCol = iOrderCol;
809#endif
810 if(TYPETest(tmp, TYPE_GAS)) {
811 tmp->vPred() = vPred;
812 tmp->mumax() = mumax;
813 tmp->PdV() = PdV;
814 tmp->uDotPdV() = uDotPdV;
815 tmp->uDotAV() = uDotAV;
816 tmp->uDotDiff() = uDotDiff;
817 tmp->c() = c;
818 tmp->PoverRho2() = PoverRho2;
819 tmp->BalsaraSwitch() = BalsaraSwitch;
820 tmp->fBallMax() = fBallMax;
821#ifdef CULLENALPHA
822 tmp->CullenAlpha() = CullenAlpha;
823 tmp->TimeDivV() = TimeDivV;
824 tmp->dvds() = dvds;
825 tmp->dvds_old() = dvds_old;
826#endif
827 tmp->curlv() = curlv;
828 tmp->u() = u;
829#ifndef COOLING_NONE
830 tmp->uDot() = uDot;
831#endif
832 tmp->uPred() = uPred;
833 tmp->fMetals() = fMetals;
834 tmp->fESNrate() = fESNrate;
835 tmp->fMFracOxygen() = fMFracOxygen;
836 tmp->fMFracIron() = fMFracIron;
837 tmp->fTimeCoolIsOffUntil() = fTimeCoolIsOffUntil;
838#ifdef DIFFUSION
839 tmp->diff() = diff;
840 tmp->fMetalsDot() = fMetalsDot;
841 tmp->fMFracOxygenDot() = fMFracOxygenDot;
842 tmp->fMFracIronDot() = fMFracIronDot;
843#endif
844#ifdef SUPERBUBBLE
845 tmp->CoolParticle() = CoolParticle;
846 tmp->uHot() = uHot;
847 tmp->uHotPred() = uHotPred;
848 tmp->uHotDot() = uHotDot;
849 tmp->massHot() = massHot;
850 tmp->fDensityU() = fDensityU;
851 tmp->fThermalCond() = fThermalCond;
852 tmp->fPromoteSum() = fPromoteSum;
853 tmp->fPromoteSumuPred() = fPromoteSumuPred;
854 tmp->fPromoteuPredInit() = fPromoteuPredInit;
855#endif
856#ifdef DTADJUST
857 tmp->dt = dt;
858 tmp->dtNew() = dtNew;
859#endif
860 tmp->dTimeFB() = dTimeFB;
861 }
862 if(TYPETest(tmp, TYPE_STAR)) {
863 tmp->fNSN() = fNSN;
864 tmp->iEaterOrder() = iEaterOrder;
865 }
866 }
867
868#ifdef __CHARMC__
869 void pup(PUP::er &p) {
870 p | position;
871 p | velocity;
872 p | vPred;
873 p | mass;
874 p | fBall;
875 p | fDensity;
876 p | iOrder;
877 p | iType;
878 p | rung;
879#ifdef DTADJUST
880 p | dt;
881 p | dtNew;
882#endif
883 p | treeAcceleration;
884 p | mumax;
885 p | PdV;
886 p | uDotPdV;
887 p | uDotAV;
888 p | uDotDiff;
889 p | c;
890 p | PoverRho2;
891 p | BalsaraSwitch;
892 p | fBallMax;
893#ifdef CULLENALPHA
894 p | CullenAlpha;
895 p | TimeDivV;
896 p | dvds;
897 p | dvds_old;
898#endif
899 p | u;
900 p | uPred;
901 p | uDot;
902 p | curlv;
903 p | fMetals;
904 p | fESNrate;
905 p | fMFracOxygen;
906 p | fMFracIron;
907 p | fTimeCoolIsOffUntil;
908#ifdef DIFFUSION
909 p | diff;
910 p | fMetalsDot;
911 p | fMFracOxygenDot;
912 p | fMFracIronDot;
913#endif
914#ifdef SUPERBUBBLE
915 p((char *) &CoolParticle, sizeof(CoolParticle)); /* PUPs as bytes */
916 p | uHot;
917 p | uHotPred;
918 p | uHotDot;
919 p | massHot;
920 p | fDensityU;
921 p | fThermalCond;
922 p | fPromoteSum;
923 p | fPromoteSumuPred;
924 p | fPromoteuPredInit;
925#endif
926 p | fNSN;
927 p | iEaterOrder;
928 p | dTimeFB;
929 p | iBucketOff;
930#ifdef COLLISION
931 p | soft;
932 p | dtCol;
933 p | iOrderCol;
934#endif
935 }
936#endif
937};
938
941
942inline int TYPETest(ExternalSmoothParticle *a, unsigned int b) {
943 return a->iType & b;
944 }
945
946#endif
int TYPETest(const GravityParticle *a, unsigned int b)
Test for a type flag.
Definition GravityParticle.h:606
int TYPEReset(GravityParticle *a, unsigned int b)
Unset a type flag.
Definition GravityParticle.h:614
int TYPESet(GravityParticle *a, unsigned int b)
Set a type flag.
Definition GravityParticle.h:610
void unDeleteParticle(GravityParticle *p)
unmark particle as deleted
Definition GravityParticle.h:622
GravityParticle StarFromGasParticle(GravityParticle *p)
Create star particle from gas particle Note that new memory is allocated for the extradata.
Definition GravityParticle.h:637
void deleteParticle(GravityParticle *p)
mark particle as deleted
Definition GravityParticle.h:630
#define IMAGAS
Definition GravityParticle.h:463
#define IMASTAR
Definition GravityParticle.h:466
Information needed to calculate gravity.
Definition GravityParticle.h:33
Class for cross processor data needed for smooth operations.
Definition GravityParticle.h:649
void getParticle(GravityParticle *tmp) const
Fill in a full gravity particle from this object.
Definition GravityParticle.h:795
Fundamental type for a particle.
Definition GravityParticle.h:364
cosmoType fBall
Neighbor search radius for smoothing.
Definition GravityParticle.h:387
int rung
the current rung (greater means faster)
Definition GravityParticle.h:389
bool operator<(const GravityParticle &p) const
Used to sort the particles into tree order.
Definition GravityParticle.h:420
unsigned int iType
Bitmask to hold particle type information.
Definition GravityParticle.h:390
int64_t iOrder
Input order of particles; unique particle ID.
Definition GravityParticle.h:403
ExternalSmoothParticle getExternalSmoothParticle()
Get quantities needed for SPH smooths.
Definition GravityParticle.h:939
cosmoType dtGrav
Definition GravityParticle.h:383
Extra data needed for SPH.
Definition GravityParticle.h:51
Extra data needed for Stars.
Definition GravityParticle.h:250