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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a test for moving particles in a complex geometry and #13269
Conversation
This must happen in Lines 793 to 818 in 5478749
We already repeat things if we happen to fail, so it surprises me that we do not catch that case (as you described in more detail on slack). I will take a look. I think the current solution is a bit unfortunate because it forces a re-computation of all points that left the cell, which can be a substantial cost. So we should first try to see if there is a more fundamental thing we can fix. |
@kronbichler It would be really nice to find a better solution than the one I propose. I do not like my solution at all, because, like you said, it duplicate the costs. |
@blais I now made a correction in #13278 - I believe this obviates the current patch, requiring only the test case (which is indeed valuable). I added another test in that PR that picks only the point that did not succeed: The algorithm would find another inverse point far away from the unit cell that also happened to have zero residual. We came there by bad luck, coming from a very bad initial guess. |
@kronbichler you're the best :). |
Yes, @blaisb , that would be great to have the test. |
@gassmoeller It seems the tolerance issue was also there on top of the bug addressed by @kronbichler . I think it's good if you review this one. |
4d7dab9
to
f7a7341
Compare
|
source/particles/particle_handler.cc
Outdated
@@ -1376,7 +1376,8 @@ namespace Particles | |||
reference_locations); | |||
|
|||
if (GeometryInfo<dim>::is_inside_unit_cell( | |||
reference_locations[0])) | |||
reference_locations[0]), | |||
1e-12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've got the parentheses wrong here. You write
if (foo(), 1e-12)
where you mean
if (foo(1e-12))
Nice catch by our warnings infrastructure :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch! My bad, I should have seen it from the automatic indentation.
I'm not sure if 1e-12 is the best threshold here. It seems to work in most cases I tried.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you fix the parenthesis this looks good to me. I would suggest a threshold of 1e-10 as this is the default for GridTools::find_active_cell_around_point
, that way #13202 combined with this PR should change as little as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good to me, thanks for narrowing down the problem (and thanks to @kronbichler for fixing the issue inside the mapping!). See my comment, 1e-10 should be the best threshold if only for compatibility.
source/particles/particle_handler.cc
Outdated
@@ -1376,7 +1376,8 @@ namespace Particles | |||
reference_locations); | |||
|
|||
if (GeometryInfo<dim>::is_inside_unit_cell( | |||
reference_locations[0])) | |||
reference_locations[0]), | |||
1e-12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you fix the parenthesis this looks good to me. I would suggest a threshold of 1e-10 as this is the default for GridTools::find_active_cell_around_point
, that way #13202 combined with this PR should change as little as possible.
Dear all, My conclusions is that I will need to write additional test for particles :). |
On 1/24/22 6:19 PM, Bruno Blais wrote:
My conclusions is that I will need to write additional test for particles :).
More tests = always more better.
|
/rebuild |
@bangerth I think this might be ready for merge since both @kronbichler and @gassmoeller approved :). |
This PR aimed at addressing #13246, but a better solution was found by @kronbichler in #13278 . However, the tolerance of the particle_handler locating algorithm is still a bit too harsh and, consequently, particles can still be lost when crossing cells. This PR fixes the tolerance and also a unit test that I created to reproduce the bug I encountered in #13426. I think it would be worthwhile to keep the test since it helped me debug the issue quite nicely.
The test is very simple. 48 particles are inserted in an hyper_ball. They are moved slightly using Euler's method. Before #13278 a particle would be lost on the second step. I think we need more tests for particles ( It has been a few times that I found issues in particles using Lethe :) ).