Skip to content

Commit 7249fa0

Browse files
committed
dsl: Remove unnecessary Thickness kwargs and consolidate
1 parent 2dc440a commit 7249fa0

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

‎devito/types/dimension.py‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,16 @@ class SpaceDimension(BasicDimension):
464464

465465
is_Space = True
466466

467+
@cached_property
468+
def rank_offsets(self):
469+
"""
470+
The number of points of `root` owned by the MPI ranks before (`side=LEFT`)
471+
or after (`side=RIGHT`) this one, that is the offset of this rank from that
472+
edge of the Grid. Zero without domain decomposition.
473+
"""
474+
return tuple(RankOffset(name=f"{self.name}_{s}_ofs", side=s, root=self)
475+
for s in (LEFT, RIGHT))
476+
467477

468478
class TimeDimension(BasicDimension):
469479

@@ -566,6 +576,7 @@ class Thickness(DataSymbol):
566576
__rkwargs__ = DataSymbol.__rkwargs__ + ('root', 'side', 'local', 'value', 'separated')
567577

568578
def __new__(cls, *args, root=None, side=None, local=False, separated=False, **kwargs):
579+
kwargs.setdefault('nonnegative', True)
569580
newobj = super().__new__(cls, *args, **kwargs)
570581
newobj._root = root
571582
newobj._side = side
@@ -695,11 +706,9 @@ def _interval(self):
695706

696707
@memoized_meth
697708
def _symbolic_thickness(self, **kwargs):
698-
kwargs = {'dtype': np.int32, 'is_const': True, 'nonnegative': True,
699-
'separated': self.separated}
700-
701709
names = [f"{self.parent.name}_{s}tkn" for s in ('l', 'r')]
702-
return SubDimensionThickness(*[Thickness(name=n, **kwargs) for n in names])
710+
return SubDimensionThickness(*[Thickness(name=n, separated=self.separated)
711+
for n in names])
703712

704713
@cached_property
705714
def symbolic_min(self):
@@ -825,9 +834,7 @@ def middle(cls, name, parent, thickness_left, thickness_right, local=False,
825834

826835
@memoized_meth
827836
def _symbolic_thickness(self, thickness=None):
828-
kwargs = {'dtype': np.int32, 'is_const': True, 'nonnegative': True,
829-
'root': self.root, 'local': self.local,
830-
'separated': self.separated}
837+
kwargs = {'root': self.root, 'local': self.local, 'separated': self.separated}
831838

832839
names = [f"{self.parent.name}_{s}tkn" for s in ('l', 'r')]
833840
sides = [LEFT, RIGHT]
@@ -856,10 +863,7 @@ def _glb_interval(self):
856863
rank's local indices. Unlike `_interval`, these are not clipped to this
857864
rank, so with domain decomposition they may lie in the halo or beyond.
858865
"""
859-
kwargs = {'dtype': np.int32, 'is_const': True, 'nonnegative': True,
860-
'root': self.root}
861-
lofs = RankOffset(name=f"{self.root.name}_lofs", side=LEFT, **kwargs)
862-
rofs = RankOffset(name=f"{self.root.name}_rofs", side=RIGHT, **kwargs)
866+
lofs, rofs = self.root.rank_offsets
863867

864868
# The global Grid edges
865869
left = self.parent.symbolic_min - lofs

0 commit comments

Comments
 (0)