Skip to content

Commit

Permalink
Add a new InterFromCoarseLevel for ERF
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Sep 16, 2024
1 parent dfe1747 commit 9de8ff8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Src/AmrCore/AMReX_FillPatchUtil.H
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,23 @@ namespace amrex
const PreInterpHook& pre_interp = {},
const PostInterpHook& post_interp = {});

/**
* \brief Fill with interpolation of coarse level data
*
* No ghost cells of the destination MF on the fine level are
* filled. It's the caller's responsibility to make sure all ghost cells
* of the coarse MF needed for interpolation are filled already before
* calling this function. It's assumed that the fine level MultiFab mf's
* BoxArray is coarsenable by the refinement ratio. There is no support
* for EB.
*/
template <typename MF, typename Interp>
std::enable_if_t<IsFabArray<MF>::value>
InterpFromCoarseLevel (MF& mf, const MF& cmf, int scomp, int dcomp, int ncomp,
const Geometry& cgeom, const Geometry& fgeom,
const IntVect& ratio, Interp* mapper,
const Vector<BCRec>& bcs);

#ifndef BL_NO_FORT
enum InterpEM_t { InterpE, InterpB};

Expand Down
28 changes: 28 additions & 0 deletions Src/AmrCore/AMReX_FillPatchUtil_I.H
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,34 @@ InterpFromCoarseLevel (Array<MF*, AMREX_SPACEDIM> const& mf, IntVect const& ngho
}
}

template <typename MF, typename Interp>
std::enable_if_t<IsFabArray<MF>::value>
InterpFromCoarseLevel (MF& mf, const MF& cmf, int scomp, int dcomp, int ncomp,
const Geometry& cgeom, const Geometry& fgeom,
const IntVect& ratio, Interp* mapper,
const Vector<BCRec>& bcs)
{
const InterpolaterBoxCoarsener& coarsener = mapper->BoxCoarsener(ratio);
Box tmp(IntVect(0), IntVect(7));
tmp.refine(ratio);
Box tmp2 = coarsener.doit(tmp);
IntVect src_ghost = -tmp2.smallEnd();

const BoxArray& ba = mf.boxArray();
const DistributionMapping& dm = mf.DistributionMap();

const IndexType& typ = ba.ixType();

BL_ASSERT(typ == cmf.boxArray().ixType());

MF mf_crse_patch(amrex::coarsen(ba,ratio), dm, ncomp, src_ghost);
mf_crse_patch.ParallelCopy(cmf, scomp, 0, ncomp, src_ghost, src_ghost,
cgeom.periodicity());

FillPatchInterp(mf, dcomp, mf_crse_patch, 0, ncomp, IntVect(0), cgeom, fgeom,
amrex::convert(fgeom.Domain(),typ), ratio, mapper, bcs, 0);
}

template <typename MF, typename BC, typename Interp>
std::enable_if_t<IsFabArray<MF>::value>
FillPatchNLevels (MF& mf, int level, const IntVect& nghost, Real time,
Expand Down

0 comments on commit 9de8ff8

Please sign in to comment.