Remove fuzz and return face id alongside element id (Replace stale #308)#319
Remove fuzz and return face id alongside element id (Replace stale #308)#319Sichao25 wants to merge 5 commits into
Conversation
| * should be updated to properly handle the new result. | ||
| */ | ||
| [[nodiscard]] virtual LO GetOwningElementId(const Result& result) const = 0; | ||
| [[nodiscard]] virtual Kokkos::View<LO*> GetOwningElementIds( |
There was a problem hiding this comment.
Can these GetOwningElementId functions be made into free functions?
There was a problem hiding this comment.
It is possible, but since we need to access some private members, more API changes such as getter functions are required.
There was a problem hiding this comment.
Ok, so I think we should probably have a free function that given mesh, dim, id gives back the owning element. The member function can call this.
The free function version will be useful in a number of other places.
| */ | ||
| template <int N> | ||
| [[nodiscard]] KOKKOS_FUNCTION inline Real | ||
| distance_to_closest_edge_from_barycentric(const Omega_h::Matrix<N, 3>& coords, |
There was a problem hiding this comment.
In the case when a point is on the infinite extension of one of the face's edges, this function will erroneously say the point is 0 units from an edge. Also, this method will not (as the comment states) extend to 3D: barycentric coordinates in 3D are the ratios of volumes of tetrahedra, thus the product of the ith coordinate and the height/altitude of the face is not in the distance of the point to the edge.
There was a problem hiding this comment.
@HelenW42 did you end up having a fix for this function?
There was a problem hiding this comment.
I am working on a fix in 2D that computes the distance to the three edges and compares them, while keeping the original function as an efficient solution for points inside the element. I haven't implemented or thought much about the 3D case yet. Happy to hear any thoughts or if there are any known solutions.
There was a problem hiding this comment.
The attached PDF has my (rough) derivations of how to find whether a point is within a certain tolerance of an edge, vertex, and face in 2D and 3D from the barycentric coordinates alone. While I didn't include a specific fix for the collinear edge case, it's not that expensive an addition: if the point seems to have zero distance from the edge and is not within it, just check the distance from the vertices that define that edge (the derivation for which is in the file).
bary_to_global_tolerance.pdf
There was a problem hiding this comment.
Based on an offline discussion with Jacob, it should be okay to remove the function distance_to_closest_edge_from_barycentric from this PR since the current GridPointSearch class doesn't use it during the search process. I'll add a test case covering the edge case for the current approach. We can then address this barycentric-based approach in a separate issue or PR.
Resolved the merge conflict and updated the PR #308 to fit the new field API.