31 #define small_p 1.e-12
32 #define small_rho 1.e-12
33 #define INTERPOLATE_RAREFACTION YES
35 #define accuracy 1.e-6
38 static void TwoShock_Shock (
double,
double,
double,
double,
double,
double,
39 double,
double *,
double *,
double *,
int);
46 double *cmax,
Grid *grid)
60 int k, nfail = 0, izone_fail[1024];
62 double gL, gR, gL1, gR1;
63 double uxR, uxR1, pR, j2R, wR, VR, VR1;
64 double uxL, uxL1, pL, j2L, wL, VL, VL1;
65 double duR, duL, p1, u1, dp, a0, a1;
66 double tauR, tauL, am, ap;
68 static double **fl, **us, **ws;
69 static double *hR, *hL, *a2L, *a2R, *cmax_loc, *cmin_loc;
71 static double **fL, **fR, *prL, *prR;
108 for (i = beg; i <= end; i++) {
110 #if SHOCK_FLATTENING == MULTID
112 HLL_Speed (state->
vL, state->
vR, a2L, a2R, &gL - i, &gR - i, i, i);
113 Flux (state->
uL, state->
vL, a2L, fL, prL, i, i);
114 Flux (state->
uR, state->
vR, a2R, fR, prR, i, i);
116 a0 =
MAX(fabs(gR), fabs(gL));
122 for (nv =
NFLX; nv--; ){
123 state->
flux[
i][nv] = gL*gR*(state->
uR[
i][nv] - state->
uL[
i][nv])
124 + gR*fL[i][nv] - gL*fR[i][nv];
125 state->
flux[
i][nv] *= a0;
127 state->
press[
i] = (gR*prL[
i] - gL*prR[
i])*a0;
158 j2R = tauR*(hR[
i]*(
gmmr - 2.0) + 1.0) / (
gmmr*pR);
159 j2L = tauL*(hL[
i]*(
gmmr - 2.0) + 1.0) / (
gmmr*pL);
162 a0 = (5.0*hR[
i] - 8.0*wR)/(2.0*hR[i] - 5.0*wR);
163 j2R = -tauR*(a0*wR + hR[
i]*(1.0 - a0))/(a0*pR);
165 a0 = (5.0*hL[
i] - 8.0*wL)/(2.0*hL[i] - 5.0*wL);
166 j2L = -tauL*(a0*wL + hL[
i]*(1.0 - a0))/(a0*pL);
169 gR1 = sqrt(VR*VR + (1.0 - uxR*uxR)*j2R);
172 gL1 = -sqrt(VL*VL + (1.0 - uxL*uxL)*j2L);
175 duR = gR1/(hR[
i]*gR);
176 duL = gL1/(hL[
i]*gL);
178 p1 = ql[
VXn] - qr[
VXn] + duR*pR - duL*pL;
189 for (iter = 1; iter <
MAX_ITER; iter++) {
191 TwoShock_Shock (tauL, uxL, pL, gL, VL, hL[i], p1, &uxL1, &duL, &wL, -1);
192 TwoShock_Shock (tauR, uxR, pR, gR, VR, hR[i], p1, &uxR1, &duR, &wR, 1);
196 dp = (uxR1 - uxL1)/(duL - duR);
197 if (-dp > p1) dp = -0.5*p1;
205 if ( (fabs(dp) <
accuracy*p1) )
break;
212 u1 = 0.5*(uxR1 + uxL1);
216 if (u1 != u1 || iter == MAX_ITER) {
218 u1 = 0.5*(uxL + uxR);
221 izone_fail[nfail] =
i;
222 for (nv =
NFLX; nv--; ){
245 gL1 = gL*hL[
i]/(gL*hL[
i] + (p1 - pL)*(VL + wL*uxL));
246 Ustar[
VXt] = ql[
VXt]*gL1; ,
247 Ustar[
VXb] = ql[
VXb]*gL1;)
249 VL1 = VL - (u1 - uxL)*wL;
255 #if INTERPOLATE_RAREFACTION == YES
261 ap = am = VL/wL + uxL;
264 am = ap = VL/wL + uxL;
268 for (nv =
NFLX; nv--;) ws[i][nv] = ql[nv];
270 }
else if (ap <= 0.0) {
272 for (nv =
NFLX; nv--;) ws[i][nv] = Ustar[nv];
276 for (nv =
NFLX; nv--;) {
277 ws[
i][nv] = (am*Ustar[nv] - ap*ql[nv])/(am - ap);
284 gR1 = gR*hR[
i]/(gR*hR[
i] + (p1 - pR)*(VR + wR*uxR));
285 Ustar[
VXt] = qr[
VXt]*gR1; ,
286 Ustar[
VXb] = qr[
VXb]*gR1;)
289 VR1 = VR - (u1 - uxR)*wR;
292 #if INTERPOLATE_RAREFACTION == YES
298 am = ap = VR/wR + uxR;
301 am = ap = VR/wR + uxR;
306 for (nv =
NFLX; nv--;) ws[i][nv] = qr[nv];
308 }
else if (am >= 0.0){
310 for (nv =
NFLX; nv--;) ws[i][nv] = Ustar[nv];
314 for (nv =
NFLX; nv--;) {
315 ws[
i][nv] = (ap*Ustar[nv] - am*qr[nv])/(ap - am);
328 a0 =
MAX(fabs(cmax_loc[i]), fabs(cmin_loc[i]));
335 #ifdef ARTIFICIAL_VISC
336 for (i = beg; i <= end; i++){
338 for (nv = 0; nv <
NFLX; nv++) {
339 state->
flux[
i][nv] += a0*(state->
uL[
i][nv] - state->
uR[
i][nv]);
349 for (k = 1; k <= nfail; k++){
350 print1 (
"! Failure in Riemann - substituting HLL flux: ");
351 Where (izone_fail[k],NULL);
352 HLL_Solver (state, izone_fail[k]-2, izone_fail[k]+3, cmax, grid);
366 double wl2, beta_fix=0.9999,
scrh;
372 print (
"! u2 > 1 (%12.6e) in TwoShock_Lorentz\n",
scrh);
374 EXPAND(U[VX1] *=
scrh; ,
377 scrh = beta_fix*beta_fix;
381 wl2 = 1.0/(1.0 -
scrh);
388 double V0,
double h0,
double p1,
double *u1,
389 double *dudp,
double *zeta,
int istate)
396 double a,b,
c, da,db,dc, dp;
397 double tau1,h1,d_htau1,g1;
408 a = 1.0 - dp/(
gmmr*p1);
410 c = -h0*(h0 + tau0*dp);
412 h1 = 0.5/a*(-b + sqrt(b*b - 4.0*a*c));
413 tau1 = (h1 - 1.0)/(
gmmr*p1);
414 g1 = 2.0*h1*
gmmr/(2.0*h1 - 1.0);
416 j2 = h0*
gmmr*tau0 + (h1*tau1 + h0*tau0)*(1.0/(h0 + h1) - 1.0);
419 d_htau1 = (h1*tau1 + h0*tau0 - g1*h1*tau1);
420 d_htau1 /= (g1*p1 - dp);
423 a = p0*(3.0*p1 + p0);
424 b = -h0*h0*(3.0*p1 + 2.0*p0)
425 -h0*tau0*(3.0*p1*p1 - 7.0*p1*p0 - 4.0*p0*p0) - dp;
426 c = -h0*tau0*(h0*h0 + 2.0*h0*tau0*p1 + 2.0);
428 dx = 2.0*c*dp/(-b + sqrt(b*b - 4.0*a*c*dp));
430 g1 = 2.0*c/(-b + sqrt(b*b - 4.0*a*c*dp));
431 h1 = sqrt(h0*h0 + (dx + 2.0*h0*tau0)*dp);
436 db = -h0*h0*3.0 - h0*tau0*(6.0*p1 - 7.0*p0) - 1.0;
437 dc = c - h0*tau0*dp*2.0*h0*tau0;
439 d_htau1 = -(da*dx*dx + db*dx + dc)/(2.0*a*dx + b);
442 g1 = ((double)istate)*sqrt(V0*V0 + (1.0 - u0*u0)*j2);
443 *zeta = (V0*u0 + g1) / (1.0 - u0*u0);
449 b = 1.0/(h0*g0 + (p1 - p0)*((*zeta)*u0 +
V0));
450 *u1 = (h0*g0*u0 + (*zeta)*(p1 - p0)) * b;
456 a = -0.5*(d_htau1 + j2) / g1;
457 *dudp = ((*zeta) + a - (*u1)*((*zeta)*u0 + V0 + a*u0)) * b;
473 double vx, vt2,
vel2;
474 double sroot, delta2, cs2[1], h[1];
479 for (nv = 0; nv <
NFLX; nv++) q[0][nv] = w[nv];
487 sroot = cs2[0]*(1.0 - vx*vx - vt2*cs2[0])*(1.0 - vel2);
490 print (
"! sroot < 0 in RIemann \n");
491 for (nv = 0; nv <
NFLX; nv++){
498 delta2 = 1.0 - vel2*cs2[0];
499 return( (vx*(1.0 - cs2[0]) + (
double)iside*sroot)/delta2);
506 #undef INTERPOLATE_RAREFACTION
static double qglob_l[NFLX]
double ** flux
upwind flux computed with the Riemann solver
void print1(const char *fmt,...)
void Flux(double **u, double **w, double *a2, double **fx, double *p, int beg, int end)
void TwoShock_Solver(const State_1D *state, int beg, int end, double *cmax, Grid *grid)
int g_maxRiemannIter
Maximum number of iterations for iterative Riemann Solver.
double ** vR
Primitive variables to the right of the interface, .
void SoundSpeed2(double **v, double *cs2, double *h, int beg, int end, int pos, Grid *grid)
static void TwoShock_Shock(double, double, double, double, double, double, double, double *, double *, double *, int)
void print(const char *fmt,...)
static double qglob_r[NFLX]
double ** uR
same as vR, in conservative vars
#define ARRAY_1D(nx, type)
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
void PrimToCons(double **uprim, double **ucons, int ibeg, int iend)
Riemann_Solver HLL_Solver
void HLL_Speed(double **vL, double **vR, double *a2L, double *a2R, double *SL, double *SR, int beg, int end)
double ** vL
Primitive variables to the left of the interface, .
double * press
Upwind pressure term computed with the Riemann solver.
void MaxSignalSpeed(double **v, double *cs2, double *cmin, double *cmax, int beg, int end)
#define FLAG_HLL
Use HLL Riemann solver.
#define ARRAY_2D(nx, ny, type)
static double TwoShock_Lorentz(double *U, int n)
#define QUIT_PLUTO(e_code)
static double TwoShock_RarefactionSpeed(double *u, int side)
double ** uL
same as vL, in conservative vars