@@ -96,22 +96,16 @@ void main_main ()
9696 // **********************************
9797 // SIMULATION SETUP
9898
99- // make BoxArray and Geometry
100- // ba will contain a list of boxes that cover the domain
101- // geom contains information such as the physical domain size,
102- // number of points in the domain, and periodicity
103- BoxArray ba;
104- Geometry geom;
105-
10699 // AMREX_D_DECL means "do the first X of these, where X is the dimensionality of the simulation"
107100 IntVect dom_lo (AMREX_D_DECL ( 0 , 0 , 0 ));
108101 IntVect dom_hi (AMREX_D_DECL (n_cell-1 , n_cell-1 , n_cell-1 ));
109102
110103 // Make a single box that is the entire domain
111104 Box domain (dom_lo, dom_hi);
112105
106+ // ba will contain a list of boxes that cover the domain
113107 // Initialize the boxarray "ba" from the single box "domain"
114- ba. define (domain);
108+ BoxArray ba (domain);
115109
116110 // Break up boxarray "ba" into chunks no larger than "max_grid_size" along a direction
117111 ba.maxSize (max_grid_size);
@@ -123,8 +117,10 @@ void main_main ()
123117 // periodic in all direction
124118 Array<int ,AMREX_SPACEDIM> is_periodic{AMREX_D_DECL (1 ,1 ,1 )};
125119
120+ // geom contains information such as the physical domain size,
121+ // number of points in the domain, and periodicity
126122 // This defines a Geometry object
127- geom. define (domain, real_box, CoordSys::cartesian, is_periodic);
123+ Geometry geom (domain, real_box, CoordSys::cartesian, is_periodic);
128124
129125 // extract dx from the geometry object
130126 GpuArray<Real,AMREX_SPACEDIM> dx = geom.CellSizeArray ();
@@ -232,15 +228,28 @@ void main_main ()
232228 amrex::Print () << " Total evolution time = " << evolution_stop_time << " seconds\n " ;
233229
234230 // exact solution
235- MultiFab phi_exact (ba, dm, Ncomp, 0 );
231+ BoxArray ba_exact (domain);
232+ DistributionMapping dm_exact (ba_exact);
233+ MultiFab phi_exact (ba_exact, dm_exact, Ncomp, n_cell);
236234 InitializeData (phi_exact,dx,prob_lo,prob_hi,time,advCoeffx,advCoeffy);
237- const std::string& pltfile = amrex::Concatenate (" exact" ,nsteps,5 );
238- WriteSingleLevelPlotfile (pltfile, phi_exact, {" phi" }, geom, time, nsteps);
235+ phi_exact.SumBoundary (geom.periodicity ());
239236
237+ {
238+ const std::string& pltfile = amrex::Concatenate (" exact" ,nsteps,5 );
239+ WriteSingleLevelPlotfile (pltfile, phi_exact, {" phi" }, geom, time, nsteps);
240+ }
241+
242+ MultiFab phi_exact_dist (ba,dm,Ncomp,0 );
243+ phi_exact_dist.ParallelCopy (phi_exact,0 ,0 ,1 );
240244
241- MultiFab::Subtract (phi_exact,phi,0 ,0 ,1 ,0 );
242- Real error = phi_exact.norm1 (0 ,geom.periodicity ());
245+ MultiFab::Subtract (phi_exact_dist,phi,0 ,0 ,1 ,0 );
243246
247+ {
248+ const std::string& pltfile = amrex::Concatenate (" diff" ,nsteps,5 );
249+ WriteSingleLevelPlotfile (pltfile, phi_exact_dist, {" phi" }, geom, time, nsteps);
250+ }
251+
252+ Real error = phi_exact_dist.norm1 (0 ,geom.periodicity ());
244253 amrex::Print () << " L1 error = " << error << std::endl;
245254}
246255
@@ -251,6 +260,8 @@ void InitializeData(MultiFab& phi,
251260 const Real& time,
252261 const Real& Ax,
253262 const Real& Ay) {
263+
264+ int ng = phi.nGrow ();
254265
255266 GpuArray<Real,AMREX_SPACEDIM> L;
256267 for (int d=0 ; d<AMREX_SPACEDIM; ++d) {
@@ -260,7 +271,7 @@ void InitializeData(MultiFab& phi,
260271 // loop over boxes
261272 for (MFIter mfi (phi); mfi.isValid (); ++mfi)
262273 {
263- const Box& bx = mfi.validbox ( );
274+ const Box& bx = mfi.growntilebox (ng );
264275 const Array4<Real>& phi_array = phi.array (mfi);
265276
266277 Real sigma = 0.1 ;
0 commit comments