Skip to content

Commit

Permalink
update from comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Apr 14, 2020
1 parent 1e91124 commit a8b7ab0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion devito/operator/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _lower_exprs(cls, expressions, **kwargs):
dimension_map = {}

# Handle Functions (typical case)
mapper = {f: f.indexify(w_shift=True, extra_subs=dimension_map)
mapper = {f: f.indexify(lshift=True, subs=dimension_map)
for f in retrieve_functions(expr)}

# Handle Indexeds (from index notation)
Expand Down
8 changes: 4 additions & 4 deletions devito/types/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,17 +919,17 @@ def _data_alignment(self):
"""
return default_allocator().guaranteed_alignment

def indexify(self, indices=None, w_shift=False, extra_subs=None):
def indexify(self, indices=None, lshift=False, subs=None):
"""Create a types.Indexed from the current object."""
if indices is not None:
return Indexed(self.indexed, *indices)

# Substitution for each index (spacing only used in own dimension)
extra_subs = extra_subs or {}
subs = [{**d._indexify_map, **extra_subs} for d in self.dimensions]
subs = subs or {}
subs = [{**{d.spacing: 1, -d.spacing: -1}, **subs} for d in self.dimensions]

# Add halo shift
shift = self._size_nodomain.left if w_shift else tuple([0]*len(self.dimensions))
shift = self._size_nodomain.left if lshift else tuple([0]*len(self.dimensions))
# Indices after substitutions
indices = [(a - o + f).xreplace(s) for a, o, f, s in
zip(self.args, self.origin, shift, subs)]
Expand Down
8 changes: 0 additions & 8 deletions devito/types/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,6 @@ def __new__(cls, *args, **kwargs):
def __init_finalize__(self, name, spacing=None):
self._spacing = spacing or Scalar(name='h_%s' % name, is_const=True)

@cached_property
def _indexify_map(self):
return {self.spacing: 1}


class DefaultDimension(Dimension, DataSymbol):

Expand Down Expand Up @@ -746,10 +742,6 @@ def free_symbols(self):
retval |= self.condition.free_symbols
return retval

@cached_property
def _indexify_map(self):
return {self.spacing: 1, -self.spacing: -1}

# Pickling support
_pickle_kwargs = DerivedDimension._pickle_kwargs + ['factor', 'condition', 'indirect']

Expand Down

0 comments on commit a8b7ab0

Please sign in to comment.