Conversation
The second angle of each dual triangle in buildMeshQualities() used b_len * c_len where the law of cosines needs b_len * b_len, so triangleAngleQuality (and potentially obtuseTriangle) were wrong wherever the triangle's b and c sides differ. Fix both the netcdf_c converter (built into the conda package) and the legacy converter. Add a test that recomputes the dual-triangle angles from dcEdge and checks triangleAngleQuality, obtuseTriangle and that the angles sum to pi. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
TestingI built the conda package with Before the fix (with the new test added):
After the fix:
The legacy converter in Posted by Claude Code on @xylar's behalf. The testing and wording above are AI-authored; please check them accordingly. |
Collaborator
Author
|
@trhille, could you please take a quick look here as well? |
This branch has not been deployed
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.
buildMeshQualities()inMpasMeshConverter.xcomputed the second angle of each dual triangle withb_len * c_lenwhere the law of cosines needsb_len * b_len. As a result,triangleAngleQualitywas wrong wherever the triangle's b and c sides differ, andobtuseTriangle(plus the "Mesh contains: N obtuse triangles" count) could be wrong on meshes with angles near 90°. The same typo is fixed in the legacy converter inmesh_conversion_tools/, although that one isn't built into the conda package.On
mesh.QU.1920km.151026.nc, before the fixtriangleAngleQualitywas off at 204 of 320 vertices, by up to 0.07, and the three angles of a triangle summed to between 3.037 and 3.227. After the fix, it matches an independent calculation exactly and all angle sums are π.obtuseTriangleis 0 on this mesh either way.This adds
test_conversion_triangle_angle_quality, which recomputes the angles fromdcEdgeandedgesOnVertexand checkstriangleAngleQuality,obtuseTriangleand that the angles sum to π. The test fails without the fix and passes with it.Closes #761
🤖 Generated with Claude Code