-
Notifications
You must be signed in to change notification settings - Fork 29
/
SphUtils.h
154 lines (142 loc) · 4.2 KB
/
SphUtils.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
/*
* This file contains inline utility functions and function declarations needed
* for SPH
*
* Based on the physics modules implemented by James Wadsley in GASOLINE.
* Implemented by Tom Quinn in ChaNGa and refactored by Isaac Backus
* Oct 14, 2016
*/
#ifndef SPHUTILS_H
#define SPHUTILS_H
// Include Sph.h for possible macro definitions in there
#include "Sph.h"
/**
* @brief presPdv can be used as a simple means to switch Pressure weighting
* schemes for PdV calculations.
* @return a
*/
inline double presPdv(const double a, const double b){
return a;
}
/**
* @brief presAcc can be used as a simple means to switch Pressure weighting for
* schemes for acceleration calculation.
* @return a + b
*/
inline double presAcc(const double a, const double b){
return a + b;
}
/**
* @brief switchCombine is used to allow weighting of the BalsaraSwitch of
* two particles.
*/
inline double switchCombine(GravityParticle *a, GravityParticle *b) {
#ifdef CULLENALPHA
return 1.0;
#else
return 0.5*(a->BalsaraSwitch()+b->BalsaraSwitch());
#endif
}
/**
* @brief rhoDivv can be used for switching between using gdforce and not
* @return b if gdforce is compiled, otherwise return a
*/
inline double rhoDivv(const double a, const double b) {
#ifdef GDFORCE
return b;
#else
return a;
#endif
}
/**
* @brief varAlpha allows for variable SPH viscosity parameter alpha. Behavior
* is controlled by compile-time flag VARALPHA.
*/
inline double varAlpha(const double alpha, const GravityParticle *a,
const GravityParticle *b) {
#if defined(VARALPHA) || defined(CULLENALPHA)
return alpha*0.5*(a->CullenAlpha() + b->CullenAlpha());
#else
return alpha;
#endif //VARALPHA
}
/**
* @brief varBeta allows for variable SPH viscosity beta. Behavior is controlled
* by the compile-time flag VARALPHA
*/
inline double varBeta(const double beta, GravityParticle *a,
const GravityParticle *b) {
#if defined(VARALPHA) || defined(CULLENALPHA)
return beta*0.5*(a->CullenAlpha() + b->CullenAlpha());
#else
return beta;
#endif //VARALPHA
}
/**
* @brief diffusionLimitTest performs a test which can be used to prevent the
* diffusion of supernova feedback energy. Its behavior is controlled by
* FEEDBACKDIFFLIMIT
* @param diffSum The possibly weighted sum of interacting particles diff()
* @param dTime Current time
* @param a Particle 1
* @param b Neighbor particle
*/
inline bool diffusionLimitTest(const double diffSum, const double dTime,
GravityParticle *a, GravityParticle *b) {
#ifdef FEEDBACKDIFFLIMIT
return (diffSum == 0 \
|| dTime < a->fTimeCoolIsOffUntil() \
|| dTime < b->fTimeCoolIsOffUntil());
#else
return (diffSum == 0);
#endif
}
inline double massDiffFac(const GravityParticle *p) {
///* not implemented */
//#ifdef MASSDIFF /* compile-time flag */
// return p->fMass;
//#else
return 1.0;
//#endif //MASSDIFF
}
typedef struct PressSmoothUpdateStruct {
double dvdotdr;
double visc;
double aFac;
Vector3D<double> dx;
// /* not implemented */
// #ifdef DRHODT /* compile-time flag */
// double fDivv_Corrector;
// #endif
#ifdef DIFFUSION
// /* DIFFUSIONPRICE not implemented */
// #ifdef DIFFUSIONPRICE /* compile-time flag */
// double diffu;
// #else
#ifndef NODIFFUSIONTHERMAL /* compile-time flag */
double diffu;
#endif
// #endif //DIFFUSIONPRICE
/* not implemented */
// #ifdef UNONCOOL
// double diffuNc;
// #endif
double diffMetals;
double diffMetalsOxygen;
double diffMetalsIron;
// /* not implemented */
// #ifdef MASSDIFF /* compile-time flag */
// double diffMass;
// Vector3D<double> diffVelocity;
// #endif
#endif
} PressSmoothUpdate;
typedef struct PressSmoothParticleStruct {
double rNorm;
double PoverRho2;
double PoverRho2f;
} PressSmoothParticle;
void updateParticle(GravityParticle *a, GravityParticle *b,
PressSmoothUpdate *params, PressSmoothParticle *aParams,
PressSmoothParticle *bParams, int sign);
#endif // SPHUTILS_H