From 48180ebe6f1f75ab72693fb0900b5b5f70febc2d Mon Sep 17 00:00:00 2001 From: Edward Caunt Date: Thu, 29 Jun 2023 14:41:34 +0100 Subject: [PATCH] geometry: fixed the staggered interior-sectioning test --- schism/geometry/geometry.py | 5 +++-- tests/test_geometry.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/schism/geometry/geometry.py b/schism/geometry/geometry.py index e02a4e4..57f9ab7 100644 --- a/schism/geometry/geometry.py +++ b/schism/geometry/geometry.py @@ -214,7 +214,7 @@ def _get_interior_mask(self): # Exclude exterior points # Check against min(grid.spacing)*eta as anything within # this is probably too close anyway - mask_inside = sdf.data > min(spacing)*cutoff + _feps + mask_inside = sdf.data > min(spacing)*cutoff mask_near = np.logical_and(mask_near, mask_inside) # Set up boundary points in physical space @@ -238,8 +238,9 @@ def _get_interior_mask(self): # Check nearest boundary point not in box # Errs on the side of caution (cutoff slightly larger # according to floating point precision) + cutoff_check = (cutoff+_feps)*np.array(spacing)[np.newaxis, :] interior = np.any(np.abs(query - bp[i]) - > (cutoff+_feps)*np.array(spacing)[np.newaxis, :], + > cutoff_check, axis=1) # Fill interior mask away from boundary diff --git a/tests/test_geometry.py b/tests/test_geometry.py index ffebfd1..86418ac 100644 --- a/tests/test_geometry.py +++ b/tests/test_geometry.py @@ -14,6 +14,7 @@ def read_sdf(surface, dims): """Unpickle an sdf""" path = os.path.dirname(os.path.abspath(__file__)) fname = path + '/sdfs/' + surface + '_' + str(dims) + 'd.dat' + print(fname) with open(fname, 'rb') as f: sdf = pickle.load(f) return sdf @@ -275,7 +276,7 @@ def test_interior_mask_staggered(self, surface, setup): check_mask = ymsh < 50 check_mask_stagger = ymsh < 51 for origin in bg.interior_mask: - if origin == (zero, zero): + if origin == (zero, zero) or origin == (zero, h_y/2): check = bg.interior_mask[origin][slices] \ == check_mask[slices] else: