Skip to content

Commit

Permalink
Average down faces (#1216)
Browse files Browse the repository at this point in the history
New average_down_faces functions that take coarse Geometry and average down periodically.
  • Loading branch information
WeiqunZhang authored Jul 31, 2020
1 parent 1476ea3 commit 2dad6e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Src/Base/AMReX_MultiFabUtil.H
Original file line number Diff line number Diff line change
Expand Up @@ -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<const MultiFab*,AMREX_SPACEDIM>& fine,
const Array<MultiFab*,AMREX_SPACEDIM>& 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<const MultiFab*>& fine,
const Vector<MultiFab*>& crse,
Expand Down
19 changes: 19 additions & 0 deletions Src/Base/AMReX_MultiFabUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,25 @@ namespace amrex
}
}

void average_down_faces (const Array<const MultiFab*,AMREX_SPACEDIM>& fine,
const Array<MultiFab*,AMREX_SPACEDIM>& 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<const MultiFab*>& fine, const Vector<MultiFab*>& crse,
Expand Down

0 comments on commit 2dad6e2

Please sign in to comment.