16 template <
int NReal,
int NInt,
18 bool use64BitIdCpu=
false>
21 using namespace amrex;
25 auto soa_name = std::string(
"StructOfArrays_") + std::to_string(NReal) +
"_" +
29 soa_name +=
"_" + allocstr;
31 py::class_<SOAType> py_SoA(m, soa_name.c_str(), py::dynamic_attr());
34 .def(
"define", &SOAType::define)
35 .def_property_readonly(
"num_real_comps", &SOAType::NumRealComps,
36 "Get the number of compile-time + runtime Real components")
37 .def_property_readonly(
"num_int_comps", &SOAType::NumIntComps,
38 "Get the number of compile-time + runtime Int components")
39 .def_property_readonly(
"has_idcpu", [](
const py::object&){
return use64BitIdCpu; },
40 "In pure SoA particle layout, idcpu is an array in the SoA")
43 .def(
"get_real_data", py::overload_cast<>(&SOAType::GetRealData),
44 py::return_value_policy::reference_internal,
45 "Get access to the particle Real Arrays (only compile-time components)")
46 .def(
"get_int_data", py::overload_cast<>(&SOAType::GetIntData),
47 py::return_value_policy::reference_internal,
48 "Get access to the particle Int Arrays (only compile-time components)")
50 .def(
"get_real_data", py::overload_cast<const int>(&SOAType::GetRealData),
51 py::return_value_policy::reference_internal,
53 "Get access to a particle Real component Array (compile-time and runtime component)")
54 .def(
"get_int_data", py::overload_cast<const int>(&SOAType::GetIntData),
55 py::return_value_policy::reference_internal,
57 "Get access to a particle Real component Array (compile-time and runtime component)")
59 .def(
"__len__", &SOAType::size,
60 "Get the number of particles")
61 .def_property_readonly(
"size", &SOAType::size,
62 "Get the number of particles")
63 .def_property_readonly(
"num_particles", &SOAType::numParticles)
64 .def_property_readonly(
"num_real_particles", &SOAType::numRealParticles)
65 .def_property_readonly(
"num_total_particles", &SOAType::numTotalParticles)
67 .def(
"set_num_neighbors", &SOAType::setNumNeighbors)
68 .def(
"get_num_neighbors", &SOAType::getNumNeighbors)
69 .def(
"resize", &SOAType::resize)
72 py_SoA.def(
"get_idcpu_data", py::overload_cast<>(&SOAType::GetIdCPUData),
73 py::return_value_policy::reference_internal,
74 "Get access to a particle IdCPU component Array");
77 template <
int NReal,
int NInt,
bool use64BitIdCpu=false>
81 make_StructOfArrays<NReal, NInt, amrex::PinnedArenaAllocator, use64BitIdCpu>(m,
"pinned");
91 make_StructOfArrays<NReal, NInt, std::allocator, use64BitIdCpu>(m,
"std");
92 make_StructOfArrays<NReal, NInt, amrex::DefaultAllocator, use64BitIdCpu> (m,
"default");
94 make_StructOfArrays<NReal, NInt, amrex::DefaultAllocator, use64BitIdCpu> (m,
"default");
95 make_StructOfArrays<NReal, NInt, amrex::ArenaAllocator, use64BitIdCpu>(m,
"arena");
99 make_StructOfArrays<NReal, NInt, amrex::DeviceArenaAllocator, use64BitIdCpu>(m,
"device");
100 make_StructOfArrays<NReal, NInt, amrex::ManagedArenaAllocator, use64BitIdCpu>(m,
"managed");
101 make_StructOfArrays<NReal, NInt, amrex::AsyncArenaAllocator, use64BitIdCpu>(m,
"async");
void make_StructOfArrays(py::module &m, std::string allocstr)
Definition: StructOfArrays.H:19
amrex::ArenaAllocator< T > DefaultAllocator