diff --git a/Source/Particles/ParticleCreation/SmartUtils.H b/Source/Particles/ParticleCreation/SmartUtils.H index f84734308fb..6aef27d5ab4 100644 --- a/Source/Particles/ParticleCreation/SmartUtils.H +++ b/Source/Particles/ParticleCreation/SmartUtils.H @@ -64,8 +64,9 @@ void setNewParticleIDs (PTile& ptile, int old_size, int num_added) auto ptd = ptile.getParticleTileData(); amrex::ParallelFor(num_added, [=] AMREX_GPU_DEVICE (int ip) noexcept { - auto const new_id = ip + old_size; - ptd.m_idcpu[new_id] = amrex::SetParticleIDandCPU(pid+ip, cpuid); + amrex::Long const lip = static_cast(ip); + amrex::Long const new_id = lip + static_cast(old_size); + ptd.m_idcpu[new_id] = amrex::SetParticleIDandCPU(pid+lip, cpuid); }); } diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 08c784709fa..3c68d423d54 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1022,8 +1022,8 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int overlap_realbox.lo(2))}; // count the number of particles that each cell in overlap_box could add - Gpu::DeviceVector counts(overlap_box.numPts(), 0); - Gpu::DeviceVector offset(overlap_box.numPts()); + Gpu::DeviceVector counts(overlap_box.numPts(), 0); + Gpu::DeviceVector offset(overlap_box.numPts()); auto *pcounts = counts.data(); const amrex::IntVect lrrfac = rrfac; Box fine_overlap_box; // default Box is NOT ok(). @@ -1042,7 +1042,7 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int if (inj_pos->overlapsWith(lo, hi)) { auto index = overlap_box.index(iv); - const int r = (fine_overlap_box.ok() && fine_overlap_box.contains(iv))? + const amrex::Long r = (fine_overlap_box.ok() && fine_overlap_box.contains(iv))? (AMREX_D_TERM(lrrfac[0],*lrrfac[1],*lrrfac[2])) : (1); pcounts[index] = num_ppc*r; // update pcount by checking if cell-corners or cell-center @@ -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 @@ -1092,7 +1092,7 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int ParticleType::NextID(pid+max_new_particles); } WARPX_ALWAYS_ASSERT_WITH_MESSAGE( - static_cast(pid) + static_cast(max_new_particles) < LongParticleIds::LastParticleID, + pid + max_new_particles < LongParticleIds::LastParticleID, "ERROR: overflow on particle id numbers"); const int cpuid = ParallelDescriptor::MyProc(); @@ -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(); @@ -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 @@ -1651,15 +1651,15 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector, ParticleType::NextID(pid+max_new_particles); } WARPX_ALWAYS_ASSERT_WITH_MESSAGE( - static_cast(pid) + static_cast(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();