@@ -18,7 +18,7 @@ struct AMReX_PtlCounter
1818
1919 std::vector<unsigned long long > m_ParticleCounterByLevel;
2020
21- unsigned long GetTotalNumParticles () const { return m_Total;}
21+ [[nodiscard]] unsigned long long GetTotalNumParticles () const { return m_Total;}
2222
2323 std::vector<unsigned long long > m_ParticleOffsetAtRank;
2424 std::vector<unsigned long long > m_ParticleSizeAtRank;
@@ -35,31 +35,27 @@ void CountParticles()
3535 m_PtlCounter.m_ParticleOffsetAtRank .resize (this ->finestLevel ()+1 );
3636 m_PtlCounter.m_ParticleSizeAtRank .resize (this ->finestLevel ()+1 );
3737
38- auto lf_GetParticleOffsetOfProcessor = [&](const long & numParticles,
38+ auto lf_GetParticleOffsetOfProcessor = [&](const long long & numParticles,
3939 unsigned long long & offset,
4040 unsigned long long & sum) -> void
4141 {
42- std::vector<long > result (m_PtlCounter.m_MPISize , 0 );
42+ std::vector<long long > result (m_PtlCounter.m_MPISize , 0 );
4343 amrex::ParallelGather::Gather (numParticles, result.data (), -1 , amrex::ParallelDescriptor::Communicator ());
4444
4545 sum = 0 ;
4646 offset = 0 ;
47- for (int i=0 ; i<result.size (); i++) {
47+ for (int i=0 ; i<int ( result.size () ); i++) {
4848 sum += result[i];
49- if ( i < m_PtlCounter.m_MPIRank )
49+ if ( i < m_PtlCounter.m_MPIRank ) {
5050 offset += result[i];
51+ }
5152 }
5253 };
5354
5455 for (auto currentLevel = 0 ; currentLevel <= this ->finestLevel (); currentLevel++)
5556 {
56- long numParticles = 0 ; // numParticles in this processor
57-
58- // for (ParIter pti(*this, currentLevel); pti.isValid(); ++pti) {
59- for (ParConstIterType pti (*this , currentLevel); pti.isValid (); ++pti) {
60- auto numParticleOnTile = pti.numParticles ();
61- numParticles += numParticleOnTile;
62- }
57+ // numParticles in this processor
58+ auto numParticles = static_cast <long long >(this ->NumberOfParticlesAtLevel (currentLevel, false , false ));
6359
6460 unsigned long long offset=0 ; // offset of this level
6561 unsigned long long sum=0 ; // numParticles in this level (sum from all processors)
@@ -81,5 +77,3 @@ void CountParticles()
8177
8278AMReX_PtlCounter m_PtlCounter;
8379#endif // AMREX_PTL_OPENPMD_API_H
84-
85-
0 commit comments