From 5d02c6480a0daba228eb1a47608632e9620d8f00 Mon Sep 17 00:00:00 2001 From: David Grote Date: Fri, 17 May 2024 09:08:03 -0700 Subject: [PATCH] Fix particle restart when finestLevel() < finest_level_in_file (#3944) ## Summary In the restart for particles, there is a loop up to `lev = finest_level_in_file` but is accessing `ParticleDistributionMap(lev)`. In the case when `finestLevel() < finest_level_in_file`, this was causing an assertion error (with DEBUG) and a seg fault (without DEBUG). This fixes the loop to only go up to `finestLevel()`. This fixes the issue and still works properly (all of the particles are read in). This also removes the `if` block that would no longer ever be called. ## Additional background Curiously, previously it would work with `finestLevel() < finest_level_in_file`, but none of this code had changed recently. I don't know how it worked before. ## Checklist The proposed changes: - [x] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate --- Src/Particle/AMReX_ParticleIO.H | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Src/Particle/AMReX_ParticleIO.H b/Src/Particle/AMReX_ParticleIO.H index 77a2c0cf992..ca40256620e 100644 --- a/Src/Particle/AMReX_ParticleIO.H +++ b/Src/Particle/AMReX_ParticleIO.H @@ -775,7 +775,7 @@ ParticleContainer_impl finestLevel()) - { - dual_grid = true; - break; - } - particle_box_arrays[lev].readFrom(phdr_file); if (! particle_box_arrays[lev].CellEqual(ParticleBoxArray(lev))) { dual_grid = true; } } @@ -927,7 +921,7 @@ ParticleContainer_impl