@@ -131,11 +131,17 @@ void make_Iterators (py::module &m, std::string allocstr)
131131template <typename T_ParticleType, int T_NArrayReal=0 , int T_NArrayInt=0 >
132132void make_ParticleInitData (py::module &m) {
133133 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>;
137134
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>();
139145 auto const particle_init_data_type =
140146 std::string (" ParticleInitType_" ) + suffix;
141147 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)
221227 // const IntVect* Nrep = nullptr);
222228
223229 // void InitFromBinaryFile (const std::string& file, int extradata);
224-
225230 // void InitFromBinaryMetaFile
226- // void InitRandom (Long icount, ULong iseed,
227- // const ParticleInitData& mass,
228- // bool serialize = false, RealBox bx = RealBox());
229231
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 )
232240 .def (" Redistribute" , &ParticleContainerType::Redistribute, py::arg (" lev_min" )=0 , py::arg (" lev_max" )=-1 ,
233241 py::arg (" nGrow" )=0 , py::arg (" local" )=0 , py::arg (" remove_negative" )=true )
234242 .def (" SortParticlesByCell" , &ParticleContainerType::SortParticlesByCell)
@@ -361,15 +369,6 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
361369 // }
362370 ;
363371
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-
373372 using iterator = amrex::ParIter_impl<ParticleType, T_NArrayReal, T_NArrayInt, Allocator>;
374373 make_Iterators< false , iterator, Allocator >(m, allocstr);
375374 using const_iterator = amrex::ParConstIter_impl<ParticleType, T_NArrayReal, T_NArrayInt, Allocator>;
@@ -383,8 +382,7 @@ void make_ParticleContainer_and_Iterators (py::module &m)
383382{
384383 // TODO for pure SoA
385384 // 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);
388386
389387 // see Src/Base/AMReX_GpuContainers.H
390388 // !AMREX_USE_GPU: DefaultAllocator = std::allocator
0 commit comments