From f1fcac8a018c46fe0ae587469b2bf92862110f7a Mon Sep 17 00:00:00 2001 From: Michael E Rowan <38045958+mrowan137@users.noreply.github.com> Date: Tue, 5 May 2020 17:40:24 -0700 Subject: Switch costs to LayoutData (#970) Cleanup Cleanup --- Source/Parallelization/WarpXRegrid.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'Source/Parallelization/WarpXRegrid.cpp') diff --git a/Source/Parallelization/WarpXRegrid.cpp b/Source/Parallelization/WarpXRegrid.cpp index f04c59c78..6c6710121 100644 --- a/Source/Parallelization/WarpXRegrid.cpp +++ b/Source/Parallelization/WarpXRegrid.cpp @@ -35,12 +35,6 @@ WarpX::LoadBalance () const int nLevels = finestLevel(); for (int lev = 0; lev <= nLevels; ++lev) { - LayoutData costsLayoutData(boxArray(lev), DistributionMap(lev)); - for (auto i : costsLayoutData.IndexArray()) - { - costsLayoutData[i] = (*costs[lev])[i]; - } - // Compute the new distribution mapping DistributionMapping newdm; const amrex::Real nboxes = costs[lev]->size(); @@ -52,11 +46,11 @@ WarpX::LoadBalance () amrex::Real proposedEfficiency = 0.0; newdm = (load_balance_with_sfc) - ? DistributionMapping::makeSFC(costsLayoutData, + ? DistributionMapping::makeSFC(*costs[lev], currentEfficiency, proposedEfficiency, false, ParallelDescriptor::IOProcessorNumber()) - : DistributionMapping::makeKnapSack(costsLayoutData, + : DistributionMapping::makeKnapSack(*costs[lev], currentEfficiency, proposedEfficiency, nmax, false, @@ -283,9 +277,11 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi if (costs[lev] != nullptr) { - costs[lev].reset(new amrex::Vector); - const int nboxes = Efield_fp[lev][0].get()->size(); - costs[lev]->resize(nboxes, 0.0); + costs[lev].reset(new amrex::LayoutData(ba, dm)); + for (int i : costs[lev]->IndexArray()) + { + (*costs[lev])[i] = 0.0; + } } SetDistributionMap(lev, dm); @@ -299,7 +295,7 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi } void -WarpX::ComputeCostsHeuristic (amrex::Vector > >& a_costs) +WarpX::ComputeCostsHeuristic (amrex::Vector > >& a_costs) { for (int lev = 0; lev <= finest_level; ++lev) { @@ -333,6 +329,9 @@ WarpX::ResetCosts () { for (int lev = 0; lev <= finest_level; ++lev) { - costs[lev]->assign((*costs[lev]).size(), 0.0); + for (int i : costs[lev]->IndexArray()) + { + (*costs[lev])[i] = 0.0; + } } } -- cgit v1.2.3