diff --git a/Src/Base/AMReX_MultiFab.H b/Src/Base/AMReX_MultiFab.H index b2fc9c80a1f..aafa6ded726 100644 --- a/Src/Base/AMReX_MultiFab.H +++ b/Src/Base/AMReX_MultiFab.H @@ -486,6 +486,12 @@ public: int dstcomp, int numcomp, const IntVect& nghost); + + + /** Create a copy of this MultiFab, using the same Arena. + */ + MultiFab Copy (); + /** * \brief Copy from src to dst including nghost ghost cells. * The two MultiFabs MUST have the same underlying BoxArray. diff --git a/Src/Base/AMReX_MultiFab.cpp b/Src/Base/AMReX_MultiFab.cpp index 15f9490b1c2..0c52c21c427 100644 --- a/Src/Base/AMReX_MultiFab.cpp +++ b/Src/Base/AMReX_MultiFab.cpp @@ -167,6 +167,27 @@ MultiFab::Add (MultiFab& dst, const MultiFab& src, amrex::Add(dst, src, srccomp, dstcomp, numcomp, nghost); } +MultiFab +MultiFab::Copy () +{ + auto mf = MultiFab( + this->boxArray(), + this->DistributionMap(), + this->nComp(), + this->nGrowVect(), + MFInfo().SetArena(this->arena()) + ); + MultiFab::Copy( + mf, + *this, + 0, + 0, + this->nComp(), + this->nGrowVect() + ); + return mf; +} + void MultiFab::Copy (MultiFab& dst, const MultiFab& src, int srccomp, int dstcomp, int numcomp, int nghost)