Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ghost particle property pool breakage #13654

Merged

Conversation

gassmoeller
Copy link
Member

I tried to open this PR against #13646, but for some reason I cannot select lethe-cfd/dealii as base repository.

Either way @blaisb this includes the fix for the bug you found. It was indeed in the sorting algorithm and a pretty nefarious inconsistency in our cache. While creating the new sorted_particles particle_container_owned_end already points into the new sorted container, while particle_container_ghost_end still points into the old unsorted container (so we would not move the ghost particle handes into the new sorted container and thus they were left behind and never properly deleted). I think the design of the reset_particle_container function is partly to blame, because it looks like it is just changing the container, but it actually also changes the cache of the ParticleHandler class. Maybe there is a cleaner solution than mine here, but this is the minimal change that fixes the problem. Do you want to incorporate this into your PR and also add the test?

Thanks for providing an interesting problem, I think this was the most challenging debugging I have done in a while 馃槃

@blaisb
Copy link
Member

blaisb commented Apr 28, 2022

@gassmoeller It seems that this PR also includes my test that was created in #13646 . If you want, we can merge your current PR and close mine, since yours already includes the test I wrote. You did all the crazy debugging, I just came up with an annoying test :). Let the glory be yours :). I'm just glad this is fixed.

Copy link
Member

@blaisb blaisb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change I would make is to the explanation of the test :)!

Comment on lines 16 to 24
* This test case is an extremely simplified version of step-68.
* A ball made of 48 particles is generated. This ball is moved down slightly.
* The particles remain in the simulation domain and they should not disappear.
* At the moment of the creation of this test, a bug in the particle_handler
would
* make one particle disappear and the number would decrease from 48 to 47 at
the
* second time step.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* This test case is an extremely simplified version of step-68.
* A ball made of 48 particles is generated. This ball is moved down slightly.
* The particles remain in the simulation domain and they should not disappear.
* At the moment of the creation of this test, a bug in the particle_handler
would
* make one particle disappear and the number would decrease from 48 to 47 at
the
* second time step.
*/
* This test case is an extremely simplified version of step-68.
* A ball made of 48 particles is generated. This particles are advected a few time-steps and they move through cells.
* Ghost particles are also generated. Particles have properties stored onto them. This test was created to reproduce a
* bug that would occur when sorting the property pool of particles while there was ghost particles that existed.
*/

Copy link
Member

@kronbichler kronbichler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix makes a lot of sense, thanks for tackling this @gassmoeller @blaisb ! Please fix the documentation as suggested by @blaisb and we are good to go.

@@ -295,9 +299,12 @@ namespace Particles
if (cells_to_particle_cache[cell->active_cell_index()] !=
particles.end())
{
// before we move the sorted_particles into particles
// particle_container_ghost_end() still points to the
// old particles container. Therefore this condition looks quirky.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to break the line before quirky to fix the indent issue.

@kronbichler
Copy link
Member

/rebuild

@gassmoeller
Copy link
Member Author

I have included the suggestions and added some more output to the test to proof the problem is fixed (so that similar issues are caught more reliably by the test). Should be ready now.

@drwells drwells merged commit c946a1b into dealii:master Apr 29, 2022
@gassmoeller gassmoeller deleted the ghost_particle_property_pool_breakage branch April 30, 2022 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants