@@ -18,7 +18,7 @@ struct AMReX_PtlCounter
18
18
19
19
std::vector<unsigned long long > m_ParticleCounterByLevel;
20
20
21
- unsigned long GetTotalNumParticles () const { return m_Total;}
21
+ [[nodiscard]] unsigned long GetTotalNumParticles () const { return m_Total;}
22
22
23
23
std::vector<unsigned long long > m_ParticleOffsetAtRank;
24
24
std::vector<unsigned long long > m_ParticleSizeAtRank;
@@ -35,31 +35,27 @@ void CountParticles()
35
35
m_PtlCounter.m_ParticleOffsetAtRank .resize (this ->finestLevel ()+1 );
36
36
m_PtlCounter.m_ParticleSizeAtRank .resize (this ->finestLevel ()+1 );
37
37
38
- auto lf_GetParticleOffsetOfProcessor = [&](const long & numParticles,
38
+ auto lf_GetParticleOffsetOfProcessor = [&](const long long & numParticles,
39
39
unsigned long long & offset,
40
40
unsigned long long & sum) -> void
41
41
{
42
- std::vector<long > result (m_PtlCounter.m_MPISize , 0 );
42
+ std::vector<long long > result (m_PtlCounter.m_MPISize , 0 );
43
43
amrex::ParallelGather::Gather (numParticles, result.data (), -1 , amrex::ParallelDescriptor::Communicator ());
44
44
45
45
sum = 0 ;
46
46
offset = 0 ;
47
- for (int i=0 ; i<result.size (); i++) {
47
+ for (int i=0 ; i<int ( result.size () ); i++) {
48
48
sum += result[i];
49
- if ( i < m_PtlCounter.m_MPIRank )
49
+ if ( i < m_PtlCounter.m_MPIRank ) {
50
50
offset += result[i];
51
+ }
51
52
}
52
53
};
53
54
54
55
for (auto currentLevel = 0 ; currentLevel <= this ->finestLevel (); currentLevel++)
55
56
{
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 >(this ->NumberOfParticlesAtLevel (currentLevel, false , false ));
63
59
64
60
unsigned long long offset=0 ; // offset of this level
65
61
unsigned long long sum=0 ; // numParticles in this level (sum from all processors)
@@ -81,5 +77,3 @@ void CountParticles()
81
77
82
78
AMReX_PtlCounter m_PtlCounter;
83
79
#endif // AMREX_PTL_OPENPMD_API_H
84
-
85
-
0 commit comments