Skip to content

Commit

Permalink
api: fix symbolic indices with stagger
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Mar 10, 2024
1 parent 17c53c1 commit 5f4bc51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion devito/finite_differences/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,18 @@ def generate_indices_staggered(expr, dim, order, side=None, x0=None):
indices = [start, start - diff]
indices = IndexSet(dim, indices)
else:
if start is dim:
if x0 is None or order % 2 == 0:
o_min = -order//2
o_max = order//2
elif start is dim:
o_min = -order//2 + 1
o_max = order//2
start = dim + diff/2
else:
o_min = -order//2
o_max = order//2 - 1
start = dim

d = make_stencil_dimension(expr, o_min, o_max)
iexpr = ind0 + d * diff
indices = IndexSet(dim, expr=iexpr)
Expand Down
2 changes: 1 addition & 1 deletion examples/seismic/elastic/elastic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run(shape=(50, 50), spacing=(20.0, 20.0), tn=1000.0,
def test_elastic(dtype):
_, _, _, [rec1, rec2, v, tau] = run(dtype=dtype)
assert np.isclose(norm(rec1), 19.25636, atol=1e-3, rtol=0)
assert np.isclose(norm(rec2), 0.644412, atol=1e-3, rtol=0)
assert np.isclose(norm(rec2), 0.6276, atol=1e-3, rtol=0)


@pytest.mark.parametrize('shape', [(51, 51), (16, 16, 16)])
Expand Down
2 changes: 1 addition & 1 deletion examples/seismic/viscoelastic/viscoelastic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def run(shape=(50, 50), spacing=(20.0, 20.0), tn=1000.0,
def test_viscoelastic(dtype):
_, _, _, [rec1, rec2, v, tau] = run(dtype=dtype)
assert np.isclose(norm(rec1), 12.28040, atol=1e-3, rtol=0)
assert np.isclose(norm(rec2), 0.320738, atol=1e-3, rtol=0)
assert np.isclose(norm(rec2), 0.312462, atol=1e-3, rtol=0)


@pytest.mark.parametrize('shape', [(51, 51), (16, 16, 16)])
Expand Down

0 comments on commit 5f4bc51

Please sign in to comment.