Skip to content

Commit

Permalink
ParticleContainer: More Pure SoA Init Functions
Browse files Browse the repository at this point in the history
Depends on upstream.
  • Loading branch information
ax3l committed May 30, 2023
1 parent 2712b9d commit 6edcfa4
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/Particle/ParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
// const IntVect* Nrep = nullptr);

// void InitFromBinaryFile (const std::string& file, int extradata);

// void InitFromBinaryMetaFile
// void InitRandom (Long icount, ULong iseed,
// const ParticleInitData& mass,
// bool serialize = false, RealBox bx = RealBox());

.def("Increment", &ParticleContainerType::Increment) // TODO pure SoA
//.def("IncrementWithTotal", &ParticleContainerType::IncrementWithTotal, py::arg("mf"), py::arg("level"), py::arg("local")=false) // TODO pure SoA
// TODO for pure SoA
// depends on https://github.com/AMReX-Codes/amrex/pull/3280
.def("InitRandom", py::overload_cast<Long, ULong, const ParticleInitData&, bool, RealBox>(&ParticleContainerType::InitRandom)) // TODO pure SoA
.def("InitRandomPerBox", py::overload_cast<Long, ULong, const ParticleInitData&>(&ParticleContainerType::InitRandomPerBox)) // TODO pure SoA
.def("InitOnePerCell", &ParticleContainerType::InitOnePerCell) // TODO pure SoA

.def("Increment", &ParticleContainerType::Increment)
.def("IncrementWithTotal", &ParticleContainerType::IncrementWithTotal, py::arg("mf"), py::arg("level"), py::arg("local")=false)
.def("Redistribute", &ParticleContainerType::Redistribute, py::arg("lev_min")=0, py::arg("lev_max")=-1,
py::arg("nGrow")=0, py::arg("local")=0, py::arg("remove_negative")=true)
.def("SortParticlesByCell", &ParticleContainerType::SortParticlesByCell)
Expand Down Expand Up @@ -361,15 +363,6 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
// }
;

// TODO for pure SoA
// depends on https://github.com/AMReX-Codes/amrex/pull/3280
if constexpr (!T_ParticleType::is_soa_particle) {
py_pc
.def("InitRandom", py::overload_cast<Long, ULong, const ParticleInitData&, bool, RealBox>(&ParticleContainerType::InitRandom)) // TODO pure SoA
.def("InitRandomPerBox", py::overload_cast<Long, ULong, const ParticleInitData&>(&ParticleContainerType::InitRandomPerBox)) // TODO pure SoA
.def("InitOnePerCell", &ParticleContainerType::InitOnePerCell);
}

using iterator = amrex::ParIter_impl<ParticleType, T_NArrayReal, T_NArrayInt, Allocator>;
make_Iterators< false, iterator, Allocator >(m, allocstr);
using const_iterator = amrex::ParConstIter_impl<ParticleType, T_NArrayReal, T_NArrayInt, Allocator>;
Expand All @@ -383,8 +376,7 @@ void make_ParticleContainer_and_Iterators (py::module &m)
{
// TODO for pure SoA
// depends on https://github.com/AMReX-Codes/amrex/pull/3280
if constexpr (!T_ParticleType::is_soa_particle)
make_ParticleInitData<T_ParticleType, T_NArrayReal, T_NArrayInt>(m);
make_ParticleInitData<T_ParticleType, T_NArrayReal, T_NArrayInt>(m);

// see Src/Base/AMReX_GpuContainers.H
// !AMREX_USE_GPU: DefaultAllocator = std::allocator
Expand Down

0 comments on commit 6edcfa4

Please sign in to comment.