18 using namespace amrex;
24 template <
typename T_ParticleType,
29 using ParticleType = T_ParticleType;
30 using RealType =
typename ParticleType::RealType;
33 bool const read_only =
false;
34 d[
"data"] = py::make_tuple(std::intptr_t(aos.
dataPtr()), read_only);
35 d[
"shape"] = py::make_tuple(aos.
size());
36 d[
"strides"] = py::make_tuple(
sizeof(ParticleType));
37 d[
"typestr"] =
"|V" + std::to_string(
sizeof(ParticleType));
39 descr.append(py::make_tuple(
"x", py::format_descriptor<RealType>::format()));
40 #if (AMREX_SPACEDIM >= 2)
41 descr.append(py::make_tuple(
"y", py::format_descriptor<RealType>::format()));
43 #if (AMREX_SPACEDIM >= 3)
44 descr.append(py::make_tuple(
"z", py::format_descriptor<RealType>::format()));
46 if constexpr (ParticleType::NReal > 0) {
47 for(
int ii=0; ii < ParticleType::NReal; ii++) {
48 descr.append(py::make_tuple(
"rdata_"+std::to_string(ii),py::format_descriptor<RealType>::format()));
51 descr.append(py::make_tuple(
"idcpu", py::format_descriptor<uint64_t>::format()) );
52 if constexpr (ParticleType::NInt > 0) {
53 for(
int ii=0; ii < ParticleType::NInt; ++ii) {
54 descr.append(py::make_tuple(
"idata_"+std::to_string(ii),py::format_descriptor<int>::format()));
64 template <
typename T_ParticleType,
68 using namespace amrex;
71 using ParticleType = T_ParticleType;
73 auto const aos_name = std::string(
"ArrayOfStructs_")
74 .append(std::to_string(ParticleType::NReal)).append(
"_")
75 .append(std::to_string(ParticleType::NInt)).append(
"_")
77 py::class_<AOSType>(m, aos_name.c_str())
82 .def(
"size", &AOSType::size)
83 .def(
"numParticles", &AOSType::numParticles)
84 .def(
"numRealParticles", &AOSType::numRealParticles)
85 .def(
"numNeighborParticles", &AOSType::numNeighborParticles)
86 .def(
"numTotalParticles", &AOSType::numTotalParticles)
87 .def(
"setNumNeighbors", &AOSType::setNumNeighbors)
88 .def(
"getNumNeighbors", &AOSType::getNumNeighbors)
89 .def(
"empty", py::overload_cast<>(&AOSType::empty))
90 .def(
"empty", py::overload_cast<>(&AOSType::empty, py::const_))
91 .def(
"push_back", &AOSType::push_back)
92 .def(
"pop_back", &AOSType::pop_back)
93 .def(
"back", py::overload_cast<>(&AOSType::back),
"get back member. Problem!!!!! this is perfo")
96 .def_property_readonly(
"__array_interface__", [](AOSType
const & aos) {
99 .def_property_readonly(
"__cuda_array_interface__", [](AOSType
const & aos) {
115 d[
"stream"] = py::none();
120 .def(
"test_sizes", [](){ })
121 .def(
"__setitem__", [](AOSType &aos,
int const v,
const ParticleType& p){ aos[v] = p; })
122 .def(
"__getitem__", [](AOSType &aos,
int const v){
return aos[v]; }, py::return_value_policy::reference)
124 .def(
"to_host", [](AOSType
const & aos) {
126 h_data.
resize(aos.size());
129 aos.begin(), aos.end(),
138 template <
int NReal,
int NInt>
141 using namespace amrex;
147 make_ArrayOfStructs<ParticleType, amrex::PinnedArenaAllocator> (m,
"pinned");
157 make_ArrayOfStructs<ParticleType, std::allocator> (m,
"std");
158 make_ArrayOfStructs<ParticleType, amrex::DefaultAllocator> (m,
"default");
160 make_ArrayOfStructs<ParticleType, amrex::DefaultAllocator> (m,
"default");
161 make_ArrayOfStructs<ParticleType, amrex::ArenaAllocator> (m,
"arena");
165 make_ArrayOfStructs<ParticleType, amrex::DeviceArenaAllocator> (m,
"device");
166 make_ArrayOfStructs<ParticleType, amrex::ManagedArenaAllocator> (m,
"managed");
167 make_ArrayOfStructs<ParticleType, amrex::AsyncArenaAllocator> (m,
"async");
void make_ArrayOfStructs(py::module &m, std::string allocstr)
Definition: ArrayOfStructs.H:66
ParticleVector::iterator begin()
void resize(size_t count)
const ParticleType * dataPtr() const
void copy(HostToDevice, InIter begin, InIter end, OutIter result) noexcept
static constexpr DeviceToHost deviceToHost
py::dict array_interface(Array4< T > const &a4)
Definition: Array4.H:62