devito
devito copied to clipboard
Time loop splitting
When running an operator with an injection at the beginning, the time loop is split in two.
This can be reproduced with an example of the form:
from devito import *
grid = Grid(shape=(10, 10))
time = grid.time_dim
nt = 200
factor = 5
time_under = ConditionalDimension(name='timeu', parent=time, factor=factor)
rec = SparseTimeFunction(name='rec', grid=grid, npoint=1, nt=nt)
u = TimeFunction(name='u', grid=grid, space_order=2)
v = TimeFunction(name='v', grid=grid, space_order=2)
g = Function(name='g', grid=grid, space_order=2)
usaved = TimeFunction(name='usaved', grid=grid, space_order=2, time_dim=time_under, save=nt//factor+1)
eq = [Eq(u.forward, u + 1), Eq(usaved, u.forward)] + rec.interpolate(u)
op = Operator(eq)
op(time_m=1, time_M=nt-1)
t = rec.time_dim
eq = rec.inject(field=v, expr=rec) + [Eq(v.backward, v + 1), Inc(g, v.backward * usaved)]
op = Operator(eq)
op(time_m=1, time_M=nt-1)
where the second operator ends up with two time loops instead of one.