5 #include "PatchPluto.H"
7 void PatchPluto::startup(FArrayBox& a_U)
10 int isub, jsub, ksub, nsub = 5;
11 int nxtot, nytot, nztot;
13 int ibg, ieg, jbg, jeg, kbg, keg;
14 static double **ucons, **uprim;
18 double us[256], u_av[256], b[3];
23 Box curBox = a_U.box();
26 FArrayBox
dV(curBox,CHOMBO_NDV);
28 curBox.grow(-m_numGhost);
30 setGrid(curBox,grid,
dV);
32 jbg = jeg = kbg = keg = 0;
34 D_EXPAND(ibg = a_U.loVect()[0]; ieg = a_U.hiVect()[0]; ,
35 jbg = a_U.loVect()[1]; jeg = a_U.hiVect()[1]; ,
36 kbg = a_U.loVect()[2]; keg = a_U.hiVect()[2];)
38 NX1_TOT = nxtot = ieg - ibg + 1;
39 NX2_TOT = nytot = jeg - jbg + 1;
40 NX3_TOT = nztot = keg - kbg + 1;
47 for (nv=0 ; nv<
NVAR ; nv ++)
48 UU[nv] =
ArrayMap(nztot,nytot,nxtot,a_U.dataPtr(nv));
62 tbox.
ib = 0; tbox.
ie = nxtot-1;
63 tbox.
jb = 0; tbox.
je = nytot-1;
64 tbox.
kb = 0; tbox.
ke = nztot-1;
75 for (nv = 0; nv <
NVAR; nv++) UU[nv][k][j][i] = u_av[nv] = 0.0;
85 #if INITIAL_SMOOTHING == YES
87 for (ksub = 0; ksub < nsub; ksub++){
88 for (jsub = 0; jsub < nsub; jsub++){
89 for (isub = 0; isub < nsub; isub++){
91 x1s = x1 + (double)(1.0 - nsub + 2.0*isub)/(double)(2.0*nsub)*dx1;
92 x2s = x2 + (double)(1.0 - nsub + 2.0*jsub)/(double)(2.0*nsub)*dx2;
93 x3s = x3 + (double)(1.0 - nsub + 2.0*ksub)/(double)(2.0*nsub)*dx3;
95 Init (us, x1s, x2s, x3s);
96 for (nv = 0; nv <
NVAR; nv++) {
97 u_av[nv] += us[nv]/(double)(nsub*nsub*nsub);
103 Init (u_av, x1, x2, x3);
107 for (nv = 0; nv <
NVAR; nv++) UU[nv][k][j][i] = u_av[nv];
109 #if (PHYSICS == MHD || PHYSICS == RMHD)
110 #if ASSIGN_VECTOR_POTENTIAL == YES
112 for (nv = 0; nv <
DIMENSIONS; nv++) UU[
BX1+nv][k][j][i] = b[nv];
122 for (k = 0; k < nztot ; k++) {
123 for (j = 0; j < nytot ; j++) {
125 for (i = 0; i < nxtot; i++) {
126 for (nv = 0 ; nv <
NVAR ; nv++) {
127 us[nv] = uprim[
i][nv] = UU[nv][
k][
j][
i];
132 if (us[
RHO] <= 0.0) {
133 print (
"! startup: density is negative\n");
136 #if EOS != ISOTHERMAL
137 if (us[PRS] <= 0.0) {
138 print (
"! startup: pressure is negative\n");
142 #if (PHYSICS == RHD) || (PHYSICS == RMHD)
145 print (
"! startup: total velocity exceeds 1\n");
152 for (i = 0; i < nxtot; i++) {
153 for (nv = 0; nv <
NVAR; nv++) {
154 UU[nv][
k][
j][
i] = ucons[
i][nv];
158 Entropy(uprim, UU[ENTR][k][j], 0, nxtot-1);
159 for (i = 0; i < nxtot; i++) {
170 #if GEOMETRY != CARTESIAN
171 #if CHOMBO_CONS_AM == YES
172 #if ROTATING_FRAME == YES
173 Box aBox = a_U.box();
174 for(BoxIterator bit(aBox); bit.ok(); ++bit) {
175 const IntVect& iv = bit();
183 for (nv = 0; nv < a_U.nComp(); nv++) a_U.mult(
dV,0,nv);
185 if (g_stretch_fact != 1.) a_U *= g_stretch_fact;
int jb
Lower corner index in the x2 direction.
#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 kb
Lower corner index in the x3 direction.
void FreeArrayMap(double ***t)
int ib
Lower corner index in the x1 direction.
void Entropy(double **v, double *s, int beg, int end)
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
void print(const char *fmt,...)
void Init(double *, double, double, double)
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.
void PrimToCons(double **uprim, double **ucons, int ibeg, int iend)
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 VectorPotentialDiff(double *, int, int, int, Grid *)
#define ARRAY_2D(nx, ny, type)
#define QUIT_PLUTO(e_code)
long int NX1_TOT
Total number of zones in the X1 direction (boundaries included) for the local processor.
double *** ArrayMap(int nx, int ny, int nz, double *uptr)