Skip to content

Remove fuzz and return face id alongside element id (Replace stale #308)#319

Open
Sichao25 wants to merge 5 commits into
SCOREC:developfrom
Sichao25:yus/transfer
Open

Remove fuzz and return face id alongside element id (Replace stale #308)#319
Sichao25 wants to merge 5 commits into
SCOREC:developfrom
Sichao25:yus/transfer

Conversation

@Sichao25

Copy link
Copy Markdown
Contributor

Resolved the merge conflict and updated the PR #308 to fit the new field API.

* should be updated to properly handle the new result.
*/
[[nodiscard]] virtual LO GetOwningElementId(const Result& result) const = 0;
[[nodiscard]] virtual Kokkos::View<LO*> GetOwningElementIds(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these GetOwningElementId functions be made into free functions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible, but since we need to access some private members, more API changes such as getter functions are required.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Sichao25 Sichao25 marked this pull request as ready for review June 18, 2026 22:16
*/
template <int N>
[[nodiscard]] KOKKOS_FUNCTION inline Real
distance_to_closest_edge_from_barycentric(const Omega_h::Matrix<N, 3>& coords,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HelenW42 did you end up having a fix for this function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@HelenW42 HelenW42 Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

3 participants