Skip to content

Commit e69f9ba

Browse files
committed
WIP
1 parent d8fabb4 commit e69f9ba

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

devito/timestepping/superstep.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def superstep_generator_iterative(field, stencil, k, tn=0):
55
''' Generate superstep iteratively:
6-
A^j+1 = A·A^j
6+
Aʲ⁺¹ = A·
77
'''
88
# New fields, for vector formulation both current and previous timestep are needed
99
name = field.name
@@ -42,13 +42,15 @@ def superstep_generator_iterative(field, stencil, k, tn=0):
4242

4343
def superstep_generator(field, stencil, k, tn=0):
4444
''' Generate superstep using a binary decomposition:
45-
A^k = a_j A^2^j + ... + a_2 A^2^2 + a_1 A² + a_0 A
45+
A^k = aⱼ A^2ʲ × ... × a₂ A^2² × a₁ A² × a₀ A
46+
where k = aⱼ·2ʲ + ... + a₂·2² + a₁·2¹ + a₀·2⁰
4647
'''
4748
# New fields, for vector formulation both current and previous timestep are needed
4849
name = field.name
4950
grid = field.grid
50-
u = TimeFunction(name=f'{name}_ss', grid=grid, time_order=2, space_order=2*k)
51-
u_prev = TimeFunction(name=f'{name}_ss_p', grid=grid, time_order=2, space_order=2*k)
51+
# time_order of `field` needs to be 2
52+
u = TimeFunction(name=f'{name}_ss', grid=grid, time_order=1, space_order=2*k)
53+
u_prev = TimeFunction(name=f'{name}_ss_p', grid=grid, time_order=1, space_order=2*k)
5254

5355
superstep_solution_transfer(field, u, u_prev, tn)
5456

@@ -73,6 +75,7 @@ def superstep_solution_transfer(old, new, new_p, tn):
7375
''' Transfer state from a previous TimeFunction to a 2 field superstep
7476
Used after injecting source using standard timestepping.
7577
'''
78+
# 3 should be replaced with `old.time_order + 1` although this needs some thought
7679
idx = tn % 3 if old.save is None else -1
7780
new.data[0, :] = old.data[idx - 1]
7881
new.data[1, :] = old.data[idx]

examples/timestepping/acoustic_superstep_2d.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ def acoustic_model(model, step=1, snapshots=1):
129129
else:
130130
new_u, new_u_p, *stencil = superstep_generator(u, stencil.rhs, step)
131131

132-
new_u.data[0, :] = u.data[idx - 1]
133-
new_u.data[1, :] = u.data[idx]
134-
new_u_p.data[0, :] = u.data[idx - 2]
135-
new_u_p.data[1, :] = u.data[idx - 1]
136-
137132
tn2 = int(np.ceil((t2 - t1)/model.critical_dt))
138133
dt = (t2 - t1)/tn2
139134

0 commit comments

Comments
 (0)