Skip to content

Add --mesh-quality element shape report - #59

Merged
cpgr merged 1 commit into
masterfrom
mesh-quality
Aug 13, 2026
Merged

Add --mesh-quality element shape report#59
cpgr merged 1 commit into
masterfrom
mesh-quality

Conversation

@cpgr

@cpgr cpgr commented Aug 13, 2026

Copy link
Copy Markdown
Owner

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.

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>
@cpgr
cpgr merged commit e693e61 into master Aug 13, 2026
1 check passed
@cpgr
cpgr deleted the mesh-quality branch August 13, 2026 09:54
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.

1 participant