19 #include "PatchPluto.H"
23 void PatchPluto::saveFluxes (
const State_1D *state,
int beg,
int end,
32 double **f, *p, r, area;
37 for (i = beg; i <=
end; i++) f[i][
MXn] += p[i];
39 #if (GEOMETRY == CARTESIAN) && (CH_SPACEDIM > 1)
40 if ((
g_dir ==
IDIR) && (g_stretch_fact != 1.)) {
41 for (i = beg; i <=
end; i++) {
42 VAR_LOOP(nv) f[i][nv] *= g_stretch_fact;
45 #if (CH_SPACEDIM == 3)
46 if ((
g_dir ==
JDIR) && (g_x3stretch != 1.)) {
47 for (i = beg; i <=
end; i++) {
48 VAR_LOOP(nv) f[i][nv] *= g_x3stretch;
52 for (i = beg; i <=
end; i++) {
53 VAR_LOOP(nv) f[i][nv] *= g_x2stretch;
59 #if GEOMETRY == CYLINDRICAL
61 for (i = beg; i <=
end; i++) {
62 for (nv = 0; nv <
NVAR; nv++) {
65 f[
i][nv] *= g_x2stretch;
70 for (i = beg; i <=
end; i++) {
71 for (nv = 0; nv <
NVAR; nv++) {
77 #if GEOMETRY == SPHERICAL
85 for (i = beg; i <=
end; i++) {
86 for (nv = 0; nv <
NVAR; nv++) {
92 #if (COMPONENTS == 3) && (ENTROPY_SWITCH)
99 #if CHOMBO_LOGR == YES
105 for (i = beg; i <=
end; i++) {
106 for (nv = 0; nv <
NVAR; nv++) {
107 f[
i][nv] *= grid[
JDIR].
A[
i]*area;
109 #if (COMPONENTS == 3) && (ENTROPY_SWITCH)
115 area = g_x2stretch*fabs(grid[
IDIR].
x[
g_i]);
116 #if CHOMBO_LOGR == YES
119 for (i = beg; i <=
end; i++) {
120 for (nv = 0; nv <
NVAR; nv++) {
123 #if (COMPONENTS == 3) && (ENTROPY_SWITCH)
130 #if GEOMETRY == POLAR
132 for (i = beg; i <=
end; i++) {
133 for (nv = 0; nv <
NVAR; nv++) {
136 f[
i][nv] *= g_x2stretch;
139 f[
i][nv] *= g_x3stretch;
142 #if (COMPONENTS > 1) && (ENTROPY_SWITCH)
149 #if CHOMBO_LOGR == YES
153 for (i = beg; i <=
end; i++) {
154 for (nv = 0; nv <
NVAR; nv++) {
157 #if (COMPONENTS > 1) && (ENTROPY_SWITCH)
162 area = g_x2stretch*fabs(grid[
IDIR].
x[
g_i]);
163 #if CHOMBO_LOGR == YES
166 for (i = beg; i <=
end; i++) {
167 for (nv = 0; nv <
NVAR; nv++) {
170 #if (COMPONENTS > 1) && (ENTROPY_SWITCH)
189 int lft_side[3] = {0,0,0}, rgt_side[3]={0,0,0};
190 static unsigned char ***flagEntr;
202 lft_side[dir] = (grid[dir -
IDIR].
lbound != 0);
203 rgt_side[dir] = (grid[dir -
IDIR].
rbound != 0);
211 cbox.
ib = 0; cbox.
ie = nx - 1;
212 cbox.
jb = 0; cbox.
je = ny - 1;
213 cbox.
kb = 0; cbox.
ke = nz - 1;
225 if (rgt_side[JDIR]) cbox.je =
JEND; ,
226 if (rgt_side[KDIR]) cbox.ke =
KEND;)
238 if (flagEntr == NULL) {
243 flagEntr[
k][
j][
i] = 0;
264 #if INTERNAL_BOUNDARY == YES
268 if (lft_side[IDIR]) {
273 if (lft_side[JDIR]) {
278 if (lft_side[KDIR]) {
283 if (rgt_side[IDIR]) {
288 if (rgt_side[JDIR]) {
293 if (rgt_side[KDIR]) {
302 void PatchPluto::showPatch (
Grid *grid)
318 print (
"+-----------------------------------------------------------+\n");
320 print (
"| ib,ie = [%d, %d], xb,xe = %s[%f, %f]%s\n",
323 print (
"| jb,je = [%d, %d], yb,ye = %s[%f, %f]%s\n",
324 JBEG, JEND, (Gy->lbound != 0 ? pb:ib),
325 Gy->xr[
JBEG-1], Gy->xr[JEND], (Gy->rbound != 0 ? pb:ib));
326 print (
"+-----------------------------------------------------------+\n");
331 void PatchPluto::convertFArrayBox(FArrayBox& U)
340 int ibeg, jbeg, kbeg;
341 int iend, jend, kend;
344 static unsigned char *flag;
345 static double **u, **v;
354 jbeg = jend = kbeg = kend = 0;
356 iend = U.hiVect()[
IDIR]; ,
357 jbeg = U.loVect()[
JDIR];
358 jend = U.hiVect()[
JDIR]; ,
359 kbeg = U.loVect()[
KDIR];
360 kend = U.hiVect()[
KDIR]; );
362 for (nv=0; nv<
NVAR; nv++) {
363 UU[nv] =
ArrayBoxMap(kbeg,kend,jbeg,jend,ibeg,iend,U.dataPtr(nv));
366 box.
ib = ibeg+IOFFSET; box.
ie = iend-IOFFSET;
367 box.
jb = jbeg+JOFFSET; box.
je = jend-JOFFSET;
368 box.
kb = kbeg+KOFFSET; box.
ke = kend-KOFFSET;
376 for (k = kbeg + KOFFSET; k <= kend - KOFFSET; k++){
377 for (j = jbeg + JOFFSET; j <= jend - JOFFSET; j++){
378 for (i = ibeg + IOFFSET; i <= iend - IOFFSET; i++){
380 NVAR_LOOP(nv) u[i-ibeg][nv] = UU[nv][k][j][i];
382 ConsToPrim (u, v, IOFFSET, iend-ibeg-IOFFSET, flag);
383 for (i = ibeg; i <= iend; i++){
384 NVAR_LOOP(nv) UU[nv][k][j][i] = v[i-ibeg][nv];
388 for (nv = 0; nv < NVAR; nv++)
#define X3_BEG
Boundary region at X3 beg.
void Boundary(const Data *d, int idim, Grid *grid)
#define X1_BEG
Boundary region at X1 beg.
int lbound
When different from zero, it specifies the boundary condition to be applied at leftmost grid side whe...
int level
The current refinement level (chombo only).
int end
Global end index for the local array.
int jb
Lower corner index in the x2 direction.
double ** flux
upwind flux computed with the Riemann solver
void PrimToCons3D(Data_Arr V, Data_Arr U, RBox *box)
int rbound
Same as lbound, but for the right edge of the grid.
double **** Vc
The main four-index data array used for cell-centered primitive variables.
int kb
Lower corner index in the x3 direction.
#define X1_END
Boundary region at X1 end.
#define ARRAY_3D(nx, ny, nz, type)
#define TOT
Computational domain (total)
unsigned char *** flag
Pointer to a 3D array setting useful integration flags that are retrieved during integration.
void ConsToPrim3D(Data_Arr U, Data_Arr V, unsigned char ***flag, RBox *box)
int ib
Lower corner index in the x1 direction.
int g_i
x1 grid index when sweeping along the x2 or x3 direction.
#define FLAG_ENTROPY
Update pressure using entropy equation.
int g_dir
Specifies the current sweep or direction of integration.
int beg
Global start index for the local array.
int ConsToPrim(double **ucons, double **uprim, int ibeg, int iend, unsigned char *flag)
int g_j
x2 grid index when sweeping along the x1 or x3 direction.
#define X2_END
Boundary region at X2 end.
long int IEND
Upper grid index of the computational domain in the the X1 direction for the local processor...
void print(const char *fmt,...)
#define X3_END
Boundary region at X3 end.
#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.
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.
double *** ArrayBoxMap(int nrl, int nrh, int ncl, int nch, int ndl, int ndh, double *uptr)
double * press
Upwind pressure term computed with the Riemann solver.
void FreeArrayBoxMap(double ***t, int nrl, int nrh, int ncl, int nch, int ndl, int ndh)
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
#define X2_BEG
Boundary region at X2 beg.
#define ARRAY_2D(nx, ny, type)
int np_tot
Total number of points in the local domain (boundaries included).
long int KEND
Upper grid index of the computational domain in the the X3 direction for the local processor...
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...
double * A
Right interface area, A[i] = .