Skip to content

BUG: Fix periodic feature-centroid model in Triangle and Feature centroid filters#1670

Open
imikejackson wants to merge 2 commits into
BlueQuartzSoftware:developfrom
imikejackson:vv/compute_triangle_geom_centroids
Open

BUG: Fix periodic feature-centroid model in Triangle and Feature centroid filters#1670
imikejackson wants to merge 2 commits into
BlueQuartzSoftware:developfrom
imikejackson:vv/compute_triangle_geom_centroids

Conversation

@imikejackson

Copy link
Copy Markdown
Contributor

Summary

Fixes the periodic (wrap-aware) centroid computation in both ComputeTriangleGeomCentroids and ComputeFeatureCentroids. Both used a constant half-domain offset added to the naive centroid, which is only correct when a wrapped feature's mass is symmetric about the seam and can place asymmetric wrapped features outside the domain.

Fixes #1665.

  • ComputeTriangleGeomCentroids — reimplement the AdjustCentroidsForPeriodicFaces BoundingBox overload as a largest-empty-gap minimum-image mean computed from the feature's vertex coordinates (in-domain wrap-back; arithmetic-mean fallback for domain-filling features).
  • ComputeTriangleGeomCentroids — fix a latent std::bad_function_call: the algorithm invoked m_MessageHandler.m_Callback() directly, bypassing the empty-callback guard; it threw whenever the periodic branch fired without an installed handler. Also add cancel checks to both loops and remove a per-feature std::set copy.
  • ComputeFeatureCentroids — reimplement the periodic path as a minimum-image circular mean accumulated during the cell sweep (per-feature unit-vector sums; trig only evaluated when Is Periodic is enabled). Remove the range-based ImageGeom overload of AdjustCentroidsForPeriodicFaces, whose per-feature index ranges are mathematically insufficient to compute a wrapped centroid.
  • Replace the prior periodic test fixtures (which validated the constant-offset model against itself — a circular oracle) with independent Class 1 minimum-image oracle values, add a domain-filling fallback fixture, and add V&V deliverables (report, deviations, provenance) for ComputeTriangleGeomCentroids.
  • The periodic option is SIMPLNX-only in both filters (legacy FindTriangleGeomCentroids / FindFeatureCentroids have no periodic mode), so no legacy behavior changes. The non-periodic paths are unchanged.

Test Plan

  • Tests pass on in-core build (SimplnxCore::ComputeTriangleGeomCentroids, SimplnxCore::ComputeFeatureCentroids)
  • Tests pass on out-of-core build (simplnx-ooc-Rel)
  • Adjacent GeometryHelpers consumers regression-checked (SharedFeatureFace)

New oracle tests include the discriminating asymmetric-wrap case: the old code produced an out-of-bounds centroid (4.625 on a [0,4] domain) where the correct minimum-image value is 3.625.

…artzSoftware#1665)

The periodic path added a constant |max-min|/2 offset to the naive
centroid, which is only correct when a wrapped feature's mass is
symmetric about the seam and can place the centroid outside the domain
for asymmetric features.

* Reimplement the AdjustCentroidsForPeriodicFaces BoundingBox overload as
  a largest-empty-gap minimum-image mean computed from the feature's
  vertex coordinates, with in-domain wrap-back and an arithmetic-mean
  fallback for domain-filling features.
* Fix a latent std::bad_function_call: the algorithm invoked
  m_MessageHandler.m_Callback() directly, bypassing the empty-callback
  guard; use the call operator instead.
* Add cancel checks to the triangle and feature loops; avoid a per-feature
  std::set copy.
* Add a Class 1 (Analytical) + Class 4 (Invariant) periodic oracle test
  covering non-wrapping, symmetric-wrap, asymmetric-wrap, and
  domain-filling features; passes in-core and out-of-core.
* Add V&V deliverables (report, deviations, provenance) and document the
  Is Periodic behavior.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…uartzSoftware#1665)

The periodic path applied a constant half-domain offset to the naive
centroid. That model is only correct when a wrapped feature's mass is
symmetric about the seam and can place asymmetric features outside the
domain. The prior spacing fix (BlueQuartzSoftware#1658) was necessary but not sufficient.

* Reimplement the periodic path as a minimum-image circular mean:
  accumulate per-feature unit-vector (cos/sin) sums during the cell
  sweep, and at finalize replace the arithmetic centroid with the
  circular mean on axes where the feature spans the full extent. A
  near-zero resultant (domain-filling feature) falls back to the
  arithmetic mean. Trig is only evaluated when Is Periodic is enabled.
* Remove the range-based ImageGeom overload of
  AdjustCentroidsForPeriodicFaces: per-feature index ranges are
  mathematically insufficient to compute a wrapped centroid, and it now
  has no callers.
* Re-derive periodic test fixtures D and E against an independent
  minimum-image oracle (no longer the circular constant-offset oracle),
  and add Fixture F for the domain-filling fallback. Pass in-core and OOC.
* Update the ComputeFeatureCentroids V&V report, deviations, and user
  docs to reflect the corrected model.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
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.

ComputeTriangleGeomCentroids: periodic centroid uses a constant-offset approximation (same defect class fixed in ComputeFeatureCentroids)

1 participant