diff --git a/devito/finite_differences/derivative.py b/devito/finite_differences/derivative.py index 74f7c7cfe94..371cff71643 100644 --- a/devito/finite_differences/derivative.py +++ b/devito/finite_differences/derivative.py @@ -151,7 +151,7 @@ def _process_kwargs(cls, expr, *dims, **kwargs): orders = kwargs.get('deriv_order', dims[0][1]) if dims[0][1] != orders: raise ValueError("Two different values of `deriv_order`") - new_dims = tuple([dims[0][0]]*dims[0][1]) + new_dims = tuple([dims[0][0]]*max(1, dims[0][1])) else: # Single Dimension orders = kwargs.get('deriv_order', 1) diff --git a/tests/test_derivatives.py b/tests/test_derivatives.py index 1ce0b953f8f..f8d4bd8ac69 100644 --- a/tests/test_derivatives.py +++ b/tests/test_derivatives.py @@ -662,6 +662,20 @@ def test_zero_spec(self): assert expr0.subs(drv0, drv1) == expr1 assert expr1.subs(drv1, drv0) == expr0 + def test_zero_fd_interp(self): + """ + Test that zero-order derivatives are generating interpolation coefficients + """ + grid = Grid((11,)) + x, = grid.dimensions + f = Function(name="f", grid=grid, space_order=4) + + assert Derivative(f, x, deriv_order=0).evaluate == f + expected = (-f.subs(x, x - x.spacing) / 16 + f.subs(x, x) * 9 / 16 + + f.subs(x, x + x.spacing) * 9 / 16 - f.subs(x, x + 2*x.spacing) / 16) + finterp = Derivative(f, (x, 0), x0={x: x+x.spacing/2}).evaluate + assert simplify(finterp - expected) == 0 + class TestTwoStageEvaluation(object):