Repository navigation
Fix edge ordering on vertices of obtuse triangles in MpasMeshConverter.x - #779
Merged
Merged
Conversation
Collaborator
Author
TestingI built the
A package built the same way from cc1a077, which only renames variables, gives output identical to 6de2f24 for all of these meshes. Posted by Claude Code on @xylar's behalf. The testing, analysis and wording above are AI-authored; please check them accordingly. |
3 of 4 tasks
orderVertexArrays sorted the edges around each vertex by the direction from the vertex to each edge's location, and builds cellsOnVertex and the kites in kiteAreasOnVertex from that order. Where a triangle is obtuse, its circumcenter lies outside it, and the location of the edge opposite the obtuse angle -- where that edge crosses the line between its cells -- lies behind the vertex. That edge then sorted into the wrong place, so each kite paired a cell with an edge it doesn't share. areaTriangle, kiteAreasOnVertex and weightsOnEdge were wrong at those vertices, and NaN where a mismatched kite was degenerate enough for round-off to make its area NaN. Sort by the direction to the vertex at the other end of each edge instead, falling back to the edge's location on a boundary. On a mesh without obtuse triangles the two directions agree and the output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Heron's formula and its spherical analog take the square root of a product that is zero for a degenerate triangle, and round-off can make it slightly negative, giving NaN. Clamp the product at zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xylar
marked this pull request as draft
November 15, 2026 16:05
xylar
force-pushed
the
fix-obtuse-vertex-ordering
branch
from
November 15, 2026 16:30
403aade to
6de2f24
Compare
xylar
marked this pull request as ready for review
November 15, 2026 16:35
They are now usually the vertex at the other end of each edge rather than the edge's location, so call them dir_point1 and dir_point2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
MpasMeshConverter.x(mesh_conversion_tools_netcdf_c) now orders the edges around each vertex by the direction to the vertex at the other end of each edge, rather than to the edge's location, which lies behind the vertex when its triangle is obtuse. Kites at those vertices now pair each cell with its own edges, andareaTriangle,kiteAreasOnVertexandweightsOnEdgeare no longer NaN there. The triangle-area formulas also clamp a slightly negative product at zero, so a degenerate triangle has zero area rather than NaN.Output is unchanged for meshes without obtuse triangles. The deprecated
mesh_conversion_toolscopy has the same bug but is left as it is.Fixes #778
Posted by Claude Code on @xylar's behalf. The testing, analysis and wording above are AI-authored; please check them accordingly.