Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FD for composite staggered expr #1247

Merged
merged 7 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fd: fix single function in differentiable with stggering
  • Loading branch information
mloubout committed May 6, 2020
commit 06acbf6c37dd4270c0de522931f28e16729c278e
2 changes: 2 additions & 0 deletions devito/finite_differences/differentiable.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def dimensions(self):
@property
def indices_ref(self):
"""The reference indices of the object (indices at first creation)."""
if len(self._args_diff) == 1:
return self._args_diff[0].indices_ref
return EnrichedTuple(*self.dimensions, getters=self.dimensions)

@cached_property
Expand Down
14 changes: 14 additions & 0 deletions tests/test_staggered_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ def test_indices(ndim):
for dd in d:
assert f.indices_ref[dd] == dd + dd.spacing / 2

def test_indices_differentiable():
"""
Test that differentiable object have correct indices and indices_ref
"""
grid = Grid((10,))
x = grid.dimensions[0]
x0 = x + x.spacing/2
f = Function(name="f", grid=grid, staggered=x)
assert f.indices_ref[x] == x0
assert (1 * f).indices_ref[x] == x0
assert (1. * f).indices_ref[x] == x0
assert (1 + f).indices_ref[x] == x0
assert (1 / f).indices_ref[x] == x0


@pytest.mark.parametrize('ndim', [1, 2, 3])
def test_avg(ndim):
Expand Down