@@ -29,10 +29,10 @@ int main (int argc, char* argv[])
29
29
30
30
// physical dimensions of the domain
31
31
Real prob_lo_x = 0 .;
32
- Real prob_lo_y = 0 .;
33
- Real prob_lo_z = 0 .;
34
32
Real prob_hi_x = 1 .;
33
+ Real prob_lo_y = 0 .;
35
34
Real prob_hi_y = 1 .;
35
+ Real prob_lo_z = 0 .;
36
36
Real prob_hi_z = 1 .;
37
37
38
38
// **********************************
@@ -47,25 +47,33 @@ int main (int argc, char* argv[])
47
47
48
48
pp.get (" n_cell_x" ,n_cell_x);
49
49
pp.get (" n_cell_y" ,n_cell_y);
50
+ #if (AMREX_SPACEDIM == 3)
50
51
pp.get (" n_cell_z" ,n_cell_z);
52
+ #endif
51
53
52
54
pp.get (" max_grid_size_x" ,max_grid_size_x);
53
55
pp.get (" max_grid_size_y" ,max_grid_size_y);
56
+ #if (AMREX_SPACEDIM == 3)
54
57
pp.get (" max_grid_size_z" ,max_grid_size_z);
58
+ #endif
55
59
56
60
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
-
60
61
pp.query (" prob_hi_x" ,prob_hi_x);
62
+ pp.query (" prob_lo_y" ,prob_lo_y);
61
63
pp.query (" prob_hi_y" ,prob_hi_y);
64
+ #if (AMREX_SPACEDIM == 3)
65
+ pp.query (" prob_lo_z" ,prob_lo_z);
62
66
pp.query (" prob_hi_z" ,prob_hi_z);
67
+ #endif
68
+
63
69
}
64
70
65
71
// 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
69
77
70
78
// define lower and upper indices of domain
71
79
IntVect dom_lo (AMREX_D_DECL ( 0 , 0 , 0 ));
@@ -122,11 +130,14 @@ int main (int argc, char* argv[])
122
130
// SET VALUES FOR EACH CELL
123
131
// **********************************
124
132
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
130
141
131
142
});
132
143
}
@@ -161,17 +172,14 @@ int main (int argc, char* argv[])
161
172
my_fft.backward (phi_after);
162
173
163
174
// 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;
167
176
phi_after.mult (1 ./n_cells);
168
177
169
178
// time and step are dummy variables required to WriteSingleLevelPlotfile
170
179
Real time = 0 .;
171
180
int step = 0 ;
172
181
173
- Box cdomain = geom.Domain ();
174
- cdomain.setBig (0 ,cdomain.length (0 )/2 );
182
+ Box cdomain = cba.minimalBox ();
175
183
Geometry cgeom (cdomain, real_box, CoordSys::cartesian, is_periodic);
176
184
177
185
// arguments
0 commit comments