Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 11 additions & 14 deletions src/Base/BoxArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,30 +120,27 @@ void init_BoxArray(py::module &m) {
//! \brief Grow each Box in the BoxArray on the high end
//! by n_cell cells in the idir direction.
BoxArray& growHi (int idir, int n_cell);
//! \brief Apply surroundingNodes(Box) to each Box in BoxArray.
//! See the documentation of Box for details.
BoxArray& surroundingNodes ();
//!
*/

//! \brief Apply surroundingNodes(Box,int) to each Box in
//! BoxArray. See the documentation of Box for details.
BoxArray& surroundingNodes (int dir);
*/
.def("surroundingNodes",
py::overload_cast<>(&BoxArray::surroundingNodes))
.def("surroundingNodes",
py::overload_cast<int>(&BoxArray::surroundingNodes))

//! Apply Box::enclosedCells() to each Box in the BoxArray.
.def("enclosed_cells",
py::overload_cast<>(&BoxArray::enclosedCells))
.def("enclosed_cells",
py::overload_cast<int>(&BoxArray::enclosedCells))

//! Convert nodality of each box in the BoxArray
.def("convert",
py::overload_cast< IndexType >(&BoxArray::convert))
.def("convert",
py::overload_cast< IntVect const &>(&BoxArray::convert))
/*
//! Apply Box::convert(IndexType) to each Box in the BoxArray.
BoxArray& convert (IndexType typ);

BoxArray& convert (const IntVect& typ);

//! Apply function (*fp)(Box) to each Box in the BoxArray.
BoxArray& convert (Box (*fp)(const Box&));

//! Apply Box::shift(int,int) to each Box in the BoxArray.
BoxArray& shift (int dir, int nzones);

Expand Down
25 changes: 25 additions & 0 deletions src/Base/MultiFab.H
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,31 @@ factory :
;
}

py_MultiFab
.def("copymf",
Copy link
Contributor Author

@RevathiJambunathan RevathiJambunathan Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason, calling this copy did not seem to work
May be there is another copy method that is shadowing this
so I renamed it as copymf and that works!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this different than the copy method exposed here?

Copy link
Contributor Author

@RevathiJambunathan RevathiJambunathan Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using the copy_mfab in the python script and it did not work
So now I am not sure
they look similar, but copy_mfab did not work for me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you use the extension method here, as in this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed offline
.copy creates another copy and does not do what we want in this PR
where we copy the values from a src to dst multifab and the dst multifab is already allocated and initialized.

[](T &self, T const &src, int srccomp, int dstcomp, int numcomp, int nghost) {
T::Copy(self, src, srccomp, dstcomp, numcomp, nghost);
},
py::arg("src"), py::arg("srccomp"), py::arg("dstcomp"), py::arg("numcomp"), py::arg("nghost"),
"Copy from src to self including nghost ghost cells.\n"
"The two MultiFabs MUST have the same underlying BoxArray. The copy is local"
)
;

// TODO: Missing in iMultiFab https://github.com/AMReX-Codes/amrex/issues/4317
if constexpr (std::is_same_v<T, MultiFab>) {
py_MultiFab
.def("copymf",
[](T &self, T const &src, int srccomp, int dstcomp, int numcomp, IntVect const &nghost) {
T::Copy(self, src, srccomp, dstcomp, numcomp, nghost);
},
py::arg("src"), py::arg("srccomp"), py::arg("dstcomp"), py::arg("numcomp"), py::arg("nghost"),
"Copy from src to self including nghost ghost cells.\n"
"The two MultiFabs MUST have the same underlying BoxArray. The copy is local"
)
;
}

py_MultiFab
.def("subtract",
[](T & self, T const & src, int srccomp, int comp, int numcomp, int nghost) {
Expand Down
1 change: 1 addition & 0 deletions src/Base/MultiFab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,5 @@ void init_MultiFab(py::module &m, py::class_< amrex::MFIter > & py_MFIter)

m.def("copy_mfab", py::overload_cast< MultiFab &, MultiFab const &, int, int, int, int >(&MultiFab::Copy), py::arg("dst"), py::arg("src"), py::arg("srccomp"), py::arg("dstcomp"), py::arg("numcomp"), py::arg("nghost"))
.def("copy_mfab", py::overload_cast< MultiFab &, MultiFab const &, int, int, int, IntVect const & >(&MultiFab::Copy), py::arg("dst"), py::arg("src"), py::arg("srccomp"), py::arg("dstcomp"), py::arg("numcomp"), py::arg("nghost"));

}
Loading