Skip to content

Commit

Permalink
api: avoid duplicate properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed May 21, 2024
1 parent e7561b4 commit c3d8356
Showing 1 changed file with 18 additions and 34 deletions.
52 changes: 18 additions & 34 deletions devito/types/dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ def coefficients(self):
"""Form of the coefficients of the function."""
return self._coefficients

@property
def _shape_with_outhalo(self):
return self.shape_with_halo

@cached_property
def shape(self):
"""
Expand Down Expand Up @@ -231,27 +235,19 @@ def shape_domain(self):

@cached_property
def shape_with_halo(self):
return tuple(j + i + k for i, (j, k) in zip(self.shape, self._size_outhalo))
"""
Shape of the domain+outhalo region. The outhalo is the region
surrounding the domain that may be read by an Operator.
@cached_property
def _shape_with_outhalo(self):
Notes
-----
In an MPI context, this is the *local* with_halo region shape.
Further, note that the outhalo of inner ranks is typically empty, while
the outhalo of boundary ranks contains a number of elements depending
on the rank position in the decomposed grid (corner, side, ...).
"""
return tuple(j + i + k for i, (j, k) in zip(self.shape, self._size_outhalo))

_shape_with_halo_docstring = """\
Shape of the domain+outhalo region. The outhalo is the region
surrounding the domain that may be read by an Operator.
Notes
-----
In an MPI context, this is the *local* with_halo region shape.
Further, note that the outhalo of inner ranks is typically empty, while
the outhalo of boundary ranks contains a number of elements depending
on the rank position in the decomposed grid (corner, side, ...).
"""

shape_with_halo.__doc__ = _shape_with_halo_docstring
_shape_with_outhalo.__doc__ = _shape_with_halo_docstring

@cached_property
def _shape_with_inhalo(self):
"""
Expand Down Expand Up @@ -317,25 +313,13 @@ def size_global(self):
"""
return reduce(mul, self.shape_global)

@cached_property
@property
def _offset_inhalo(self):
"""Number of points before the first and last halo elements."""
left = tuple(self._size_padding.left)
right = tuple(np.add(np.add(left, self._size_halo.left), self._size_domain))

offsets = tuple(Offset(i, j) for i, j in zip(left, right))
return super()._offset_halo

return DimensionTuple(*offsets, getters=self.dimensions, left=left, right=right)

@cached_property
@property
def _size_inhalo(self):
"""Number of points in the halo region."""
left = tuple(zip(*self._halo))[0]
right = tuple(zip(*self._halo))[1]

sizes = tuple(Size(i, j) for i, j in self._halo)

return DimensionTuple(*sizes, getters=self.dimensions, left=left, right=right)
return super()._size_halo

@cached_property
def _size_outhalo(self):
Expand Down

0 comments on commit c3d8356

Please sign in to comment.