Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiFab::deepCopy() #3848

Merged
merged 5 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Src/Base/AMReX_MultiFab.H
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,14 @@ public:
int dstcomp,
int numcomp,
const IntVect& nghost);

/** Create a deep copy of this MultiFab and its data.
*
* This uses the same arena and factory in the copy and copies
* all data.
*/
MultiFab deepCopy ();

/**
* \brief Copy from src to dst including nghost ghost cells.
* The two MultiFabs MUST have the same underlying BoxArray.
Expand Down
22 changes: 22 additions & 0 deletions Src/Base/AMReX_MultiFab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,28 @@ MultiFab::Add (MultiFab& dst, const MultiFab& src,
amrex::Add(dst, src, srccomp, dstcomp, numcomp, nghost);
}

MultiFab
MultiFab::deepCopy ()
{
auto mf = MultiFab(
this->boxArray(),
this->DistributionMap(),
this->nComp(),
this->nGrowVect(),
MFInfo().SetArena(this->arena()),
this->Factory()
);
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
Loading