From 655a60c1381aedda203b02f2a68fc937c35e99b4 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Fri, 16 Oct 2026 08:29:54 -0400 Subject: [PATCH] mesh: test that more smoothing iterations never lower the smallest scaled Jacobian (#489) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo --- crates/mesh/src/project/tests.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/mesh/src/project/tests.rs b/crates/mesh/src/project/tests.rs index 63f3bae..1239052 100644 --- a/crates/mesh/src/project/tests.rs +++ b/crates/mesh/src/project/tests.rs @@ -98,6 +98,22 @@ fn seven_block_sphere_converges_without_losing_quality() { assert!(last_error < 0.01, "{last_error}"); } +/// More smoothing iterations never leave a worse mesh: the smoother keeps the best grid its +/// sweeps passed through (#489), so where the sweeps happen to stop does not decide the result. +#[test] +fn more_iterations_never_lower_the_smallest_scaled_jacobian() { + let (r, h) = (10.0, 2.0); + let (s, t) = cylinder(r, h, 128); + let topo = Topology::butterfly([0.0; 3], [0.0, 0.0, 1.0], r, &[0.0, h], 0.55).unwrap(); + let mut last = f64::NEG_INFINITY; + for iterations in [5, 20, 100, 300] { + let m = project_mesh(&topo, &s, &t, &ProjectOptions { iterations, ..options(0.75) }).unwrap(); + let sj = m.report.min_scaled_jacobian; + assert!(sj >= last - 1e-9, "{iterations} iterations: {sj} after {last}"); + last = sj; + } +} + /// A disc: the five-block butterfly, its rim on the circle where the side meets the caps. #[test] fn butterfly_disc_meshes_with_its_rim_on_the_circle() {