44 #define NVLAST (NVAR-1)
54 #define swR (1.0 - swL)
70 #if SB_SYMMETRIZE_HYDRO == NO
86 for (nv = 0; nv <=
NVLAST; nv++){
98 for (nv = 0; nv <=
NVLAST; nv++){
119 static double **fL, **fR;
120 static double ****Ftmp;
122 #if SB_SYMMETRIZE_HYDRO == NO
136 #if TIME_STEPPING == RK2
138 #elif TIME_STEPPING == RK3
176 if (grid[
IDIR].lbound != 0){
182 box.
ib = 0; box.
ie = 0;
184 box.
kb = 0; box.
ke = NX3_TOT-1;
188 for (nv = 0; nv <=
NVLAST; nv++) {
196 for (nv = 0; nv <=
NVLAST; nv++){
212 for (nv = 0; nv <=
NVLAST; nv++){
224 box.
ib = 0; box.
ie = 0;
226 box.
kb = 0; box.
ke = NX3_TOT-1;
230 for (nv = 0; nv <=
NVLAST; nv++) {
238 for (nv = 0; nv <=
NVLAST; nv++){
252 for (nv = 0; nv <=
NVLAST; nv++){
309 int dimx[3] = {1, 0, 0};
310 int dimy[3] = {0, 1, 0};
311 int dimz[3] = {0, 0, 1};
313 double tB, tE, w, dt, dtdy;
314 static double **BxL0, **BxL, ***dBxL_lim, *dBxL, ***eyL, ***ezL;
315 static double **BxR0, **BxR, ***dBxR_lim, *dBxR, ***eyR, ***ezR;
316 static double ***etmp, ***dBtmp;
318 #if (SB_SYMMETRIZE_EY == NO) && (SB_SYMMETRIZE_EZ == NO) \
319 && (SB_FORCE_EMF_PERIODS == NO)
355 if (grid[
IDIR].lbound != 0){
364 if (grid[
IDIR].lbound != 0){
367 if (grid[
IDIR].rbound != 0){
370 #elif TIME_STEPPING == RK2
375 BxL[
k][
j] = 0.5*(BxL0[
k][
j] + V0[
BX1s][
k][
j][IBEG - 1]);
381 #elif TIME_STEPPING == RK3
387 BxL[
k][
j] = 0.75*BxL0[
k][
j] + 0.25*V0[
BX1s][
k][
j][IBEG - 1];
397 BxL[
k][
j] = (BxL0[
k][
j] + 2.0*V0[
BX1s][
k][
j][IBEG - 1])/3.0;
410 if (grid[
IDIR].lbound != 0){
416 ezL[k][j][0] = emf->
ez[k][j][IBEG - 1]; ,
417 eyL[k][j][0] = emf->
ey[k][j][IBEG - 1];)
421 for (j = 1; j <=
JEND + nghost; j++) dBxL[j] = BxL[k][j] - BxL[k][j-1];
423 dBxL_lim[
k][
j][0] =
VAN_LEER(dBxL[j+1], dBxL[j]);
430 if (grid[
IDIR].rbound != 0){
436 ezR[k][j][0] = emf->
ez[k][j][IEND]; ,
437 eyR[k][j][0] = emf->
ey[k][j][IEND]; )
441 for (j = 1; j <=
JEND + nghost; j++) dBxR[j] = BxR[k][j] - BxR[k][j-1];
443 dBxR_lim[
k][
j][0] =
VAN_LEER(dBxR[j+1], dBxR[j]);
455 ExchangeX (dBxL_lim[0][0], dBxR_lim[0][0],
NX3_TOT*NX2_TOT, grid); ,
456 ExchangeX (eyL[0][0], eyR[0][0],
NX3_TOT*NX2_TOT, grid); )
465 if (grid[
IDIR].lbound != 0){
468 box.
ib = 0; box.
ie = 0;
469 box.
jb = 0; box.
je = NX2_TOT-1;
471 #if SB_SYMMETRIZE_EY == YES
475 BOX_LOOP((&box), k, j, i) etmp[k][j][i] = eyR[k][j][i];
492 #if SB_SYMMETRIZE_EZ == YES
497 dBtmp[
k][
j][
i] = dBxR_lim[
k][
j][
i];
498 etmp[
k][
j][
i] = ezR[
k][
j][
i];
502 for (k = KBEG; k <=
KEND; k++){
503 for (j =
JBEG - 1; j <=
JEND + 1; j++){
504 dBxL[
j] = 0.5*(dBxL_lim[
k][
j][0] + dBtmp[
k][
j][0]);
507 fE = w*(BxL[
k][
j] + 0.5*dBxL[
j]*(1.0 - w*dtdy));
508 emf->
ez[
k][
j][IBEG-1] = 0.5*(ezL[
k][
j][0] + etmp[
k][
j][0] + fE);
518 if (grid[
IDIR].rbound != 0){
520 box.
ib = 0; box.
ie = 0;
521 box.
jb = 0; box.
je = NX2_TOT-1;
524 #if SB_SYMMETRIZE_EY == YES
526 for (k = KBEG - 1; k <=
KEND; k++){
533 #if SB_SYMMETRIZE_EZ == YES
537 for (k = KBEG; k <=
KEND; k++){
538 for (j =
JBEG - 1; j <=
JEND + 1; j++){
539 dBxR[
j] = 0.5*(dBxL_lim[
k][
j][0] + dBxR_lim[
k][
j][0]);
542 fE = w*(BxR[
k][j + 1] - 0.5*dBxR[j + 1]*(1.0 - w*dtdy));
543 emf->
ez[
k][
j][
IEND] = 0.5*(ezR[
k][
j][0] + ezL[
k][
j][0] - fE);
553 #if DIMENSIONS == 3 && SB_FORCE_EMF_PERIODS == YES
558 MPI_Barrier (MPI_COMM_WORLD);
560 MPI_Barrier (MPI_COMM_WORLD);
563 for (i = IBEG ; i <=
IEND; i++){
564 esym = 0.5*(emf->
ex[KBEG - 1][
j][
i] + emf->
ex[
KEND][
j][
i]);
565 emf->
ex[KBEG - 1][
j][
i] = esym;
572 for (k = KBEG - 1; k <=
KEND; k++){
573 for (i = IBEG ; i <=
IEND; i++){
582 MPI_Barrier (MPI_COMM_WORLD);
584 MPI_Barrier (MPI_COMM_WORLD);
587 for (i = IBEG - 1; i <=
IEND; i++){
588 esym = 0.5*(emf->
ey[KBEG - 1][
j][
i] + emf->
ey[
KEND][
j][
i]);
589 emf->
ey[KBEG - 1][
j][
i] = esym;
596 for (k = KBEG ; k <=
KEND; k++){
597 for (i = IBEG - 1; i <=
IEND; i++){
599 ez[
k][
JBEG - 1][
i] = esym;
609 void ExchangeX (
double *bufL,
double *bufR,
int nel,
Grid *grid)
616 static int dest = -1;
617 int stag = 1, rtag = 1;
621 static int nprocs[3], periods[3], coords[3];
624 MPI_Barrier (MPI_COMM_WORLD);
632 if (grid[
IDIR].lbound != 0){
633 MPI_Cart_get(cartcomm, 3, nprocs, periods, coords);
634 coords[0] += nprocs[0] - 1;
635 MPI_Cart_rank (cartcomm, coords, &dest);
638 if (grid[
IDIR].rbound != 0){
639 MPI_Cart_get(cartcomm, 3, nprocs, periods, coords);
640 coords[0] += - nprocs[0] + 1;
641 MPI_Cart_rank (cartcomm, coords, &dest);
645 if (grid[
IDIR].lbound != 0){
647 MPI_Sendrecv (bufL, nel, MPI_DOUBLE, dest, stag,
648 bufR, nel, MPI_DOUBLE, dest, rtag,
649 MPI_COMM_WORLD, &istat);
653 if (grid[
IDIR].rbound != 0){
655 MPI_Sendrecv (bufR, nel, MPI_DOUBLE, dest, stag,
656 bufL, nel, MPI_DOUBLE, dest, rtag,
657 MPI_COMM_WORLD, &istat);
661 MPI_Barrier (MPI_COMM_WORLD);
int AL_Exchange_dim(char *buf, int *dims, int sz_ptr)
#define X1_BEG
Boundary region at X1 beg.
int jb
Lower corner index in the x2 direction.
double ** flux
upwind flux computed with the Riemann solver
#define BOX_LOOP(B, k, j, i)
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
int g_intStage
Gives the current integration stage of the time stepping method (predictor = 0, 1st corrector = 1...
int kb
Lower corner index in the x3 direction.
double g_dt
The current integration time step.
void SB_CorrectFluxes(Data_Arr U, double t, double dt, Grid *grid)
#define X1_END
Boundary region at X1 end.
#define ARRAY_3D(nx, ny, nz, type)
int ib
Lower corner index in the x1 direction.
int AL_Get_cart_comm(int, MPI_Comm *)
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.
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
#define ARRAY_4D(nx, ny, nz, nv, type)
int nghost
Number of ghost zones.
long int IEND
Upper grid index of the computational domain in the the X1 direction for the local processor...
double sb_vy
Velocity offset (>0), in SB_Boundary().
int g_k
x3 grid index when sweeping along the x1 or x2 direction.
#define ARRAY_1D(nx, type)
D_EXPAND(tot/[n]=(double) grid[IDIR].np_int_glob;, tot/[n]=(double) grid[JDIR].np_int_glob;, tot/[n]=(double) grid[KDIR].np_int_glob;)
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
double g_time
The current integration time.
int ie
Upper corner index in the x1 direction.
int ke
Upper corner index in the x3 direction.
int je
Upper corner index in the x2 direction.
void SB_SaveFluxes(State_1D *state, Grid *grid)
static double *** FluxL
Array of fluxes at the left x-boundary.
static double *** FluxR
Array of fluxes at the right x-boundary.
double * press
Upwind pressure term computed with the Riemann solver.
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
#define ARRAY_2D(nx, ny, type)
long int KEND
Upper grid index of the computational domain in the the X3 direction for the local processor...
double glm_ch
The propagation speed of divergence error.
long int JBEG
Lower grid index of the computational domain in the the X2 direction for the local processor...
long int JEND
Upper grid index of the computational domain in the the X2 direction for the local processor...
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...