Skip to content

Commit d544404

Browse files
committed
In column_track() base tolerance on local rather than global grid size
1 parent dbdd504 commit d544404

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

mulgrids.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,8 +2005,6 @@ def column_track(self, line):
20052005

20062006
tol = 1e-3
20072007
def track_dist(p): return norm(p - line[0])
2008-
dl = track_dist(line[1])
2009-
tol_dl = tol * dl
20102008

20112009
track, dist = [], []
20122010
start_col, end_col = None, None
@@ -2032,7 +2030,8 @@ def track_dist(p): return norm(p - line[0])
20322030
elif col == end_col:
20332031
pts = [pts[0], line[-1]]
20342032
din, dout = track_dist(pts[0]), track_dist(pts[-1])
2035-
if abs(dout - din) > tol_dl:
2033+
col_tol = max(col.side_lengths) * tol
2034+
if abs(dout - din) > col_tol:
20362035
track.append((col, pts[0], pts[-1]))
20372036
dist.append(din)
20382037

tests/test_mulgrid.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,16 @@ def test_column_track(self):
356356
self.assertTrue(np.allclose(t[0][1], line[0]))
357357
self.assertTrue(np.allclose(t[-1][2], line[1]))
358358

359+
# contrasting grid sizes:
360+
dx = [1] * 50 + [2] * 25 + [5] * 20 + [10] * 20 + [100] * 6 + [1000] * 2
361+
geo = mulgrid().rectangular(dx, [100]*5, [10])
362+
line = [np.array([0, 0]), np.array([3000, 0])]
363+
t = geo.column_track(line)
364+
self.assertEqual(len(t), 123)
365+
if (len(t) == 123):
366+
self.assertTrue(np.allclose(t[0][1], line[0]))
367+
self.assertTrue(np.allclose(t[-1][2], line[1]))
368+
359369
def test_grid3d(self):
360370
"""3D grid"""
361371

0 commit comments

Comments
 (0)