@@ -131,11 +131,17 @@ void make_Iterators (py::module &m, std::string allocstr)
131
131
template <typename T_ParticleType, int T_NArrayReal=0 , int T_NArrayInt=0 >
132
132
void make_ParticleInitData (py::module &m) {
133
133
using ParticleType = T_ParticleType;
134
- using ParticleInitData = ParticleInitType<ParticleType::NReal, ParticleType::NInt, T_NArrayReal, T_NArrayInt>;
135
- // depends on https://github.com/AMReX-Codes/amrex/pull/3280
136
- // using ParticleInitData = ParticleInitType<ParticleType, T_NArrayReal, T_NArrayInt>;
137
134
138
- std::string const suffix = particle_type_suffix<T_ParticleType, T_NArrayReal, T_NArrayInt>();
135
+ // using ParticleInitData = typename ParticleContainerType::ParticleInitData;
136
+ using ParticleInitData = typename std::conditional<
137
+ ParticleType::is_soa_particle,
138
+ // SoA Particle: init w/o positions and id/cpu, but explicitly listed in define
139
+ ParticleInitTypeSoA<T_NArrayReal - AMREX_SPACEDIM, T_NArrayInt - 2 >,
140
+ // legacy particle: init w/o positions and id/cpu, only implicitly listed in define
141
+ ParticleInitType<ParticleType::NReal, ParticleType::NInt, T_NArrayReal, T_NArrayInt>
142
+ >::type;
143
+
144
+ std::string const suffix = particle_type_suffix<ParticleType, T_NArrayReal, T_NArrayInt>();
139
145
auto const particle_init_data_type =
140
146
std::string (" ParticleInitType_" ) + suffix;
141
147
auto py_particle_init_data = py::class_<ParticleInitData>(m, particle_init_data_type.c_str ())
@@ -221,14 +227,16 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
221
227
// const IntVect* Nrep = nullptr);
222
228
223
229
// void InitFromBinaryFile (const std::string& file, int extradata);
224
-
225
230
// void InitFromBinaryMetaFile
226
- // void InitRandom (Long icount, ULong iseed,
227
- // const ParticleInitData& mass,
228
- // bool serialize = false, RealBox bx = RealBox());
229
231
230
- .def (" Increment" , &ParticleContainerType::Increment) // TODO pure SoA
231
- // .def("IncrementWithTotal", &ParticleContainerType::IncrementWithTotal, py::arg("mf"), py::arg("level"), py::arg("local")=false) // TODO pure SoA
232
+ // TODO for pure SoA
233
+ // depends on https://github.com/AMReX-Codes/amrex/pull/3280
234
+ .def (" InitRandom" , py::overload_cast<Long, ULong, const ParticleInitData&, bool , RealBox>(&ParticleContainerType::InitRandom))
235
+ // .def("InitRandomPerBox", py::overload_cast<Long, ULong, const ParticleInitData&>(&ParticleContainerType::InitRandomPerBox)) // TODO pure SoA
236
+ .def (" InitOnePerCell" , &ParticleContainerType::InitOnePerCell) // TODO pure SoA
237
+
238
+ .def (" Increment" , &ParticleContainerType::Increment)
239
+ .def (" IncrementWithTotal" , &ParticleContainerType::IncrementWithTotal, py::arg (" mf" ), py::arg (" level" ), py::arg (" local" )=false )
232
240
.def (" Redistribute" , &ParticleContainerType::Redistribute, py::arg (" lev_min" )=0 , py::arg (" lev_max" )=-1 ,
233
241
py::arg (" nGrow" )=0 , py::arg (" local" )=0 , py::arg (" remove_negative" )=true )
234
242
.def (" SortParticlesByCell" , &ParticleContainerType::SortParticlesByCell)
@@ -361,15 +369,6 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
361
369
// }
362
370
;
363
371
364
- // TODO for pure SoA
365
- // depends on https://github.com/AMReX-Codes/amrex/pull/3280
366
- if constexpr (!T_ParticleType::is_soa_particle) {
367
- py_pc
368
- .def (" InitRandom" , py::overload_cast<Long, ULong, const ParticleInitData&, bool , RealBox>(&ParticleContainerType::InitRandom)) // TODO pure SoA
369
- .def (" InitRandomPerBox" , py::overload_cast<Long, ULong, const ParticleInitData&>(&ParticleContainerType::InitRandomPerBox)) // TODO pure SoA
370
- .def (" InitOnePerCell" , &ParticleContainerType::InitOnePerCell);
371
- }
372
-
373
372
using iterator = amrex::ParIter_impl<ParticleType, T_NArrayReal, T_NArrayInt, Allocator>;
374
373
make_Iterators< false , iterator, Allocator >(m, allocstr);
375
374
using const_iterator = amrex::ParConstIter_impl<ParticleType, T_NArrayReal, T_NArrayInt, Allocator>;
@@ -383,8 +382,7 @@ void make_ParticleContainer_and_Iterators (py::module &m)
383
382
{
384
383
// TODO for pure SoA
385
384
// depends on https://github.com/AMReX-Codes/amrex/pull/3280
386
- if constexpr (!T_ParticleType::is_soa_particle)
387
- make_ParticleInitData<T_ParticleType, T_NArrayReal, T_NArrayInt>(m);
385
+ make_ParticleInitData<T_ParticleType, T_NArrayReal, T_NArrayInt>(m);
388
386
389
387
// see Src/Base/AMReX_GpuContainers.H
390
388
// !AMREX_USE_GPU: DefaultAllocator = std::allocator
0 commit comments