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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to Mesh.element_finder #667

Merged
merged 26 commits into from
Jul 28, 2021
Merged

Conversation

kinnala
Copy link
Owner

@kinnala kinnala commented Jul 13, 2021

There is a heuristic optimization in MeshTri1.element_finder and MeshTet1.element_finder which tries to reduce the number of candidate elements where the query point may reside. The optimization logic looks for the query points inside elements whose midpoints are nearby. However, if the number of input points is large (in comparison to the number of elements), this "optimization" actually leads to a larger number of candidate elements and more memory being allocated.

Moreover, it was pointed out in #666 that the optimization logic does not work for some meshes with degenerate elements.

  • Add a robustness test for randomized Delaunay MeshTri1and MeshTet1; compare against scipy.spatial.Delaunay.find_simplex
  • Search all elements if the correct candidate is not found on the first try
  • Increase the maximum number of candidate elements in MeshTet1.element_finder

While testing the new implementation it was found out that the optimization logic fails entirely for meshes that have less than 5 or 8 elements and raises error.

  • Fix MeshTri1.element_finder and MeshTet1.element_finder for meshes that have a small number of elements.

Moreover, as pointed out in #646, points outside of the mesh are not detected correctly.

@kinnala kinnala changed the title Optimize the case where the number of input points is large Bypass element_finder candidate pruning for large input and if the result looks incorrect Jul 16, 2021
@kinnala kinnala changed the title Bypass element_finder candidate pruning for large input and if the result looks incorrect Bypass element_finder candidate pruning for large n.o. input points or if no correct element is found Jul 16, 2021
skfem/mesh/mesh_tet_1.py Outdated Show resolved Hide resolved
docs/examples/ex28.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@kinnala kinnala changed the title Bypass element_finder candidate pruning for large n.o. input points or if no correct element is found Improvements to MeshTet1 and MeshTri1.element_finder Jul 23, 2021
@kinnala kinnala changed the title Improvements to MeshTet1 and MeshTri1.element_finder Improvements to MeshTet1, MeshTri1 and MeshLine1.element_finder Jul 23, 2021
@kinnala kinnala changed the title Improvements to MeshTet1, MeshTri1 and MeshLine1.element_finder Improvements to Mesh.element_finder Jul 25, 2021
@kinnala kinnala merged commit c5d2c25 into master Jul 28, 2021
@kinnala kinnala deleted the optimize-large-number-of-points branch November 4, 2021 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Examples providing your own mesh and retriving the basis functions? element_finder and external points
1 participant