@@ -63,10 +63,6 @@ int globalflags::AMRstencilWidth = VLASOV_STENCIL_WIDTH;
6363
6464extern Logger logFile, diagnostic;
6565
66- void initVelocityGridGeometry (dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid);
67- void initSpatialCellCoordinates (dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid);
68- void initializeStencils (dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid);
69-
7066void writeVelMesh (dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid) {
7167 const vector<CellID>& cells = getLocalCells ();
7268
@@ -157,7 +153,10 @@ void initializeGrids(
157153
158154
159155 phiprof::start (" Refine spatial cells" );
160- if (P::amrMaxSpatialRefLevel > 0 && project.refineSpatialCells (mpiGrid)) {
156+ recalculateLocalCellsCache ();
157+ // refineSpatialCells should be a nop if amrMaxSpatialRefLevel is 0. Make this better later
158+ if (project.refineSpatialCells (mpiGrid)) {
159+ mpiGrid.balance_load ();
161160 recalculateLocalCellsCache ();
162161 }
163162 phiprof::stop (" Refine spatial cells" );
@@ -184,6 +183,9 @@ void initializeGrids(
184183 phiprof::start (" Set spatial cell coordinates" );
185184 initSpatialCellCoordinates (mpiGrid);
186185 phiprof::stop (" Set spatial cell coordinates" );
186+
187+ SpatialCell::set_mpi_transfer_type (Transfer::CELL_DIMENSIONS);
188+ mpiGrid.update_copies_of_remote_neighbors (SYSBOUNDARIES_NEIGHBORHOOD_ID);
187189
188190 phiprof::start (" Initialize system boundary conditions" );
189191 if (sysBoundaries.initSysBoundaries (project, P::t_min) == false ) {
@@ -204,8 +206,8 @@ void initializeGrids(
204206 // Check refined cells do not touch boundary cells
205207 phiprof::start (" Check boundary refinement" );
206208 if (!sysBoundaries.checkRefinement (mpiGrid)) {
207- cerr << " (MAIN) ERROR : Boundary cells must have identical refinement level " << endl;
208- exit (1 );
209+ cerr << " (MAIN) WARNING : Boundary cells don't have identical refinement level " << endl;
210+ // exit(1);
209211 }
210212 phiprof::stop (" Check boundary refinement" );
211213
@@ -251,7 +253,8 @@ void initializeGrids(
251253
252254 // Update technicalGrid
253255 technicalGrid.updateGhostCells (); // This needs to be done at some point
254-
256+
257+ bool needCurl = false ;
255258 if (!P::isRestart) {
256259 // Initial state based on project, background field in all cells
257260 // and other initial values in non-sysboundary cells
@@ -262,12 +265,23 @@ void initializeGrids(
262265 // Each initialization has to be independent to avoid threading problems
263266
264267 // Allow the project to set up data structures for it's setCell calls
265- bool needCurl=false ;
266268 project.setupBeforeSetCell (cells, mpiGrid, needCurl);
267- if (needCurl==true ) {
268- // Communicate the perturbed B-fields and E-fileds read from the start file over to FSgrid
269+ if (needCurl) {
269270 feedPerBIntoFsGrid (mpiGrid, cells, perBGrid);
270271 perBGrid.updateGhostCells ();
272+ }
273+ }
274+
275+ phiprof::start (" setProjectBField" );
276+ project.setProjectBField (perBGrid, BgBGrid, technicalGrid);
277+ // Set E field here as well?
278+ perBGrid.updateGhostCells ();
279+ BgBGrid.updateGhostCells ();
280+ EGrid.updateGhostCells ();
281+ phiprof::stop (" setProjectBField" );
282+
283+ if (!P::isRestart) {
284+ if (needCurl) {
271285 // E is needed only because both volumetric fields are calculated in 1 call
272286 feedEIntoFsGrid (mpiGrid, cells, EGrid);
273287 EGrid.updateGhostCells ();
@@ -367,13 +381,6 @@ void initializeGrids(
367381 phiprof::stop (" Init moments" );
368382 }
369383
370- phiprof::start (" setProjectBField" );
371- project.setProjectBField (perBGrid, BgBGrid, technicalGrid);
372- perBGrid.updateGhostCells ();
373- BgBGrid.updateGhostCells ();
374- EGrid.updateGhostCells ();
375- phiprof::stop (" setProjectBField" );
376-
377384 phiprof::start (" Finish fsgrid setup" );
378385 feedMomentsIntoFsGrid (mpiGrid, cells, momentsGrid,technicalGrid, false );
379386 if (!P::isRestart) {
0 commit comments