Skip to content

Commit 5c5591a

Browse files
committed
dsl: Fix bug with overlapping corners
1 parent 390cd5c commit 5c5591a

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

devito/types/grid.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,25 +1101,28 @@ def _build_domains_overlap(self, grid: Grid) -> tuple[int, tuple[np.ndarray]]:
11011101
side = self.border_dims[d]
11021102

11031103
if isinstance(side, Dimension):
1104-
bounds_l = [0 if j != 2*i else s - b[0]
1104+
# Note: counterintuitive since the left-side boundary only has
1105+
# right-side thickness
1106+
bounds_l = [0 if j != 2*i+1 else s - b[0]
11051107
for j in range(2*len(grid.dimensions))]
1106-
bounds_r = [0 if j != 2*i+1 else s - b[1]
1108+
bounds_r = [0 if j != 2*i else s - b[1]
11071109
for j in range(2*len(grid.dimensions))]
11081110

11091111
bounds.extend([bounds_l, bounds_r])
11101112

11111113
elif side == 'left':
1112-
bounds.append([0 if j != 2*i else s - b[0]
1114+
bounds.append([0 if j != 2*i+1 else s - b[0]
11131115
for j in range(2*len(grid.dimensions))])
11141116

11151117
elif side == 'right':
1116-
bounds.append([0 if j != 2*i+1 else s - b[1]
1118+
bounds.append([0 if j != 2*i else s - b[1]
11171119
for j in range(2*len(grid.dimensions))])
11181120

11191121
else:
11201122
raise ValueError(f"Unrecognised side value {side}")
11211123

1122-
return len(bounds), tuple(np.array(bounds))
1124+
# Need to transpose array to fit into expected format for SubDomainSet
1125+
return len(bounds), tuple(np.array(bounds).T)
11231126

11241127
def _build_domains_nooverlap(self, grid: Grid) -> tuple[int, tuple[np.ndarray]]:
11251128
domain_map = {} # Stores the side
@@ -1139,11 +1142,14 @@ def _build_domains_nooverlap(self, grid: Grid) -> tuple[int, tuple[np.ndarray]]:
11391142
RIGHT: (s - b[1], 0)}
11401143
elif side == 'left':
11411144
domain_map[d] = (LEFT, CENTER)
1145+
# For intuitive behaviour, 'nocorners' should always skip corners
1146+
centerval = b[1] if self.corners == 'nocorners' else 0
11421147
interval_map[d] = {LEFT: (0, s - b[0]),
1143-
CENTER: (b[0], 0)}
1148+
CENTER: (b[0], centerval)}
11441149
elif side == 'right':
11451150
domain_map[d] = (CENTER, RIGHT)
1146-
interval_map[d] = {CENTER: (0, b[1]),
1151+
centerval = b[0] if self.corners == 'nocorners' else 0
1152+
interval_map[d] = {CENTER: (centerval, b[1]),
11471153
RIGHT: (s - b[1], 0)}
11481154
else:
11491155
raise ValueError(f"Unrecognised side value {side}")

tests/test_subdomains.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,8 @@ class Dummy(SubDomainSet):
724724
assert y.is_Parallel
725725
assert z.is_Parallel
726726

727+
728+
class TestBorder:
727729
def test_border_3d(self):
728730
"""
729731
Test the functionality of the Border class in higher dimensions.

0 commit comments

Comments
 (0)