Skip to content

Commit d4242a2

Browse files
committed
ParticleInitData for PureSoA
1 parent de5215b commit d4242a2

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

src/Particle/ParticleContainer.H

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,17 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
380380
// }
381381
;
382382

383+
py_pc
384+
.def("InitRandom", py::overload_cast<Long, ULong, const ParticleInitData&, bool, RealBox>(&ParticleContainerType::InitRandom))
385+
;
386+
383387
// TODO for pure SoA
384388
// depends on https://github.com/AMReX-Codes/amrex/pull/3280
385389
if constexpr (!T_ParticleType::is_soa_particle) {
386390
py_pc
387-
.def("InitRandom", py::overload_cast<Long, ULong, const ParticleInitData&, bool, RealBox>(&ParticleContainerType::InitRandom)) // TODO pure SoA
388-
.def("InitRandomPerBox", py::overload_cast<Long, ULong, const ParticleInitData&>(&ParticleContainerType::InitRandomPerBox)) // TODO pure SoA
389-
.def("InitOnePerCell", &ParticleContainerType::InitOnePerCell);
391+
.def("InitRandomPerBox", py::overload_cast<Long, ULong, const ParticleInitData&>(&ParticleContainerType::InitRandomPerBox))
392+
.def("InitOnePerCell", &ParticleContainerType::InitOnePerCell)
393+
;
390394
}
391395

392396
using iterator = amrex::ParIter_impl<ParticleType, T_NArrayReal, T_NArrayInt, Allocator>;
@@ -408,10 +412,7 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
408412
template <typename T_ParticleType, int T_NArrayReal=0, int T_NArrayInt=0>
409413
void make_ParticleContainer_and_Iterators (py::module &m)
410414
{
411-
// TODO for pure SoA
412-
// depends on https://github.com/AMReX-Codes/amrex/pull/3280
413-
if constexpr (!T_ParticleType::is_soa_particle)
414-
make_ParticleInitData<T_ParticleType, T_NArrayReal, T_NArrayInt>(m);
415+
make_ParticleInitData<T_ParticleType, T_NArrayReal, T_NArrayInt>(m);
415416

416417
// first, because used as copy target in methods in containers with other allocators
417418
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,

src/Particle/ParticleContainer_ImpactX.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ void init_ParticleContainer_ImpactX(py::module& m) {
1414

1515
// TODO: we might need to move all or most of the defines in here into a
1616
// test/example submodule, so they do not collide with downstream projects
17-
make_ParticleContainer_and_Iterators<Particle<0, 0>, 5, 0>(m); // ImpactX 22.07 - 24.02
1817
make_ParticleContainer_and_Iterators<SoAParticle<8, 0>, 8, 0>(m); // ImpactX 24.03+
1918
}

src/Particle/ParticleContainer_WarpX.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ void init_ParticleContainer_WarpX(py::module& m) {
1313

1414
// TODO: we might need to move all or most of the defines in here into a
1515
// test/example submodule, so they do not collide with downstream projects
16-
make_ParticleContainer_and_Iterators<Particle<0, 0>, 4, 0>(m); // WarpX 22.07 - 24.02 1D-3D
17-
//make_ParticleContainer_and_Iterators<Particle<0, 0>, 5, 0> (m); // WarpX 22.07 - 24.02 RZ
18-
1916
#if AMREX_SPACEDIM == 1
2017
make_ParticleContainer_and_Iterators<SoAParticle<5, 0>, 5, 0>(m); // WarpX 24.03+ 1D
2118
#elif AMREX_SPACEDIM == 2

tests/test_particleContainer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ class Config:
300300
# pc = sim.get_particles()
301301
# Config = sim.extension.Config
302302

303-
# iterate over every mesh-refinement levels (no MR: lev=0)
303+
# iterate over mesh-refinement level (no MR: lev=0)
304304
for lvl in range(pc.finest_level + 1):
305305
# get every local chunk of particles
306306
for pti in pc.iterator(pc, level=lvl):
307-
# additional compile-time and runtime attributes in SoA format
307+
# compile-time and runtime attributes in SoA format
308308
soa = pti.soa().to_cupy() if Config.have_gpu else pti.soa().to_numpy()
309309

310310
# notes:
@@ -341,7 +341,7 @@ class Config:
341341
# pc = sim.get_particles()
342342
# Config = sim.extension.Config
343343

344-
# iterate over every mesh-refinement levels (no MR: lev=0)
344+
# iterate over mesh-refinement level (no MR: lev=0)
345345
for lvl in range(pc.finest_level + 1):
346346
# get every local chunk of particles
347347
for pti in pc.iterator(pc, level=lvl):

0 commit comments

Comments
 (0)