diff --git a/devito/operations/interpolators.py b/devito/operations/interpolators.py index f7896b73d96..2903467d218 100644 --- a/devito/operations/interpolators.py +++ b/devito/operations/interpolators.py @@ -189,7 +189,7 @@ def _interpolation_indices(self, variables, offset=0, field_offset=0, mapper[d] = ConditionalDimension(p.name, self.sfunction._sparse_dim, condition=condition, indirect=True) # Apply mapper to each variable with origin correction before the - # dimension get replaced. + # dimensions get replaced. vmapper = {} for v in variables: try: diff --git a/tests/test_symbolics.py b/tests/test_symbolics.py index fccf793495b..8015bb403a2 100644 --- a/tests/test_symbolics.py +++ b/tests/test_symbolics.py @@ -9,7 +9,7 @@ Operator, SubDimension, norm, Le, Ge, Gt, Lt, Abs, sin, cos, Min, Max) from devito.ir import Expression, FindNodes from devito.symbolics import (retrieve_functions, retrieve_indexed, evalrel, # noqa - CallFromPointer, Cast, FieldFromPointer, + CallFromPointer, Cast, FieldFromPointer, INT, FieldFromComposite, IntDiv, ccode, uxreplace) from devito.types import Array, Bundle, LocalObject, Object, Symbol as dSymbol @@ -31,6 +31,18 @@ def test_float_indices(): assert indices == 1 +def test_func_of_indices(): + """ + Test that origin is correctly processed with functions + """ + grid = Grid((10,)) + x = grid.dimensions[0] + u = Function(name="u", grid=grid, space_order=2, staggered=x) + us = u.subs({u.indices[0]: INT(Abs(u.indices[0]))}) + assert us.indices[0] == INT(Abs(x + x.spacing/2)) + assert us.indexify().indices[0] == INT(Abs(x)) + + @pytest.mark.parametrize('dtype,expected', [ (np.float32, "float r0 = 1.0F/h_x;"), (np.float64, "double r0 = 1.0/h_x;")