Skip to content

Commit

Permalink
Implement: Arena
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Oct 7, 2022
1 parent 7fe40bd commit 5865c3e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Base/Arena.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Copyright 2021-2022 The AMReX Community
*
* Authors: Axel Huebl
* License: BSD-3-Clause-LBNL
*/
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>

#include <AMReX_Arena.H>

namespace py = pybind11;
using namespace amrex;


void init_Arena(py::module &m) {
py::class_< Arena >(m, "Arena");

m.def("The_Arena", &The_Arena, py::return_value_policy::reference)
.def("The_Async_Arena", &The_Async_Arena, py::return_value_policy::reference)
.def("The_Device_Arena", &The_Device_Arena, py::return_value_policy::reference)
.def("The_Managed_Arena", &The_Managed_Arena, py::return_value_policy::reference)
.def("The_Pinned_Arena", &The_Pinned_Arena, py::return_value_policy::reference)
.def("The_Cpu_Arena", &The_Cpu_Arena, py::return_value_policy::reference)
;

// ArenaInfo
}
1 change: 1 addition & 0 deletions src/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
target_sources(pyAMReX
PRIVATE
AMReX.cpp
Arena.cpp
Array4.cpp
Box.cpp
RealBox.cpp
Expand Down
13 changes: 13 additions & 0 deletions src/Base/MultiFab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ using namespace amrex;


void init_MultiFab(py::module &m) {
py::class_< MFInfo >(m, "MFInfo")
.def_readwrite("alloc", &MFInfo::alloc)
.def_readwrite("arena", &MFInfo::arena)
.def_readwrite("tags", &MFInfo::tags)

.def(py::init< >())

.def("set_alloc", &MFInfo::SetAlloc)
.def("set_arena", &MFInfo::SetArena)
//.def("set_tag", py::overload_cast< std::string >(&MFInfo::SetTag))
.def("set_tag", [](MFInfo & info, std::string tag) { info.SetTag(std::move(tag)); })
;

py::class_< FabArrayBase >(m, "FabArrayBase")
.def_property_readonly("is_all_cell_centered", &FabArrayBase::is_cell_centered)
.def_property_readonly("is_all_nodal",
Expand Down
3 changes: 3 additions & 0 deletions src/pyAMReX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace py = pybind11;

// forward declarations of exposed classes
void init_AMReX(py::module&);
void init_Arena(py::module&);
void init_Array4(py::module&);
void init_Box(py::module &);
void init_RealBox(py::module &);
Expand Down Expand Up @@ -52,6 +53,7 @@ PYBIND11_MODULE(amrex_pybind, m) {
:toctree: _generate
AmrInfo
AmrMesh
Arena
ArrayOfStructs
Box
RealBox
Expand All @@ -73,6 +75,7 @@ PYBIND11_MODULE(amrex_pybind, m) {

// note: order from parent to child classes
init_AMReX(m);
init_Arena(m);
init_Dim3(m);
init_IntVect(m);
init_RealVect(m);
Expand Down

0 comments on commit 5865c3e

Please sign in to comment.