Skip to content

Commit

Permalink
MultiFab::copy()
Browse files Browse the repository at this point in the history
Create a copy of this MultiFab, using the same Arena.
  • Loading branch information
ax3l committed Mar 25, 2024
1 parent 9e8f8d6 commit 3789855
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Src/Base/AMReX_MultiFab.H
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions Src/Base/AMReX_MultiFab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3789855

Please sign in to comment.