GEOS icon indicating copy to clipboard operation
GEOS copied to clipboard

Robust point location for degenerate configurations

Open sframba opened this issue 1 year ago • 1 comments

This PR adds a new method to determine if a point lies inside or outsilde a (convex) polyhedral cell. Compared to the current method, the new implementation is slower, but handles gracefully the degenerate conditions of points lying on mesh vertices, edges and faces. It does so by:

  • Triangulating each face of a cell in a consistent manner, by always choosing the lowest global-id vertex as root;
  • Ordering each triangle again using global ids, so that the edges and vertices are encountered in a consistent order across MPI ranks;
  • Computing the winding number (an integer) subtended by each triangle;
  • If the point lies on a vertex, edge or face, this will be found consistently by all ranks, whatever the cell from which the face/edge/vertex is seen. This is true because the order in which the vertices are traversed (and thus the result of the calculation) is exactly the same no matter the originating cell or MPI rank;
  • Finally, if a degenerate condition is found, the {face,edge,vertex}-to-element maps of the host element are used to choose consistently a single representative element. The adjacent element with the lowest global ID is chosen, ensuring general consistency across MPI ranks.

The only ambiguity left is when the point lies on a face/edge/vertex that is a boundary for an MPI rank, but an interior face/edge/vertex for another rank. In this case, both ranks will claim the point. However, at least one of them will consider the point to belong to a ghost element. This is a desirable outcome, since the desired behaviour in this case can be different according to the specific application (e.g., sources vs. receivers for the seismic wave case). This outcome leaves the choice to the caller method on how to handle this case, using ghost rank information.

The new point location algorithm is used for wave propagation kernels, fixing issue 3104 and issue 2888.

sframba avatar Jul 02 '24 11:07 sframba

Codecov Report

Attention: Patch coverage is 73.66771% with 84 lines in your changes missing coverage. Please review.

Project coverage is 55.92%. Comparing base (b31d792) to head (71f5930). Report is 77 commits behind head on develop.

Files with missing lines Patch % Lines
...omponents/mesh/utilities/ComputationalGeometry.hpp 68.00% 48 Missing :warning:
...rderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp 0.00% 19 Missing :warning:
...n/anisotropic/AcousticVTIWaveEquationSEMKernel.hpp 0.00% 16 Missing :warning:
...condOrderEqn/isotropic/AcousticWaveEquationSEM.cpp 94.44% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3202      +/-   ##
===========================================
+ Coverage    55.89%   55.92%   +0.03%     
===========================================
  Files         1042     1042              
  Lines        88731    88923     +192     
===========================================
+ Hits         49599    49733     +134     
- Misses       39132    39190      +58     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 02 '24 12:07 codecov[bot]

@rrsettgast Is it good to go? If so, could you please add your review?

sframba avatar Aug 03 '24 11:08 sframba