@@ -29,10 +29,10 @@ int main (int argc, char* argv[])
2929
3030 // physical dimensions of the domain
3131 Real prob_lo_x = 0 .;
32- Real prob_lo_y = 0 .;
33- Real prob_lo_z = 0 .;
3432 Real prob_hi_x = 1 .;
33+ Real prob_lo_y = 0 .;
3534 Real prob_hi_y = 1 .;
35+ Real prob_lo_z = 0 .;
3636 Real prob_hi_z = 1 .;
3737
3838 // **********************************
@@ -47,25 +47,33 @@ int main (int argc, char* argv[])
4747
4848 pp.get (" n_cell_x" ,n_cell_x);
4949 pp.get (" n_cell_y" ,n_cell_y);
50+ #if (AMREX_SPACEDIM == 3)
5051 pp.get (" n_cell_z" ,n_cell_z);
52+ #endif
5153
5254 pp.get (" max_grid_size_x" ,max_grid_size_x);
5355 pp.get (" max_grid_size_y" ,max_grid_size_y);
56+ #if (AMREX_SPACEDIM == 3)
5457 pp.get (" max_grid_size_z" ,max_grid_size_z);
58+ #endif
5559
5660 pp.query (" prob_lo_x" ,prob_lo_x);
57- pp.query (" prob_lo_y" ,prob_lo_y);
58- pp.query (" prob_lo_z" ,prob_lo_z);
59-
6061 pp.query (" prob_hi_x" ,prob_hi_x);
62+ pp.query (" prob_lo_y" ,prob_lo_y);
6163 pp.query (" prob_hi_y" ,prob_hi_y);
64+ #if (AMREX_SPACEDIM == 3)
65+ pp.query (" prob_lo_z" ,prob_lo_z);
6266 pp.query (" prob_hi_z" ,prob_hi_z);
67+ #endif
68+
6369 }
6470
6571 // Determine the domain length in each direction
66- Real L_x = std::abs (prob_hi_x - prob_lo_x);
67- Real L_y = std::abs (prob_hi_y - prob_lo_y);
68- Real L_z = std::abs (prob_hi_z - prob_lo_z);
72+ Real cen_x = (prob_hi_x - prob_lo_x) / 2 .;
73+ Real cen_y = (prob_hi_y - prob_lo_y) / 2 .;
74+ #if (AMREX_SPACEDIM == 3)
75+ Real cen_z = (prob_hi_z - prob_lo_z) / 2 .;
76+ #endif
6977
7078 // define lower and upper indices of domain
7179 IntVect dom_lo (AMREX_D_DECL ( 0 , 0 , 0 ));
@@ -122,11 +130,14 @@ int main (int argc, char* argv[])
122130 // SET VALUES FOR EACH CELL
123131 // **********************************
124132
125- Real x = (i+0.5 ) * dx[0 ];
126- Real y = (AMREX_SPACEDIM>=2 ) ? (j+0.5 ) * dx[1 ] : 0 .;
127- Real z = (AMREX_SPACEDIM==3 ) ? (k+0.5 ) * dx[2 ] : 0 .;
128-
129- phi_ptr (i,j,k) = std::exp (-10 .*((x-0.5 )*(x-0.5 )+(y-0.5 )*(y-0.5 )+(z-0.5 )*(z-0.5 )));
133+ Real x = prob_lo_x + (i+0.5 ) * dx[0 ];
134+ Real y = prob_lo_y + (j+0.5 ) * dx[1 ];
135+ #if (AMREX_SPACEDIM == 2)
136+ phi_ptr (i,j,k) = std::exp (-500 .*((x-cen_x)*(x-cen_x)+(y-cen_y)*(y-cen_y)));
137+ #elif (AMREX_SPACEDIM == 3)
138+ Real z = prob_lo_z + (k+0.5 ) * dx[2 ];
139+ phi_ptr (i,j,k) = std::exp (-500 .*((x-cen_x)*(x-cen_x)+(y-cen_y)*(y-cen_y)+(z-cen_z)*(z-cen_z)));
140+ #endif
130141
131142 });
132143 }
@@ -161,17 +172,14 @@ int main (int argc, char* argv[])
161172 my_fft.backward (phi_after);
162173
163174 // scale phi_after by 1/n_cells so it matches the original phi
164- long n_cells = n_cell_x;
165- if (AMREX_SPACEDIM >= 2 ) n_cells *= n_cell_y;
166- if (AMREX_SPACEDIM >= 3 ) n_cells *= n_cell_z;
175+ long n_cells = (AMREX_SPACEDIM == 2 ) ? n_cell_x*n_cell_y : n_cell_x*n_cell_y*n_cell_z;
167176 phi_after.mult (1 ./n_cells);
168177
169178 // time and step are dummy variables required to WriteSingleLevelPlotfile
170179 Real time = 0 .;
171180 int step = 0 ;
172181
173- Box cdomain = geom.Domain ();
174- cdomain.setBig (0 ,cdomain.length (0 )/2 );
182+ Box cdomain = cba.minimalBox ();
175183 Geometry cgeom (cdomain, real_box, CoordSys::cartesian, is_periodic);
176184
177185 // arguments
0 commit comments