19 template <
typename T_ParticleType,
int NArrayReal,
int NArrayInt>
22 using namespace amrex;
24 using ParticleType = T_ParticleType;
25 constexpr
int NStructReal = ParticleType::NReal;
26 constexpr
int NStructInt = ParticleType::NInt;
31 auto particle_tile_data_type = std::string(
"ParticleTileData_");
32 if (T_ParticleType::is_soa_particle) {
33 particle_tile_data_type +=
"pureSoA_";
36 particle_tile_data_type +=
37 std::to_string(NStructReal) +
"_" +
38 std::to_string(NStructInt) +
"_";
40 particle_tile_data_type +=
41 std::to_string(NArrayReal) +
"_" +
42 std::to_string(NArrayInt);
44 py::class_<ParticleTileDataType>(m, particle_tile_data_type.c_str())
47 .def_property_readonly(
"m_size", [](ParticleTileDataType
const & ptd){
return ptd.m_size; })
48 .def_property_readonly(
"m_num_runtime_real", [](ParticleTileDataType
const & ptd){
return ptd.m_num_runtime_real; })
49 .def_property_readonly(
"m_num_runtime_int", [](ParticleTileDataType
const & ptd){
return ptd.m_num_runtime_int; })
51 .def(
"get_super_particle", &ParticleTileDataType::template getSuperParticle<ParticleType>)
52 .def(
"set_super_particle", &ParticleTileDataType::template setSuperParticle<ParticleType>)
54 .def(
"__setitem__", [](ParticleTileDataType &pdt,
int const v,
55 SuperParticleType
const value) { pdt.setSuperParticle(value, v); })
57 [](ParticleTileDataType &pdt,
int const v) {
return pdt.getSuperParticle(v); })
62 template <
typename T_ParticleType,
int NArrayReal,
int NArrayInt,
66 using namespace amrex;
68 using ParticleType = T_ParticleType;
69 constexpr
int NStructReal = ParticleType::NReal;
70 constexpr
int NStructInt = ParticleType::NInt;
75 auto particle_tile_type = std::string(
"ParticleTile_");
76 if (T_ParticleType::is_soa_particle) {
77 particle_tile_type +=
"pureSoA_";
81 std::to_string(NStructReal) +
"_" +
82 std::to_string(NStructInt) +
"_";
84 particle_tile_type += std::to_string(NArrayReal) +
"_" +
85 std::to_string(NArrayInt) +
"_" + allocstr;
87 auto py_particle_tile = py::class_<ParticleTileType>(m, particle_tile_type.c_str())
89 .def_readonly_static(
"NAR", &ParticleTileType::NAR)
90 .def_readonly_static(
"NAI", &ParticleTileType::NAI)
91 .def(
"define", &ParticleTileType::define)
92 .def(
"get_struct_of_arrays", py::overload_cast<>(&ParticleTileType::GetStructOfArrays),
93 py::return_value_policy::reference_internal)
95 .def_property_readonly(
"empty", &ParticleTileType::empty)
96 .def_property_readonly(
"size", &ParticleTileType::size)
97 .def_property_readonly(
"num_particles", &ParticleTileType::numParticles)
98 .def_property_readonly(
"num_real_particles", &ParticleTileType::numRealParticles)
99 .def_property_readonly(
"num_neighbor_particles", &ParticleTileType::numNeighborParticles)
100 .def_property_readonly(
"num_total_particles", &ParticleTileType::numTotalParticles)
102 .def(
"set_num_neighbors", &ParticleTileType::setNumNeighbors)
103 .def(
"get_num_neighbors", &ParticleTileType::getNumNeighbors)
104 .def(
"resize", &ParticleTileType::resize)
107 if constexpr (!T_ParticleType::is_soa_particle) {
110 [](ParticleTileType& ptile,
const ParticleType &p) { ptile.push_back(p); },
111 "Add one particle to this tile.")
117 [](ParticleTileType& ptile,
const SuperParticleType &p) {ptile.push_back(p);},
118 "Add one particle to this tile.")
119 .def(
"push_back_real", [](ParticleTileType& ptile,
int comp, ParticleReal v) {ptile.push_back_real(comp, v);})
120 .def(
"push_back_real", [](ParticleTileType& ptile,
121 const std::array<ParticleReal, NArrayReal>& v) {ptile.push_back_real(v);})
122 .def(
"push_back_real", [](ParticleTileType&ptile,
126 {ptile.push_back_real(comp, npar, v);})
127 .def(
"push_back_int", [](ParticleTileType& ptile,
int comp,
int v) {ptile.push_back_int(comp, v);})
128 .def(
"push_back_int", [](ParticleTileType& ptile,
129 const std::array<int, NArrayInt>& v) {ptile.push_back_int(v);})
130 .def(
"push_back_int", [](ParticleTileType&ptile,
134 {ptile.push_back_int(comp, npar, v);})
136 .def_property_readonly(
"num_real_comps", &ParticleTileType::NumRealComps)
137 .def_property_readonly(
"num_int_comps", &ParticleTileType::NumIntComps)
138 .def_property_readonly(
"num_runtime_real_comps", &ParticleTileType::NumRuntimeRealComps)
139 .def_property_readonly(
"num_runtime_int_comps", &ParticleTileType::NumRuntimeIntComps)
141 .def(
"shrink_to_fit", &ParticleTileType::shrink_to_fit)
142 .def(
"capacity", &ParticleTileType::capacity)
143 .def(
"swap",&ParticleTileType::swap)
144 .def(
"get_particle_tile_data", &ParticleTileType::getParticleTileData)
145 .def(
"__setitem__", [](ParticleTileType & pt,
int const v, SuperParticleType
const value){ pt.getParticleTileData().setSuperParticle( value, v); })
146 .def(
"__getitem__", [](ParticleTileType & pt,
int const v){
return pt.getParticleTileData().getSuperParticle(v); })
149 if constexpr (!T_ParticleType::is_soa_particle) {
151 .def(
"get_array_of_structs",
152 py::overload_cast<>(&ParticleTileType::GetArrayOfStructs),
153 py::return_value_policy::reference_internal)
158 template <
typename T_ParticleType,
int NArrayReal,
int NArrayInt>
161 if constexpr (T_ParticleType::is_soa_particle) {
162 make_ParticleTileData<amrex::SoAParticleBase, NArrayReal, NArrayInt>(m);
165 make_ParticleTileData<T_ParticleType, NArrayReal, NArrayInt>(m);
183 std::allocator>(m,
"std");
void make_ParticleTileData(py::module &m)
Definition: ParticleTile.H:20
void make_ParticleTile(py::module &m, std::string allocstr)
Definition: ParticleTile.H:64