meshing.quality — Compute per-element corner quality and summary statistics for a solver mesh.
quality = meshing.quality(mesh) returns a struct of per-tetrahedron scaled Jacobian, edge aspect ratio, and volume, with summary statistics, for a meshing.Mesh.
Syntax
quality = meshing.quality(mesh)Inputs
mesh- Type
Any- Required
- Yes
- Default
- —
- Description
- meshing.Mesh from meshing.generate or meshing.load.
Returns
quality- Type
Any- Description
- Struct of per-element corner quality vectors and summary statistics.
Errors
RunMat:meshing:InvalidInput- When
- A meshing object, path, option, artifact, or evidence contract is invalid, or meshing cannot produce a result that satisfies the request.
- Message
meshing operation failed
Behavior
element_ids is an E-by-1 uint64 column, and corner_scaled_jacobian, corner_aspect_ratio, and corner_volume_m3 are E-by-1 double columns aligned with it. Each value is computed from the element's four corner nodes. The scaled Jacobian lies in [-1, 1]; 1 is a regular tetrahedron and values near 0 are nearly flat. The edge aspect ratio is 1 for a regular tetrahedron and grows as elements degrade. Volume is in cubic meters.
Summary fields are minimum_corner_scaled_jacobian, mean_corner_scaled_jacobian, p05_corner_scaled_jacobian, maximum_corner_aspect_ratio, mean_corner_aspect_ratio, p95_corner_aspect_ratio, minimum_corner_volume_m3, and total_corner_volume_m3, plus element_order. Percentiles use the nearest rank round((E - 1) * q) of the sorted values.
For Tet4 the corner measures describe the element itself. For Tet10 they describe the straight-sided corner tetrahedron; certified curved Jacobians and achieved high-order geometry checks are in meshing.evidence. A mesh with no volume elements is rejected.
Use in a study
Check quality before a solve: a low minimum or 5th-percentile scaled Jacobian or a high 95th-percentile aspect ratio points to elements that can degrade stress accuracy. Compare total_corner_volume_m3 with the CAD volume to confirm that the mesh fills the part. Compare quality together with evidence and solver convergence, not element counts alone, when assessing two meshes.
Errors
Every failure reports RunMat:meshing:InvalidInput, with a message that names the operation and the specific cause.
The input must be a meshing.Mesh with at least one volume element.
Example
Check element shape and recover the part volume
part = geometry.load('box.brep', 'Units', 'm');
solverMesh = meshing.generate(part, 'TargetSize', 0.5, 'MaximumDeviation', 0.05, 'ElementOrder', 'tet4', 'Seed', 42);
q = meshing.quality(solverMesh);
fprintf('min scaled Jacobian %.3f, p95 aspect ratio %.2f, volume %.6f m^3\n', ...
q.minimum_corner_scaled_jacobian, q.p95_corner_aspect_ratio, q.total_corner_volume_m3);Using meshing.quality with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how meshing.quality changes the result.
Run a small meshing.quality example, explain the result, then change one input and compare the output.
FAQ
Is a positive minimum Jacobian guaranteed?⌄
Yes for an admitted mesh: generation fails rather than returning inverted or degenerate elements. The statistics let you judge how far above that floor the mesh is.
Related Meshing functions
meshing.boundaryFaces · meshing.elements · meshing.evidence · meshing.generate · meshing.load · meshing.nodes · meshing.regions · meshing.save
Related guides
Source you can read
Every RunMat function's source is public. Read exactly how meshing.quality is executed, line by line, in Rust.
- View the source for meshing.quality in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.