Repository navigation
Conversation
locate_cell, Function._at, PointEvaluator and VertexOnlyMesh stored an explicit tolerance argument as the mesh tolerance, so the argument changed every later call that did not give a tolerance. Pass the tolerance down to the C locator instead, and cache one rtree for each tolerance until the mesh coordinates change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbrubeck
requested review from
leo-collins
and removed request for
leo-collins
December 3, 2026 11:03
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An explicit
toleranceargument for point location was stored as the mesh tolerance, so it changed every later call that did not give a tolerance:locate_cell,locate_reference_coordinate,locate_cell_and_reference_coordinate,locate_cells_ref_coords_and_dists,Function._at,PointEvaluatorandVertexOnlyMeshall setmesh.tolerance = tolerance. Each of them now passes the tolerance down to the point locator and leavesmesh.toleranceunchanged.What changes for users:
toleranceargument now applies only to the call that receives it.VertexOnlyMesh(mesh, points, tolerance=t)andPointEvaluator(mesh, points, tolerance=t)no longer changemesh.tolerance. Code that relied on that side effect must setmesh.toleranceitself.Implementation details
Function._ctypesis now a method that takes the tolerance, so that the C struct holds the rtree for that tolerance.PointEvaluatorstores its owntoleranceand passes it toVertexOnlyMesh.clear_rtreeempties the map of rtrees.test_point_eval_api.py::test_tolerance,test_point_eval_api.py::test_point_evaluator_toleranceandtest_vertex_only_mesh_generation.py::test_point_toleranceasserted that the mesh tolerance changes. They now assert that it does not.Evidence
New test in
tests/firedrake/regression/test_locate_cell.py:No tests have been run yet: the local environment can only import Firedrake
main. This draft relies on CI for the first run onrelease. It still has to be confirmed that the new test fails without the fix.Limitations
mainhas the same bug in the same places. Onmain,_box_ratio_heuristicandpartition_rtreeare also cached onself.tolerance, so the merge ofreleaseintomainmust pass the tolerance to them too.Merge Danger
Door: two-way
Blast Radius: point evaluation
Code that set the mesh tolerance through a
tolerance=argument ofVertexOnlyMesh,PointEvaluatororlocate_cellnow keeps the old mesh tolerance in later calls.AI assistance: Claude Code (Claude Opus 5.5) wrote the change, the tests and this description.
🤖 Generated with Claude Code