Skip to content

Commit 937cb60

Browse files
authored
PC.size (#502)
Add a shortcut for the MPI-global, valid particles in a PC. Add more doc strings.
1 parent f56da4a commit 937cb60

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/Particle/ParticleContainer.H

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
285285
const Vector<IntVect>&>
286286
(&ParticleContainerType::Define))
287287

288-
.def("num_local_tiles_at_level", &ParticleContainerType::numLocalTilesAtLevel)
288+
.def("num_local_tiles_at_level",
289+
&ParticleContainerType::numLocalTilesAtLevel,
290+
py::arg("level")
291+
)
289292

290293
.def("reserve_data", &ParticleContainerType::reserveData)
291294
.def("resize_data", &ParticleContainerType::resizeData)
@@ -319,8 +322,23 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
319322
// py::overload_cast<int, int, int>
320323
// (&ParticleContainerType::DefineAndReturnParticleTile))
321324
// Long TotalNumberOfParticles (bool only_valid=true, bool only_local=false) const;
325+
.def("number_of_particles",
326+
[](ParticleContainerType const & pc, bool only_local){
327+
return pc.TotalNumberOfParticles(only_local);
328+
},
329+
py::arg("only_local")=false,
330+
"Return the number of valid particles on all MPI ranks, unless only_local is specified."
331+
)
322332
.def("total_number_of_particles", &ParticleContainerType::TotalNumberOfParticles,
323-
py::arg("only_valid")=true, py::arg("only_local")=false)
333+
py::arg("only_valid")=true, py::arg("only_local")=false,
334+
"Return the number of particles (only valid or including invalid) on all MPI ranks, unless only_local is specified."
335+
)
336+
.def_property_readonly("size",
337+
[](ParticleContainerType const & pc){
338+
return pc.TotalNumberOfParticles(false);
339+
},
340+
"Return the number of valid particles on all MPI ranks"
341+
)
324342
.def("remove_particles_at_level", &ParticleContainerType::RemoveParticlesAtLevel)
325343
.def("remove_particles_not_at_finestLevel", &ParticleContainerType::RemoveParticlesNotAtFinestLevel)
326344
// void CreateVirtualParticles (int level, AoS& virts) const;

0 commit comments

Comments
 (0)