@@ -505,7 +505,7 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
505505/* * Create ParticleContainers and Iterators
506506 */
507507template <typename T_ParticleType, int T_NArrayReal=0 , int T_NArrayInt=0 >
508- void make_ParticleContainer_and_Iterators (py::module &m)
508+ void make_ParticleContainer_and_Iterators (py::module &m, bool only_polymorphic= false )
509509{
510510 if constexpr (T_ParticleType::is_soa_particle) {
511511 make_Particle<T_NArrayReal, T_NArrayInt>(m);
@@ -532,38 +532,41 @@ void make_ParticleContainer_and_Iterators (py::module &m)
532532 make_ParticleInitData<T_ParticleType, T_NArrayReal, T_NArrayInt>(m);
533533
534534 // first, because used as copy target in methods in containers with other allocators
535- make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
536- amrex::PinnedArenaAllocator>(m, " pinned" );
537-
538- // see Src/Base/AMReX_GpuContainers.H
539- // !AMREX_USE_GPU: DefaultAllocator = std::allocator
540- // AMREX_USE_GPU: DefaultAllocator = amrex::ArenaAllocator
541-
542- // work-around for https://github.com/pybind/pybind11/pull/4581
543- // make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
544- // std::allocator>(m, "std"); // CPU DefaultAllocator
545- // make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
546- // amrex::ArenaAllocator>(m, "arena"); // GPU DefaultAllocator
535+ if (!only_polymorphic) {
536+ make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
537+ amrex::PinnedArenaAllocator>(m, " pinned" );
538+
539+ // see Src/Base/AMReX_GpuContainers.H
540+ // !AMREX_USE_GPU: DefaultAllocator = std::allocator
541+ // AMREX_USE_GPU: DefaultAllocator = amrex::ArenaAllocator
542+
543+ // work-around for https://github.com/pybind/pybind11/pull/4581
544+ // make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
545+ // std::allocator>(m, "std"); // CPU DefaultAllocator
546+ // make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
547+ // amrex::ArenaAllocator>(m, "arena"); // GPU DefaultAllocator
547548#ifdef AMREX_USE_GPU
548- make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
549- std::allocator>(m, " std" );
550- make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
551- amrex::DefaultAllocator>(m, " default" ); // amrex::ArenaAllocator
549+ make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
550+ std::allocator>(m, " std" );
551+ make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
552+ amrex::DefaultAllocator>(m, " default" ); // amrex::ArenaAllocator
552553#else
553- make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
554- amrex::DefaultAllocator>(m, " default" ); // std::allocator
555- make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
556- amrex::ArenaAllocator>(m, " arena" );
554+ make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
555+ amrex::DefaultAllocator>(m, " default" ); // std::allocator
556+ make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
557+ amrex::ArenaAllocator>(m, " arena" );
557558#endif
558- // end work-around
559+ // end work-around
559560#ifdef AMREX_USE_GPU
560- make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
561- amrex::DeviceArenaAllocator>(m, " device" );
562- make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
563- amrex::ManagedArenaAllocator>(m, " managed" );
564- make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
565- amrex::AsyncArenaAllocator>(m, " async" );
561+ make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
562+ amrex::DeviceArenaAllocator>(m, " device" );
563+ make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
564+ amrex::ManagedArenaAllocator>(m, " managed" );
565+ make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
566+ amrex::AsyncArenaAllocator>(m, " async" );
566567#endif
568+ } // if (!only_polymorphic)
569+
567570 make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
568571 amrex::PolymorphicArenaAllocator>(m, " polymorphic" );
569572}
0 commit comments