Skip to content

fix(ExternalTimeSeries): match georeferenced single precision outputs - #1422

Open
francoisbonneau wants to merge 3 commits into
nextfrom
fix/external-time-series-tolerance
Open

francoisbonneau wants to merge 3 commits into
nextfrom
fix/external-time-series-tolerance

Conversation

@francoisbonneau

Copy link
Copy Markdown
Member

Problem

ExternalTimeSeries::apply_to fails on GEOS outputs of a georeferenced model (UTM coordinates):

Point 12669 of the unique vertices [3417873.75 7263443 3305.04] is within the tolerance 7.27497 of several Block elements
  • The matching tolerance was GLOBAL_EPSILON × largest coordinate: 7.27 m in UTM, regardless of the cell size. On this mesh, thousands of vertices and cell barycenters have a neighbor closer than that, so they were always rejected as ambiguous. It is about 17× the actual single precision rounding (≤ 0.28 m).
  • The unique vertices were matched even though they carried no attribute (GEOS only writes cell data), and they failed first.

Changes

  • Point sets without a transferable attribute are not matched anymore.
  • The tolerance is now the maximum single precision rounding of the coordinates: half the float gap around the largest absolute coordinate, computed for each axis from the bounding box (with magnitudes below 1 rounded as 1), plus GLOBAL_EPSILON for computations on rounded coordinates (e.g. barycenters).
  • The ambiguity criterion is unchanged (second closest element within the tolerance). With a tolerance that matches the real rounding, that check is exact.

Tests

  • check_georeferenced_model: test_mesh3 scaled ×10 and translated to UTM coordinates, points rounded to float, cell values only.
  • check_unattributed_vertices: duplicated unique vertices without values no longer prevent applying the cell values.
  • Both tests fail without the fix. Real case verified: GEOS outputs (41 time steps, 14 Blocks) now load on the georeferenced model.

🤖 Generated with Claude Code

The matching tolerance was GLOBAL_EPSILON relative to the largest
coordinate: about 7 m on UTM coordinates, wider than the cell size, so
apply_to rejected the simulator outputs of georeferenced models as
ambiguous. It now bounds the single precision rounding of the points,
axis by axis (about 0.28 m on UTM coordinates).
Point sets without transferable attribute (e.g. unique vertices when the
simulator only writes cell data) are no longer matched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@BotellaA BotellaA left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: corrections needed before merge

1. Python docstring is out of date (cross-repo consistency / documentation)

bindings/python/src/model/representation/core/external_time_series.cpp, docstring of apply_to (around line 62): it still says the tolerance is "GLOBAL_EPSILON relative to the largest coordinate when larger than 1". This PR changed the rule in the C++ header but not here. Per AGENTS.md, an inaccurate docstring is a bug. Please describe the new rule:

  • the tolerance bounds the single precision rounding of the largest absolute coordinates;
  • a point set without a transferable attribute is not matched.

2. Barycenter tolerance: misleading comment, possibly too tight (design)

src/geode/model/representation/core/external_time_series.cpp, matching_tolerance. The comment says "GLOBAL_EPSILON is added for the computations made on the rounded coordinates (e.g. barycenters)". At UTM magnitudes, 1e-6 covers none of that error.

Here is a case where a cell barycenter can fail to match:

  • the simulator reads the mesh with float coordinates, averages the vertices into a cell center, and writes the center as a float again;
  • the error can then reach a full float gap: ½ gap from averaging the rounded vertices, plus ½ gap from writing the result;
  • at y ≈ 7e6 the gap is 0.5, so the error can reach 0.5 m, while the tolerance is ½ gap + 1e-6 ≈ 0.25 m.

Real GEOS outputs load, so GEOS probably computes cell centers in double. Still, please either:

  • allow one full float gap for the barycenter matching; it stays far below typical cell spacing; or
  • at least fix the comment so it does not claim barycenter errors are covered.

3. Missing test cases (tests)

check_georeferenced_model only covers the single-rounding case, which sits exactly at the tolerance limit. Its unique vertices carry no values. Please add:

  • a negative case at UTM magnitude: a shift just above the tolerance must still throw OpenGeodeException;
  • a case with values on the unique vertices at UTM magnitude, so that vertex matching is tested with data.

@BotellaA

Copy link
Copy Markdown
Member

🤖 claude-cross-repo-review: complete

…ferenced matching

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@francoisbonneau

Copy link
Copy Markdown
Member Author

Thanks for the review, all three points are addressed in the last commit.

  1. The Python docstring of apply_to now describes the single precision tolerance and says that a point set without a transferable attribute is not matched.
  2. Allowing a full float gap would reject the real case. At y ≈ 7e6, that tolerance is about 0.56 m, but the cell centers are only 0.55 m apart, so the ambiguity check would fail. The PVD reader computes the barycenters in double precision from the float vertices, so their error stays within half a gap. I fixed the misleading comment and documented, in the header and in matching_tolerance, that points rounded twice are not covered.
  3. The UTM tests are now:
    • check_georeferenced_cell_values: cell values only;
    • check_georeferenced_values: vertex and cell values, with the pressures checked on the vertices;
    • check_georeferenced_tolerance: barycenters shifted by 1 m (above the ≈ 0.25 m tolerance, below the 1.9 m barycenter spacing) must throw.

@BotellaA
BotellaA removed the request for review from BenPinet November 30, 2026 12:22
…ated Blocks

- Several points matched with the same Block element (e.g. a vertex
  written with slightly different coordinates by several datasets) are
  accepted with an error log: the closest point is kept.
- A Block is represented in a point set when one of its polyhedra is
  matched (cell barycenters) or one of its matched vertices belongs to no
  other Block (unique vertices). Every element of a represented Block must
  be matched, the other Blocks (e.g. outside of the simulated regions) are
  left untouched, including their vertices shared with simulated Blocks.
- Both point sets are matched and checked before any value is written: a
  rejected time series leaves the model unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants