forked from 1b-agent/fieldcraft-upstream
mesh: strong relax keeps a morph unless it inverts, default reach five element lengths
Owner's rule (#438): move the bad nodes, interpolate, keep the morph as long as no element inverts (guards "valid", the default); the old guards stay as "strict". The run keeps its best round (highest smallest scaled Jacobian, then fewest elements below the threshold, then highest mean) and never ends below the start. Default reach five mean edge lengths of the bad elements (was three); on the Pi 5 base reach 3, 5 and 7 end at the same quality, 5 moving fewer nodes than 7 while leaving none below 0.7. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
1 parent
426df4a333
commit
a2a4f8895e
6 files changed
+82
-22
No files matched your search
@@ -360,7 +360,7 @@ fn strong_relaxation_of_a_distorted_block_keeps_faces_and_edges() {
|
||||
let (original, m) = distorted_annulus(6, 0.06);
|
||||
let geo = Geo { model: original.clone() };
|
||||
let nodes: BTreeSet<u32> = m.nodes().keys().copied().collect();
|
||||
let options = MorphOptions { below: 0.9, reach: None, rounds: 40 };
|
||||
let options = MorphOptions { below: 0.9, reach: None, rounds: 40, ..MorphOptions::default() };
|
||||
let r = morph(&m, &nodes, options, &geo).unwrap();
|
||||
assert!(r.after.min_quality > r.before.min_quality + 0.2, "{:?} → {:?}: {:?}", r.before.min_quality, r.after.min_quality, r.rounds);
|
||||
assert!(r.mean_after > r.mean_before, "mean {} → {}", r.mean_before, r.mean_after);
|
||||
@@ -389,7 +389,7 @@ fn strong_relaxation_moves_only_nodes_within_the_reach() {
|
||||
let geo = Geo { model: original };
|
||||
let nodes: BTreeSet<u32> = m.nodes().keys().copied().collect();
|
||||
let reach = 0.4;
|
||||
let r = morph(&m, &nodes, MorphOptions { below: 0.8, reach: Some(reach), rounds: 20 }, &geo).unwrap();
|
||||
let r = morph(&m, &nodes, MorphOptions { below: 0.8, reach: Some(reach), rounds: 20, ..MorphOptions::default() }, &geo).unwrap();
|
||||
assert!(r.after.min_quality > r.before.min_quality, "{:?}", r.rounds);
|
||||
for n in r.positions.keys() {
|
||||
assert!(dist(m.node(*n).unwrap().xyz, CENTRE) < 0.2 + 2.0 * reach, "node {n} far from the bad spot moved");
|
||||
@@ -413,6 +413,22 @@ fn strong_relaxation_untangles_inverted_elements() {
|
||||
assert!(r.after.min_quality > 0.5, "{:?}", r.after);
|
||||
}
|
||||
|
||||
/// Both guards keep the result valid and never below the start; the valid guards (keep a morph
|
||||
/// unless it inverts an element) lift the worst element at least as far as the strict ones.
|
||||
#[test]
|
||||
fn strong_relaxation_guards_valid_and_strict() {
|
||||
let (original, m) = distorted_annulus(6, 0.06);
|
||||
let geo = Geo { model: original };
|
||||
let nodes: BTreeSet<u32> = m.nodes().keys().copied().collect();
|
||||
let run = |guards| morph(&m, &nodes, MorphOptions { below: 0.9, rounds: 40, guards, ..MorphOptions::default() }, &geo).unwrap();
|
||||
let (valid, strict) = (run(Guards::Valid), run(Guards::Strict));
|
||||
for r in [&valid, &strict] {
|
||||
assert_eq!(r.after.invalid, 0, "{:?}", r.after);
|
||||
assert!(r.after.min_quality >= r.before.min_quality, "{:?} → {:?}", r.before.min_quality, r.after.min_quality);
|
||||
}
|
||||
assert!(valid.after.min_quality >= strict.after.min_quality - 1e-9, "valid {:?}, strict {:?}", valid.after, strict.after);
|
||||
}
|
||||
|
||||
/// A good mesh is left as it is; bad options are errors.
|
||||
#[test]
|
||||
fn strong_relaxation_keeps_a_good_mesh_and_refuses_bad_options() {
|
||||
|
||||
Reference in new issue
Block a user