Skip to content

fix(cpgrid): reject out-of-segment crossing nodes#59

Open
tomerarnon wants to merge 1 commit into
sintefmath:mainfrom
Terra-AI-Inc:ta_cpgrid_crossing_node_fixes_upstream
Open

fix(cpgrid): reject out-of-segment crossing nodes#59
tomerarnon wants to merge 1 commit into
sintefmath:mainfrom
Terra-AI-Inc:ta_cpgrid_crossing_node_fixes_upstream

Conversation

@tomerarnon

Copy link
Copy Markdown
Contributor

Summary

This changes corner-point grid crossing-node construction to treat line intersections as bounded segment intersections.

Previously, find_crossing_node used the intersection of the infinite lines defined by two CPG face edges. For nearly parallel or strongly skewed edges, that can produce an extra node far outside the local grid geometry. The new logic:

  • computes segment parameters for both edges
  • rejects intersections outside either segment
  • keeps a small tolerance for floating-point endpoint overshoot
  • skips adding a crossing node when no bounded crossing exists

Tests

  • added unit coverage for an interior crossing
  • added unit coverage for a tiny endpoint overshoot
  • added unit coverage for a near-parallel out-of-segment case

@tomerarnon

Copy link
Copy Markdown
Contributor Author

Here is a minimal reproducer for the crossing-node issue using find_crossing_node directly.

using GeoEnergyIO
import GeoEnergyIO.CornerPointGrid: find_crossing_node

x1 = [517.2413793103449, 827.5862068965517, 832.5650700477282]
x2 = [517.2413793103449, 775.8620689655172, 843.7944466341665]
x3 = [517.2413793103449, 827.5862068965517, 833.565070047728]
x4 = [517.2413793103449, 775.8620689655172, 844.7944461223784]

pt = find_crossing_node(x1, x2, x3, x4)
println(pt)

The four points define two finite CPG edge segments. Their local envelope is:

y = 775.8620689655172 .. 827.5862068965517
z = 832.5650700477282 .. 844.7944461223784

Package output before this change:

[517.2413793103449, -1.010647461257371e8, 2.1942298049696658e7]

That point is far outside the finite segment envelope. The corresponding segment parameter is:

t = 1.9539344250975822e6

Package output with this PR:

nothing

Visual summary:

GeoEnergyIO crossing-node MWE

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.

1 participant