Skip to content

Commit

Permalink
Fix ParticleContainer: amrex::Long pid
Browse files Browse the repository at this point in the history
```
error: narrowing conversion from 'amrex::Long' (aka 'long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
```
  • Loading branch information
ax3l committed Feb 21, 2024
1 parent b59f657 commit ecac157
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Source/Particles/PhysicalParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,10 +1080,10 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int

// Max number of new particles. All of them are created,
// and invalid ones are then discarded
const int max_new_particles = Scan::ExclusiveSum(counts.size(), counts.data(), offset.data());
const amrex::Long max_new_particles = Scan::ExclusiveSum(counts.size(), counts.data(), offset.data());

// Update NextID to include particles created in this function
int pid;
amrex::Long pid;
#ifdef AMREX_USE_OMP
#pragma omp critical (add_plasma_nextid)
#endif
Expand All @@ -1092,7 +1092,7 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int
ParticleType::NextID(pid+max_new_particles);
}
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
static_cast<amrex::Long>(pid) + static_cast<amrex::Long>(max_new_particles) < LongParticleIds::LastParticleID,
pid + max_new_particles < LongParticleIds::LastParticleID,
"ERROR: overflow on particle id numbers");

const int cpuid = ParallelDescriptor::MyProc();
Expand All @@ -1103,8 +1103,8 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int
DefineAndReturnParticleTile(lev, grid_id, tile_id);
}

auto old_size = particle_tile.size();
auto new_size = old_size + max_new_particles;
amrex::Long old_size = particle_tile.size();
amrex::Long new_size = old_size + max_new_particles;
particle_tile.resize(new_size);

auto& soa = particle_tile.GetStructOfArrays();
Expand Down Expand Up @@ -1639,10 +1639,10 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,

// Max number of new particles. All of them are created,
// and invalid ones are then discarded
const int max_new_particles = Scan::ExclusiveSum(counts.size(), counts.data(), offset.data());
const amrex::Long max_new_particles = Scan::ExclusiveSum(counts.size(), counts.data(), offset.data());

// Update NextID to include particles created in this function
int pid;
amrex::Long pid;
#ifdef AMREX_USE_OMP
#pragma omp critical (add_plasma_nextid)
#endif
Expand All @@ -1651,15 +1651,15 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
ParticleType::NextID(pid+max_new_particles);
}
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
static_cast<amrex::Long>(pid) + static_cast<amrex::Long>(max_new_particles) < LongParticleIds::LastParticleID,
pid + max_new_particles < LongParticleIds::LastParticleID,
"overflow on particle id numbers");

const int cpuid = ParallelDescriptor::MyProc();

auto& particle_tile = tmp_pc.DefineAndReturnParticleTile(0, grid_id, tile_id);

auto old_size = particle_tile.size();
auto new_size = old_size + max_new_particles;
amrex::Long old_size = particle_tile.size();
amrex::Long new_size = old_size + max_new_particles;
particle_tile.resize(new_size);

auto& soa = particle_tile.GetStructOfArrays();
Expand Down

0 comments on commit ecac157

Please sign in to comment.