30 void PrimRHS (
double *w,
double *dw,
double cs2,
double h,
double *Adw)
47 double rho, u1, u2, u3;
49 double g, v1, v2, v3, gx2;
57 scrh = EXPAND(u1*u1, + u2*u2, + u3*u3);
60 d_2 = g/(g2 - scrh*cs2);
68 gx2 = 1.0/(1.0 - v1*v1);
70 scrh = EXPAND(v1*dw[
VXn], + v2*dw[
VXt], + v3*dw[
VXb]);
72 Adw[PRS] = d_2*(rho*h*cs2*(dw[
VXn] - v1*
scrh)
73 + u1*(1.0 - cs2)*dw[PRS]);
75 Adw[
RHO] = v1*dw[
RHO] - (v1*dw[PRS] - Adw[PRS])/(h*cs2);
78 d_2 = u1*dw[PRS] - g*Adw[PRS];
80 EXPAND(Adw[VXn] = v1*dw[VXn] + scrh*(dw[PRS] + u1*d_2); ,
81 Adw[
VXt] = v1*dw[
VXt] + scrh*u2*d_2; ,
82 Adw[
VXb] = v1*dw[
VXb] + scrh*u3*d_2;)
90 g2 = EXPAND(v1*v1, + v2*v2, + v3*v3);
91 d_2 = 1.0/(1.0 - g2*cs2);
94 Adw[PRS] = d_2*(cs2*rho*h*dw[
VXn]
95 + v1*(1.0 - cs2)*dw[PRS]);
97 Adw[
RHO] = v1*dw[
RHO] - (v1*dw[PRS] - Adw[PRS])/(h*cs2);
99 scrh = 1.0/(g2*rho*h);
100 EXPAND(Adw[VXn] = v1*dw[VXn]
101 + scrh*(dw[PRS] - v1*Adw[PRS]); ,
102 Adw[
VXt] = v1*dw[
VXt] - scrh*v2*Adw[PRS]; ,
103 Adw[
VXb] = v1*dw[
VXb] - scrh*v3*Adw[PRS];)
114 double *a2,
double *h,
double **src,
Grid *grid)
141 double *
q, *x1, *x2, *x3, g[3];
143 #if GEOMETRY == CYLINDRICAL
153 for (i = beg; i <= end; i++){
154 for (nv =
NVAR; nv--; ){
158 #if GEOMETRY == CARTESIAN
160 #elif GEOMETRY == CYLINDRICAL
163 for (i = beg; i <= end; i++) {
170 scrh = sqrt(1.0 + vel2);
171 alpha = q[
VXn]*r_1*scrh/(1.0 + vel2*(1.0 - a2[
i]));
173 print1 (
"! Primitive source terms not yet implemented\n");
174 print1 (
"! with 4-vel. Please try 3-vel\n");
177 alpha = q[
VXn]*r_1/(1.0 - a2[
i]*
vel2);
178 scrh = a2[
i]*(1.0 -
vel2)*alpha;
182 EXPAND (src[i][VX1] = scrh*q[VX1]; ,
192 src[i][PRS] = -a2[i]*q[
RHO]*h[i]*alpha;
197 #elif GEOMETRY == SPHERICAL && DIMENSIONS == 1 && COMPONENTS == 1
200 for (i = beg; i <= end; i++) {
207 print1 (
"! PrimRHSD(): primitive source terms not yet implemented\n");
208 print1 (
"! with 4-vel. Please try 3-vel\n");
211 delta = 1.0 - vel2*a2[
i];
212 scrh = 2.0*q[
iVR]/delta*r_1;
216 EXPAND (src[i][VX1] = scrh*q[VX1]*a2[i]*(1.0 - vel2); ,
220 src[i][PRS] = src[i][
RHO]*h[i]*a2[i];
226 print1 (
"! PrimRHS(): primitive source terms not available for this geometry\n");
227 print1 (
"! Use RK integrators\n");
236 #if (BODY_FORCE != NO)
239 #if BODY_FORCE & POTENTIAL
242 for (i = beg; i <= end; i++){
243 #if BODY_FORCE & VECTOR
248 #if BODY_FORCE & POTENTIAL
250 src[
i][
VX1] -= (gPhi[
i] - gPhi[i-1])/(hscale*dx1[i]);
260 #if BODY_FORCE & POTENTIAL
263 for (i = beg; i <= end; i++){
264 #if BODY_FORCE & VECTOR
269 #if BODY_FORCE & POTENTIAL
271 src[
i][
VX2] -= (gPhi[
i] - gPhi[i-1])/(hscale*dx2[i]);
274 #if DIMENSIONS == 2 && COMPONENTS == 3
279 #if BODY_FORCE & POTENTIAL
282 for (i = beg; i <= end; i++){
283 #if BODY_FORCE & VECTOR
288 #if BODY_FORCE & POTENTIAL
290 src[
i][
VX3] -= (gPhi[
i] - gPhi[i-1])/(hscale*dx3[i]);
double ** v
Cell-centered primitive varables at the base time level, v[i] = .
void print1(const char *fmt,...)
int g_i
x1 grid index when sweeping along the x2 or x3 direction.
void PrimSource(const State_1D *state, int beg, int end, double *a2, double *h, double **src, Grid *grid)
int g_dir
Specifies the current sweep or direction of integration.
int g_j
x2 grid index when sweeping along the x1 or x3 direction.
double * xgc
Cell volumetric centroid (!= x when geometry != CARTESIAN).
double BodyForcePotential(double, double, double)
int g_k
x3 grid index when sweeping along the x1 or x2 direction.
void PrimRHS(double *v, double *dv, double cs2, double h, double *Adv)
void BodyForceVector(double *, double *, double, double, double)
#define QUIT_PLUTO(e_code)