diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WarpX.H | 7 | ||||
-rw-r--r-- | Source/WarpX.cpp | 23 | ||||
-rw-r--r-- | Source/WarpXComm.cpp | 16 | ||||
-rw-r--r-- | Source/WarpXRegrid.cpp | 15 |
4 files changed, 47 insertions, 14 deletions
diff --git a/Source/WarpX.H b/Source/WarpX.H index c0ab7495f..048bba747 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -399,6 +399,13 @@ private: amrex::Vector<std::array< std::unique_ptr<amrex::MultiFab>, 3 > > current_buf; amrex::Vector<std::unique_ptr<amrex::MultiFab> > charge_buf; + amrex::Vector<std::array<std::unique_ptr<amrex::iMultiFab>, 3 > > current_fp_owner_masks; + amrex::Vector<std::array<std::unique_ptr<amrex::iMultiFab>, 3 > > current_cp_owner_masks; + + amrex::Vector<std::unique_ptr<amrex::iMultiFab> > rho_fp_owner_masks; + amrex::Vector<std::unique_ptr<amrex::iMultiFab> > rho_cp_owner_masks; + + // div E cleaning int do_dive_cleaning = 0; diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index c3c362e4c..b1cab2aa0 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -163,6 +163,11 @@ WarpX::WarpX () current_buf.resize(nlevs_max); charge_buf.resize(nlevs_max); + current_fp_owner_masks.resize(nlevs_max); + current_cp_owner_masks.resize(nlevs_max); + rho_fp_owner_masks.resize(nlevs_max); + rho_cp_owner_masks.resize(nlevs_max); + pml.resize(nlevs_max); #ifdef WARPX_DO_ELECTROSTATIC @@ -461,8 +466,14 @@ WarpX::ClearLevel (int lev) Efield_cax[lev][i].reset(); Bfield_cax[lev][i].reset(); current_buf[lev][i].reset(); + + current_fp_owner_masks[lev][i].reset(); + current_cp_owner_masks[lev][i].reset(); } + rho_fp_owner_masks[lev].reset(); + rho_cp_owner_masks[lev].reset(); + charge_buf[lev].reset(); current_buffer_masks[lev].reset(); @@ -555,8 +566,14 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d current_fp[lev][1].reset( new MultiFab(amrex::convert(ba,jy_nodal_flag),dm,1,ngJ)); current_fp[lev][2].reset( new MultiFab(amrex::convert(ba,jz_nodal_flag),dm,1,ngJ)); + const auto& period = Geom(lev).periodicity(); + current_fp_owner_masks[lev][0] = std::move(current_fp[lev][0]->OwnerMask(period)); + current_fp_owner_masks[lev][1] = std::move(current_fp[lev][1]->OwnerMask(period)); + current_fp_owner_masks[lev][2] = std::move(current_fp[lev][2]->OwnerMask(period)); + if (do_dive_cleaning || plot_rho){ rho_fp[lev].reset(new MultiFab(amrex::convert(ba,IntVect::TheUnitVector()),dm,2,ngRho)); + rho_fp_owner_masks[lev] = std::move(rho_fp[lev]->OwnerMask(period)); } if (do_dive_cleaning) { @@ -613,8 +630,14 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d current_cp[lev][1].reset( new MultiFab(amrex::convert(cba,jy_nodal_flag),dm,1,ngJ)); current_cp[lev][2].reset( new MultiFab(amrex::convert(cba,jz_nodal_flag),dm,1,ngJ)); + const auto& cperiod = Geom(lev).periodicity(); + current_cp_owner_masks[lev][0] = std::move(current_cp[lev][0]->OwnerMask(cperiod)); + current_cp_owner_masks[lev][1] = std::move(current_cp[lev][1]->OwnerMask(cperiod)); + current_cp_owner_masks[lev][2] = std::move(current_cp[lev][2]->OwnerMask(cperiod)); + if (do_dive_cleaning || plot_rho){ rho_cp[lev].reset(new MultiFab(amrex::convert(cba,IntVect::TheUnitVector()),dm,2,ngRho)); + rho_cp_owner_masks[lev] = std::move(rho_cp[lev]->OwnerMask(cperiod)); } if (do_dive_cleaning) { diff --git a/Source/WarpXComm.cpp b/Source/WarpXComm.cpp index 57f099835..4463a522b 100644 --- a/Source/WarpXComm.cpp +++ b/Source/WarpXComm.cpp @@ -491,16 +491,16 @@ WarpX::SyncCurrent () for (int lev = 0; lev <= finest_level; ++lev) { const auto& period = Geom(lev).periodicity(); - current_fp[lev][0]->OverrideSync(period); - current_fp[lev][1]->OverrideSync(period); - current_fp[lev][2]->OverrideSync(period); + current_fp[lev][0]->OverrideSync(*current_fp_owner_masks[lev][0], period); + current_fp[lev][1]->OverrideSync(*current_fp_owner_masks[lev][1], period); + current_fp[lev][2]->OverrideSync(*current_fp_owner_masks[lev][2],period); } for (int lev = 1; lev <= finest_level; ++lev) { const auto& cperiod = Geom(lev-1).periodicity(); - current_cp[lev][0]->OverrideSync(cperiod); - current_cp[lev][1]->OverrideSync(cperiod); - current_cp[lev][2]->OverrideSync(cperiod); + current_cp[lev][0]->OverrideSync(*current_cp_owner_masks[lev][0], cperiod); + current_cp[lev][1]->OverrideSync(*current_cp_owner_masks[lev][1], cperiod); + current_cp[lev][2]->OverrideSync(*current_cp_owner_masks[lev][2], cperiod); } } @@ -642,12 +642,12 @@ WarpX::SyncRho (amrex::Vector<std::unique_ptr<amrex::MultiFab> >& rhof, for (int lev = 0; lev <= finest_level; ++lev) { const auto& period = Geom(lev).periodicity(); - rhof[lev]->OverrideSync(period); + rhof[lev]->OverrideSync(*rho_fp_owner_masks[lev], period); } for (int lev = 1; lev <= finest_level; ++lev) { const auto& cperiod = Geom(lev-1).periodicity(); - rhoc[lev]->OverrideSync(cperiod); + rhoc[lev]->OverrideSync(*rho_cp_owner_masks[lev], cperiod); } } diff --git a/Source/WarpXRegrid.cpp b/Source/WarpXRegrid.cpp index 744dd18e8..d9c5b21ff 100644 --- a/Source/WarpXRegrid.cpp +++ b/Source/WarpXRegrid.cpp @@ -40,6 +40,7 @@ WarpX::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMa // Fine patch + const auto& period = Geom(lev).periodicity(); for (int idim=0; idim < 3; ++idim) { { @@ -60,8 +61,8 @@ WarpX::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMa const IntVect& ng = current_fp[lev][idim]->nGrowVect(); auto pmf = std::unique_ptr<MultiFab>(new MultiFab(current_fp[lev][idim]->boxArray(), dm, 1, ng)); - // pmf->Redistribute(*current_fp[lev][idim], 0, 0, 1, ng); current_fp[lev][idim] = std::move(pmf); + current_fp_owner_masks[lev][idim] = std::move(current_fp[lev][idim]->OwnerMask(period)); } } @@ -78,8 +79,8 @@ WarpX::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMa const IntVect& ng = rho_fp[lev]->nGrowVect(); auto pmf = std::unique_ptr<MultiFab>(new MultiFab(rho_fp[lev]->boxArray(), dm, nc, ng)); - // pmf->Redistribute(*rho_fp[lev], 0, 0, nc, ng); rho_fp[lev] = std::move(pmf); + rho_fp_owner_masks[lev] = std::move(rho_fp[lev]->OwnerMask(period)); } // Aux patch @@ -112,6 +113,7 @@ WarpX::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMa // Coarse patch if (lev > 0) { + const auto& cperiod = Geom(lev-1).periodicity(); for (int idim=0; idim < 3; ++idim) { { @@ -130,10 +132,11 @@ WarpX::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMa } { const IntVect& ng = current_cp[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr<MultiFab>(new MultiFab(current_cp[lev][idim]->boxArray(), - dm, 1, ng)); - // pmf->Redistribute(*current_cp[lev][idim], 0, 0, 1, ng); + auto pmf = std::unique_ptr<MultiFab>( new MultiFab(current_cp[lev][idim]->boxArray(), + dm, 1, ng)); current_cp[lev][idim] = std::move(pmf); + current_cp_owner_masks[lev][idim] = std::move( + current_cp[lev][idim]->OwnerMask(cperiod)); } } @@ -150,8 +153,8 @@ WarpX::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMa const IntVect& ng = rho_cp[lev]->nGrowVect(); auto pmf = std::unique_ptr<MultiFab>(new MultiFab(rho_cp[lev]->boxArray(), dm, nc, ng)); - // pmf->Redistribute(*rho_cp[lev], 0, 0, nc, ng); rho_cp[lev] = std::move(pmf); + rho_cp_owner_masks[lev] = std::move(rho_cp[lev]->OwnerMask(cperiod)); } } |