Add --mesh-quality element shape report - #59
Merged
Merged
Conversation
The existing Jacobian check answers whether a mesh is valid. It says nothing about whether the elements are well shaped, which is what governs how well the mesh actually solves. Corner point grids routinely contain cells that are perfectly valid but very flat, and a finite element code handles those far worse than the finite volume simulator the grid was built for. Add --mesh-quality, which reports aspect ratio, skew, thickness and volume as percentile distributions, followed by counts of elements exceeding the aspect ratio and skew thresholds and the location of the worst cells. --aspect-ratio-limit adds a further threshold to the counts. Reporting only: the mesh is never modified and the exit code is never changed. It runs before the Jacobian check so the distributions are still printed when --strict-jacobians aborts, and works from connectivity and node coordinates alone, so it covers Leapfrog models as well as Eclipse. Element volume uses 2x2x2 Gauss quadrature, which integrates the trilinear Jacobian determinant exactly. Verified against analytic volumes for a parallelepiped, an anisotropic box and a frustum; the frustum is the case a naive tetrahedral decomposition would get wrong. Degenerate cells have an infinite aspect ratio, and np.percentile interpolates linearly, so a single infinity would turn most of a percentile row into NaN. They are held out of both the rows and the threshold counts, so every number describes the same population, and counted on a separate line. They still sort to the top of the worst-elements list. Also extract the element corner gather and the Exodus element ID mapping that checkElementJacobians and the new report both need. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The existing Jacobian check answers whether a mesh is valid. It says nothing about whether the elements are well shaped, which is what governs how well the mesh actually solves. Corner point grids routinely contain cells that are perfectly valid but very flat, and a finite element code handles those far worse than the finite volume simulator the grid was built for.
Add --mesh-quality, which reports aspect ratio, skew, thickness and volume as percentile distributions, followed by counts of elements exceeding the aspect ratio and skew thresholds and the location of the worst cells. --aspect-ratio-limit adds a further threshold to the counts.
Reporting only: the mesh is never modified and the exit code is never changed. It runs before the Jacobian check so the distributions are still printed when --strict-jacobians aborts, and works from connectivity and node coordinates alone, so it covers Leapfrog models as well as Eclipse.
Element volume uses 2x2x2 Gauss quadrature, which integrates the trilinear Jacobian determinant exactly. Verified against analytic volumes for a parallelepiped, an anisotropic box and a frustum; the frustum is the case a naive tetrahedral decomposition would get wrong.
Degenerate cells have an infinite aspect ratio, and np.percentile interpolates linearly, so a single infinity would turn most of a percentile row into NaN. They are held out of both the rows and the threshold counts, so every number describes the same population, and counted on a separate line. They still sort to the top of the worst-elements list.
Also extract the element corner gather and the Exodus element ID mapping that checkElementJacobians and the new report both need.