clear particles in pgen - #1441
Conversation
|
This was the reason for the introduction of |
|
Why not offer both options? This allows particles to be created in pgen safely if desired. |
Happy to support both options 😄 I am just saying that the current behavior might be the "expected behavior" (...if you will...). i.e., you classify this as a memory leak or bug, but I think another interpretation is that it is doing exactly what is expected: You source particles in a block. The block refines. Then the Parthernon particle AMR logic (I believe) maps those correctly to daughter blocks. Then you call ProblemGenerator again and source particles on those new daughter blocks and the process continues until the mesh resolves. And in this interpretation, if that isn't the behavior a user wants, then they might instead opt for |
|
Gotcha and point taken. Agreed this is not a bug then. Happy to be convinced to leave things as is, not I think clearing before the pgen is still a useful thing to offer, as it prevents a foot gun for new users. For test coverage, what about modifying the test to run in both modes? |
|
@par-hermes format |
|
@pdmullen please re-review and let me know if this seems like a good compromise. |
|
LGTM! |
pgrete
left a comment
There was a problem hiding this comment.
Only one minor comments on testing a probably more typical path.
Apart from that, this now removes the possibility to seed particles exactly once on the root level, which I think is fine.
|
@par-hermes format |
|
@pgrete please re-review. I think your comments should be addressed. |
pgrete
left a comment
There was a problem hiding this comment.
Thanks for the update.
LGTM
|
CI jobs canceled for some reason... re-running. |
PR Summary
In the process of going through the tutorial #1439 @pgrete pointed out that particles cannot currently be safely set in the problem generator, because they aren't cleared between remeshing, meaning there's a memory leak (and also probably undefined behavior).
This MR resolves the issue by just clearing particles before each pgen instance. I also modify the particle tracers example to stress this mechanism.
PR Checklist