AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
536 stars 343 forks source link

Fix particle restart when finestLevel() < finest_level_in_file #3944

Closed dpgrote closed 4 months ago

dpgrote commented 4 months ago

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:

atmyers commented 4 months ago

Thank you! I think we also need to make the same change on line 924...