Skip to content

Commit

Permalink
Box: lo/hi small/big End Setters
Browse files Browse the repository at this point in the history
Expose the properties as read and write.
  • Loading branch information
ax3l committed Apr 17, 2024
1 parent 3c43073 commit 313ed96
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
12 changes: 6 additions & 6 deletions docs/source/usage/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ Base

.. autofunction:: amrex.space3d.AlmostEqual

Index Types
"""""""""""
Indexing: Box, IntVect and IndexType
""""""""""""""""""""""""""""""""""""

.. autoclass:: amrex.space3d.IntVect
:members:
:undoc-members:

.. autoclass:: amrex.space3d.Box
:members:
Expand All @@ -107,10 +111,6 @@ Index Types
Vectors
"""""""

.. autoclass:: amrex.space3d.IntVect
:members:
:undoc-members:

.. autoclass:: amrex.space3d.RealVect
:members:
:undoc-members:
Expand Down
25 changes: 15 additions & 10 deletions src/Base/Box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,23 @@ void init_Box(py::module &m) {
py::arg("small"), py::arg("big"), py::arg("t")
)

.def_property_readonly("lo_vect", [](Box const & bx){ return bx.smallEnd(); })
.def_property_readonly("hi_vect", [](Box const & bx){ return bx.bigEnd(); })
.def_property_readonly("small_end", [](Box const & bx){ return bx.smallEnd(); })
.def_property_readonly("big_end", [](Box const & bx){ return bx.bigEnd(); })
/*
.def_property("lo_vect",
[](Box const & bx){ return bx.smallEnd(); },
[](Box & bx, IntVect const & bg){ bx.setSmall(bg); }
)
.def_property("hi_vect",
[](Box const & bx){ return bx.bigEnd(); },
[](Box & bx, IntVect const & bg){ bx.setBig(bg); }
)
.def_property("small_end",
py::overload_cast<>(&Box::smallEnd, py::const_),
py::overload_cast< IntVect const & >(&Box::setSmall))
[](Box const & bx){ return bx.smallEnd(); },
[](Box & bx, IntVect const & bg){ bx.setSmall(bg); }
)
.def_property("big_end",
&Box::bigEnd,
&Box::setBig)
*/
[](Box const & bx){ return bx.bigEnd(); },
[](Box & bx, IntVect const & bg){ bx.setBig(bg); }
)

.def_property("type",
py::overload_cast<>(&Box::type, py::const_),
&Box::setType)
Expand Down
2 changes: 1 addition & 1 deletion src/Base/MultiFab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void init_MultiFab(py::module &m)
.def(py::init< >())

.def("enable_tiling", &MFItInfo::EnableTiling,
py::arg("ts") /*=FabArrayBase::mfiter_tile_size*/ )
py::arg_v("tile_size", FabArrayBase::mfiter_tile_size, "Default tile size in MFIter" ))
.def("set_dynamic", &MFItInfo::SetDynamic,
py::arg("f"))
.def("disable_device_sync", &MFItInfo::DisableDeviceSync)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ def box():
return amr.Box((0, 0, 0), (127, 127, 127))


def test_box_setget(box):
print(box.length())

box.small_end = amr.IntVect(3)
print(box.length())

box.big_end = amr.IntVect(40)
print(box.length())


def test_length(box):
print(box.length())
assert box.length() == amr.IntVect(128, 128, 128)
Expand Down

0 comments on commit 313ed96

Please sign in to comment.