diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Evolve/WarpXEvolveEM.cpp | 8 | ||||
-rw-r--r-- | Source/Parallelization/GuardCellManager.H | 2 | ||||
-rw-r--r-- | Source/Parallelization/GuardCellManager.cpp | 4 | ||||
-rw-r--r-- | Source/Parallelization/WarpXComm.cpp | 112 | ||||
-rw-r--r-- | Source/Utils/WarpXMovingWindow.cpp | 23 | ||||
-rw-r--r-- | Source/WarpX.H | 2 | ||||
-rw-r--r-- | Source/WarpX.cpp | 6 |
7 files changed, 99 insertions, 58 deletions
diff --git a/Source/Evolve/WarpXEvolveEM.cpp b/Source/Evolve/WarpXEvolveEM.cpp index 80fe321cb..f58c34ed1 100644 --- a/Source/Evolve/WarpXEvolveEM.cpp +++ b/Source/Evolve/WarpXEvolveEM.cpp @@ -416,6 +416,8 @@ WarpX::OneStep_nosub (Real cur_time) } // E and B are up-to-date in the domain, but all guard cells are // outdated. + if ( safe_guard_cells ) + FillBoundaryB(guard_cells.ng_alloc_EB, guard_cells.ng_Extra); #endif } @@ -529,6 +531,8 @@ WarpX::OneStep_sub1 (Real curtime) FillBoundaryE(fine_lev, PatchType::fine, guard_cells.ng_FieldSolver); } + if ( safe_guard_cells ) + FillBoundaryF(fine_lev, PatchType::fine, guard_cells.ng_FieldSolver); FillBoundaryB(fine_lev, PatchType::fine, guard_cells.ng_FieldSolver); // v) Push the fields on the coarse patch and mother grid @@ -569,7 +573,11 @@ WarpX::OneStep_sub1 (Real curtime) FillBoundaryF(coarse_lev, PatchType::fine, IntVect::TheZeroVector()); } DampPML(coarse_lev, PatchType::fine); + if ( safe_guard_cells ) + FillBoundaryE(coarse_lev, PatchType::fine, guard_cells.ng_FieldSolver); } + if ( safe_guard_cells ) + FillBoundaryB(coarse_lev, PatchType::fine, guard_cells.ng_FieldSolver); } void diff --git a/Source/Parallelization/GuardCellManager.H b/Source/Parallelization/GuardCellManager.H index 4bc08cb14..70948baa8 100644 --- a/Source/Parallelization/GuardCellManager.H +++ b/Source/Parallelization/GuardCellManager.H @@ -49,7 +49,7 @@ public: const int maxwell_fdtd_solver_id, const int max_level, const amrex::Array<amrex::Real,3> v_galilean, - const bool exchange_all_guard_cells); + const bool safe_guard_cells); // Guard cells allocated for MultiFabs E and B amrex::IntVect ng_alloc_EB = amrex::IntVect::TheZeroVector(); diff --git a/Source/Parallelization/GuardCellManager.cpp b/Source/Parallelization/GuardCellManager.cpp index d7d2bce7c..2a587a211 100644 --- a/Source/Parallelization/GuardCellManager.cpp +++ b/Source/Parallelization/GuardCellManager.cpp @@ -25,7 +25,7 @@ guardCellManager::Init( const int maxwell_fdtd_solver_id, const int max_level, const amrex::Array<amrex::Real,3> v_galilean, - const bool exchange_all_guard_cells) + const bool safe_guard_cells) { // When using subcycling, the particles on the fine level perform two pushes // before being redistributed ; therefore, we need one extra guard cell @@ -137,7 +137,7 @@ guardCellManager::Init( ng_FieldSolverF = IntVect(AMREX_D_DECL(1,1,1)); #endif - if (exchange_all_guard_cells){ + if (safe_guard_cells){ // Run in safe mode: exchange all allocated guard cells at each // call of FillBoundary ng_FieldSolver = ng_alloc_EB; diff --git a/Source/Parallelization/WarpXComm.cpp b/Source/Parallelization/WarpXComm.cpp index bb2f9975f..fcc7343a6 100644 --- a/Source/Parallelization/WarpXComm.cpp +++ b/Source/Parallelization/WarpXComm.cpp @@ -369,40 +369,50 @@ WarpX::FillBoundaryE (int lev, PatchType patch_type, IntVect ng) if (do_pml && pml[lev]->ok()) { pml[lev]->ExchangeE(patch_type, - { Efield_fp[lev][0].get(), - Efield_fp[lev][1].get(), - Efield_fp[lev][2].get() }, + { Efield_fp[lev][0].get(), + Efield_fp[lev][1].get(), + Efield_fp[lev][2].get() }, do_pml_in_domain); pml[lev]->FillBoundaryE(patch_type); } const auto& period = Geom(lev).periodicity(); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - ng <= Efield_fp[lev][0]->nGrowVect(), - "Error: in FillBoundaryE, requested more guard cells than allocated"); - Efield_fp[lev][0]->FillBoundary(ng, period); - Efield_fp[lev][1]->FillBoundary(ng, period); - Efield_fp[lev][2]->FillBoundary(ng, period); + if ( safe_guard_cells ){ + Vector<MultiFab*> mf{Efield_fp[lev][0].get(),Efield_fp[lev][1].get(),Efield_fp[lev][2].get()}; + amrex::FillBoundary(mf, period); + } else { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + ng <= Efield_fp[lev][0]->nGrowVect(), + "Error: in FillBoundaryE, requested more guard cells than allocated"); + Efield_fp[lev][0]->FillBoundary(ng, period); + Efield_fp[lev][1]->FillBoundary(ng, period); + Efield_fp[lev][2]->FillBoundary(ng, period); + } } else if (patch_type == PatchType::coarse) { if (do_pml && pml[lev]->ok()) { - pml[lev]->ExchangeE(patch_type, - { Efield_cp[lev][0].get(), - Efield_cp[lev][1].get(), - Efield_cp[lev][2].get() }, - do_pml_in_domain); - pml[lev]->FillBoundaryE(patch_type); + pml[lev]->ExchangeE(patch_type, + { Efield_cp[lev][0].get(), + Efield_cp[lev][1].get(), + Efield_cp[lev][2].get() }, + do_pml_in_domain); + pml[lev]->FillBoundaryE(patch_type); } - const auto& cperiod = Geom(lev-1).periodicity(); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - ng <= Efield_cp[lev][0]->nGrowVect(), - "Error: in FillBoundaryE, requested more guard cells than allocated"); - Efield_cp[lev][0]->FillBoundary(ng, cperiod); - Efield_cp[lev][1]->FillBoundary(ng, cperiod); - Efield_cp[lev][2]->FillBoundary(ng, cperiod); + if ( safe_guard_cells ) { + Vector<MultiFab*> mf{Efield_cp[lev][0].get(),Efield_cp[lev][1].get(),Efield_cp[lev][2].get()}; + amrex::FillBoundary(mf, cperiod); + + } else { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + ng <= Efield_cp[lev][0]->nGrowVect(), + "Error: in FillBoundaryE, requested more guard cells than allocated"); + Efield_cp[lev][0]->FillBoundary(ng, cperiod); + Efield_cp[lev][1]->FillBoundary(ng, cperiod); + Efield_cp[lev][2]->FillBoundary(ng, cperiod); + } } } @@ -428,12 +438,17 @@ WarpX::FillBoundaryB (int lev, PatchType patch_type, IntVect ng) pml[lev]->FillBoundaryB(patch_type); } const auto& period = Geom(lev).periodicity(); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - ng <= Bfield_fp[lev][0]->nGrowVect(), - "Error: in FillBoundaryB, requested more guard cells than allocated"); - Bfield_fp[lev][0]->FillBoundary(ng, period); - Bfield_fp[lev][1]->FillBoundary(ng, period); - Bfield_fp[lev][2]->FillBoundary(ng, period); + if ( safe_guard_cells ) { + Vector<MultiFab*> mf{Bfield_fp[lev][0].get(),Bfield_fp[lev][1].get(),Bfield_fp[lev][2].get()}; + amrex::FillBoundary(mf, period); + } else { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + ng <= Bfield_fp[lev][0]->nGrowVect(), + "Error: in FillBoundaryB, requested more guard cells than allocated"); + Bfield_fp[lev][0]->FillBoundary(ng, period); + Bfield_fp[lev][1]->FillBoundary(ng, period); + Bfield_fp[lev][2]->FillBoundary(ng, period); + } } else if (patch_type == PatchType::coarse) { @@ -447,12 +462,17 @@ WarpX::FillBoundaryB (int lev, PatchType patch_type, IntVect ng) pml[lev]->FillBoundaryB(patch_type); } const auto& cperiod = Geom(lev-1).periodicity(); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - ng <= Bfield_cp[lev][0]->nGrowVect(), - "Error: in FillBoundaryB, requested more guard cells than allocated"); - Bfield_cp[lev][0]->FillBoundary(ng, cperiod); - Bfield_cp[lev][1]->FillBoundary(ng, cperiod); - Bfield_cp[lev][2]->FillBoundary(ng, cperiod); + if ( safe_guard_cells ){ + Vector<MultiFab*> mf{Bfield_cp[lev][0].get(),Bfield_cp[lev][1].get(),Bfield_cp[lev][2].get()}; + amrex::FillBoundary(mf, cperiod); + } else { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + ng <= Bfield_cp[lev][0]->nGrowVect(), + "Error: in FillBoundaryB, requested more guard cells than allocated"); + Bfield_cp[lev][0]->FillBoundary(ng, cperiod); + Bfield_cp[lev][1]->FillBoundary(ng, cperiod); + Bfield_cp[lev][2]->FillBoundary(ng, cperiod); + } } } @@ -476,10 +496,14 @@ WarpX::FillBoundaryF (int lev, PatchType patch_type, IntVect ng) } const auto& period = Geom(lev).periodicity(); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - ng <= F_fp[lev]->nGrowVect(), - "Error: in FillBoundaryF, requested more guard cells than allocated"); - F_fp[lev]->FillBoundary(ng, period); + if ( safe_guard_cells ) { + F_fp[lev]->FillBoundary(period); + } else { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + ng <= F_fp[lev]->nGrowVect(), + "Error: in FillBoundaryF, requested more guard cells than allocated"); + F_fp[lev]->FillBoundary(ng, period); + } } else if (patch_type == PatchType::coarse && F_cp[lev]) { @@ -491,10 +515,14 @@ WarpX::FillBoundaryF (int lev, PatchType patch_type, IntVect ng) } const auto& cperiod = Geom(lev-1).periodicity(); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - ng <= F_cp[lev]->nGrowVect(), - "Error: in FillBoundaryF, requested more guard cells than allocated"); - F_cp[lev]->FillBoundary(ng, cperiod); + if ( safe_guard_cells ) { + F_cp[lev]->FillBoundary(cperiod); + } else { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + ng <= F_cp[lev]->nGrowVect(), + "Error: in FillBoundaryF, requested more guard cells than allocated"); + F_cp[lev]->FillBoundary(ng, cperiod); + } } } diff --git a/Source/Utils/WarpXMovingWindow.cpp b/Source/Utils/WarpXMovingWindow.cpp index 6c2a249e0..8f1666b2f 100644 --- a/Source/Utils/WarpXMovingWindow.cpp +++ b/Source/Utils/WarpXMovingWindow.cpp @@ -246,15 +246,20 @@ WarpX::shiftMF (MultiFab& mf, const Geometry& geom, int num_shift, int dir, MultiFab tmpmf(ba, dm, nc, ng); MultiFab::Copy(tmpmf, mf, 0, 0, nc, ng); - IntVect ng_mw = IntVect::TheUnitVector(); - // Enough guard cells in the MW direction - ng_mw[dir] = num_shift; - // Add the extra cell (if momentum-conserving gather with staggered field solve) - ng_mw += ng_extra; - // Make sure we don't exceed number of guard cells allocated - ng_mw = ng_mw.min(ng); - // Fill guard cells. - tmpmf.FillBoundary(ng_mw, geom.periodicity()); + if ( WarpX::safe_guard_cells ) { + // Fill guard cells. + tmpmf.FillBoundary(geom.periodicity()); + } else { + IntVect ng_mw = IntVect::TheUnitVector(); + // Enough guard cells in the MW direction + ng_mw[dir] = num_shift; + // Add the extra cell (if momentum-conserving gather with staggered field solve) + ng_mw += ng_extra; + // Make sure we don't exceed number of guard cells allocated + ng_mw = ng_mw.min(ng); + // Fill guard cells. + tmpmf.FillBoundary(ng_mw, geom.periodicity()); + } // Make a box that covers the region that the window moved into const IndexType& typ = ba.ixType(); diff --git a/Source/WarpX.H b/Source/WarpX.H index cbef3d688..79f0abaf3 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -172,7 +172,7 @@ public: static int do_subcycling; - static bool exchange_all_guard_cells; + static bool safe_guard_cells; // buffers static int n_field_gather_buffer; //! in number of cells from the edge (identical for each dimension) diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 7d6637e38..9d0bfa636 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -100,7 +100,7 @@ Real WarpX::particle_slice_width_lab = 0.0; bool WarpX::do_dynamic_scheduling = true; int WarpX::do_subcycling = 0; -bool WarpX::exchange_all_guard_cells = 0; +bool WarpX::safe_guard_cells = 0; #if (AMREX_SPACEDIM == 3) IntVect WarpX::Bx_nodal_flag(1,0,0); @@ -363,7 +363,7 @@ WarpX::ReadParameters () pp.query("regrid_int", regrid_int); pp.query("do_subcycling", do_subcycling); pp.query("use_hybrid_QED", use_hybrid_QED); - pp.query("exchange_all_guard_cells", exchange_all_guard_cells); + pp.query("safe_guard_cells", safe_guard_cells); pp.query("override_sync_int", override_sync_int); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(do_subcycling != 1 || max_level <= 1, @@ -805,7 +805,7 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d maxwell_fdtd_solver_id, maxLevel(), WarpX::v_galilean, - exchange_all_guard_cells); + safe_guard_cells); if (mypc->nSpeciesDepositOnMainGrid() && n_current_deposition_buffer == 0) { n_current_deposition_buffer = 1; |