diff --git a/Src/Base/AMReX_MultiFabUtil.H b/Src/Base/AMReX_MultiFabUtil.H index b84e81cc91d..0290fd2451a 100644 --- a/Src/Base/AMReX_MultiFabUtil.H +++ b/Src/Base/AMReX_MultiFabUtil.H @@ -71,6 +71,14 @@ namespace amrex void average_down_faces (const MultiFab& fine, MultiFab& crse, const IntVect& ratio, int ngcrse=0); + // This version takes periodicity into account. + void average_down_faces (const Array& fine, + const Array& crse, + const IntVect& ratio, const Geometry& crse_geom); + // This version takes periodicity into account. + void average_down_faces (const MultiFab& fine, MultiFab& crse, + const IntVect& ratio, const Geometry& crse_geom); + //! Average fine edge-based MultiFab onto crse edge-based MultiFab. void average_down_edges (const Vector& fine, const Vector& crse, diff --git a/Src/Base/AMReX_MultiFabUtil.cpp b/Src/Base/AMReX_MultiFabUtil.cpp index f558bf1a08e..d312cb676cf 100644 --- a/Src/Base/AMReX_MultiFabUtil.cpp +++ b/Src/Base/AMReX_MultiFabUtil.cpp @@ -501,6 +501,25 @@ namespace amrex } } + void average_down_faces (const Array& fine, + const Array& crse, + const IntVect& ratio, const Geometry& crse_geom) + { + for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) + { + average_down_faces(*fine[idim], *crse[idim], ratio, crse_geom); + } + } + + void average_down_faces (const MultiFab& fine, MultiFab& crse, + const IntVect& ratio, const Geometry& crse_geom) + { + MultiFab ctmp(amrex::coarsen(fine.boxArray(),ratio), fine.DistributionMap(), + crse.nComp(), 0); + average_down_faces(fine, ctmp, ratio, 0); + crse.ParallelCopy(ctmp,0,0,crse.nComp(),0,0,crse_geom.periodicity()); + } + //! Average fine edge-based MultiFab onto crse edge-based MultiFab. //! This routine assumes that the crse BoxArray is a coarsened version of the fine BoxArray. void average_down_edges (const Vector& fine, const Vector& crse,