aboutsummaryrefslogtreecommitdiff
path: root/Source/Parallelization/WarpXComm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Parallelization/WarpXComm.cpp')
-rw-r--r--Source/Parallelization/WarpXComm.cpp51
1 files changed, 24 insertions, 27 deletions
diff --git a/Source/Parallelization/WarpXComm.cpp b/Source/Parallelization/WarpXComm.cpp
index e67acec22..6128b27a4 100644
--- a/Source/Parallelization/WarpXComm.cpp
+++ b/Source/Parallelization/WarpXComm.cpp
@@ -2,6 +2,7 @@
#include <WarpX.H>
#include <WarpX_f.H>
#include <WarpXSumGuardCells.H>
+#include <Parallelization/InterpolateCurrentFineToCoarse.H>
#include <algorithm>
#include <cstdlib>
@@ -487,7 +488,7 @@ WarpX::SyncCurrent ()
std::array< MultiFab*,3> crse { current_cp[lev][0].get(),
current_cp[lev][1].get(),
current_cp[lev][2].get() };
- SyncCurrent(fine, crse, refinement_ratio[0]);
+ interpolateCurrentFineToCoarse(fine, crse, refinement_ratio[0]);
}
// For each level
@@ -499,36 +500,35 @@ WarpX::SyncCurrent ()
}
}
-/** \brief Fills the values of the current on the coarse patch by
- * averaging the values of the current of the fine patch (on the same level).
- */
void
-WarpX::SyncCurrent (const std::array<const amrex::MultiFab*,3>& fine,
- const std::array< amrex::MultiFab*,3>& crse,
- int refinement_ratio)
+WarpX::interpolateCurrentFineToCoarse ( std::array< amrex::MultiFab const *, 3 > const & fine,
+ std::array< amrex::MultiFab *, 3 > const & coarse,
+ int const refinement_ratio)
{
+ BL_PROFILE("InterpolateCurrentFineToCoarse()");
BL_ASSERT(refinement_ratio == 2);
- const IntVect& ng = (fine[0]->nGrowVect() + 1) /refinement_ratio;
+ const IntVect& ng = (fine[0]->nGrowVect() + 1) / refinement_ratio; // add equivalent no. of guards to coarse patch
#ifdef _OPEMP
-#pragma omp parallel
+#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
{
- FArrayBox ffab;
- for (int idim = 0; idim < 3; ++idim)
+ for (int idim = 0; idim < fine.size(); ++idim) // j-field components
{
- for (MFIter mfi(*crse[idim],true); mfi.isValid(); ++mfi)
+ // OMP in-box decomposition of coarse into tilebox
+ for (MFIter mfi(*coarse[idim], TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
- const Box& bx = mfi.growntilebox(ng);
- Box fbx = amrex::grow(amrex::refine(bx,refinement_ratio),1);
- ffab.resize(fbx);
- fbx &= (*fine[idim])[mfi].box();
- ffab.setVal(0.0);
- ffab.copy((*fine[idim])[mfi], fbx, 0, fbx, 0, fine[idim]->nComp());
- WRPX_SYNC_CURRENT(bx.loVect(), bx.hiVect(),
- BL_TO_FORTRAN_ANYD((*crse[idim])[mfi]),
- BL_TO_FORTRAN_ANYD(ffab),
- &idim);
+ const Box& bx = mfi.growntilebox(ng); // only grow to outer directions of tileboxes for filling guards
+
+ auto const & arrFine = fine[idim]->const_array(mfi);
+ auto const & arrCoarse = coarse[idim]->array(mfi);
+
+ if( idim == 0 )
+ amrex::ParallelFor( bx, InterpolateCurrentFineToCoarse<0>(arrFine, arrCoarse, refinement_ratio) );
+ else if( idim == 1 )
+ amrex::ParallelFor( bx, InterpolateCurrentFineToCoarse<1>(arrFine, arrCoarse, refinement_ratio) );
+ else if( idim == 2 )
+ amrex::ParallelFor( bx, InterpolateCurrentFineToCoarse<2>(arrFine, arrCoarse, refinement_ratio) );
}
}
}
@@ -558,9 +558,6 @@ WarpX::SyncRho ()
}
}
-/** \brief Fills the values of the charge density on the coarse patch by
- * averaging the values of the charge density of the fine patch (on the same level).
- */
void
WarpX::SyncRho (const MultiFab& fine, MultiFab& crse, int refinement_ratio)
{
@@ -569,7 +566,7 @@ WarpX::SyncRho (const MultiFab& fine, MultiFab& crse, int refinement_ratio)
const int nc = fine.nComp();
#ifdef _OPEMP
-#pragma omp parallel
+#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
{
FArrayBox ffab;
@@ -607,7 +604,7 @@ WarpX::RestrictCurrentFromFineToCoarsePatch (int lev)
std::array< MultiFab*,3> crse { current_cp[lev][0].get(),
current_cp[lev][1].get(),
current_cp[lev][2].get() };
- SyncCurrent(fine, crse, refinement_ratio[0]);
+ interpolateCurrentFineToCoarse(fine, crse, refinement_ratio[0]);
}
void