Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Jan 4, 2024
1 parent 25f4e2e commit ed4eb27
Show file tree
Hide file tree
Showing 13 changed files with 338 additions and 353 deletions.
22 changes: 8 additions & 14 deletions Src/Extern/openPMD-api/AMReX_ParticlesOPENPMD.H
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct AMReX_PtlCounter

std::vector<unsigned long long> m_ParticleCounterByLevel;

unsigned long GetTotalNumParticles () const { return m_Total;}
[[nodiscard]] unsigned long GetTotalNumParticles () const { return m_Total;}

std::vector<unsigned long long> m_ParticleOffsetAtRank;
std::vector<unsigned long long> m_ParticleSizeAtRank;
Expand All @@ -35,31 +35,27 @@ void CountParticles()
m_PtlCounter.m_ParticleOffsetAtRank.resize(this->finestLevel()+1);
m_PtlCounter.m_ParticleSizeAtRank.resize(this->finestLevel()+1);

auto lf_GetParticleOffsetOfProcessor = [&](const long& numParticles,
auto lf_GetParticleOffsetOfProcessor = [&](const long long& numParticles,
unsigned long long& offset,
unsigned long long& sum) -> void
{
std::vector<long> result(m_PtlCounter.m_MPISize, 0);
std::vector<long long> result(m_PtlCounter.m_MPISize, 0);
amrex::ParallelGather::Gather (numParticles, result.data(), -1, amrex::ParallelDescriptor::Communicator());

sum = 0;
offset = 0;
for (int i=0; i<result.size(); i++) {
for (int i=0; i<int(result.size()); i++) {
sum += result[i];
if ( i < m_PtlCounter.m_MPIRank)
if ( i < m_PtlCounter.m_MPIRank) {
offset += result[i];
}
}
};

for (auto currentLevel = 0; currentLevel <= this->finestLevel(); currentLevel++)
{
long numParticles = 0; // numParticles in this processor

//for (ParIter pti(*this, currentLevel); pti.isValid(); ++pti) {
for (ParConstIterType pti(*this, currentLevel); pti.isValid(); ++pti) {
auto numParticleOnTile = pti.numParticles();
numParticles += numParticleOnTile;
}
// numParticles in this processor
auto numParticles = static_cast<long>(this->NumberOfParticlesAtLevel(currentLevel, false, false));

unsigned long long offset=0; // offset of this level
unsigned long long sum=0; // numParticles in this level (sum from all processors)
Expand All @@ -81,5 +77,3 @@ void CountParticles()

AMReX_PtlCounter m_PtlCounter;
#endif // AMREX_PTL_OPENPMD_API_H


Loading

0 comments on commit ed4eb27

Please sign in to comment.