Skip to content

Commit 283ec66

Browse files
committed
Make sure we geometrically grow the capacity of the particle buffers
1 parent ba5ade8 commit 283ec66

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Source/Particles/ParticleBoundaryBuffer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ void ParticleBoundaryBuffer::gatherParticlesFromDomainBoundaries (MultiParticleC
459459
auto dst_index = ptile_buffer.numParticles();
460460
{
461461
WARPX_PROFILE("ParticleBoundaryBuffer::gatherParticles::resize");
462+
auto np_to_add = amrex::get<0>(reduce_data.value());
463+
amrex::Long np_cap = ptile_buffer.capacity() / species_buffer.superParticleSize();
464+
if (dst_index + np_to_add > np_cap) {
465+
ptile_buffer.resize(2*(dst_index + np_to_add));
466+
}
462467
ptile_buffer.resize(dst_index + amrex::get<0>(reduce_data.value()));
463468
}
464469
{
@@ -563,6 +568,11 @@ void ParticleBoundaryBuffer::gatherParticlesFromEmbeddedBoundaries (
563568
auto dst_index = ptile_buffer.numParticles();
564569
{
565570
WARPX_PROFILE("ParticleBoundaryBuffer::gatherParticles::resize_eb");
571+
auto np_to_add = amrex::get<0>(reduce_data.value());
572+
amrex::Long np_cap = ptile_buffer.capacity() / species_buffer.superParticleSize();
573+
if (dst_index + np_to_add > np_cap) {
574+
ptile_buffer.resize(2*(dst_index + np_to_add));
575+
}
566576
ptile_buffer.resize(dst_index + amrex::get<0>(reduce_data.value()));
567577
}
568578
auto &warpx = WarpX::GetInstance();

0 commit comments

Comments
 (0)