devitocodes/devito

Conflict in time_M when using saved buffer and conditional dimension

Closed this issue · 1 comments

When using a conditional dimension that contains Ge / Le types of conditions and a saved buffer defined over that conditional dimension, there is a conflict in the calculation of time_M for different objects:

from devito import *
from devito.symbolics import CondEq


grid = Grid(shape=(10, 10))
time = grid.time_dim

nt = 200
bounds = (10, 100)
factor = 5

condition = sympy.And(CondEq(time % 7, 0),
                      Ge(time, bounds[0]),
                      Le(time, bounds[1]), )

time_under = ConditionalDimension(name='timeu',
                                  parent=time,
                                  factor=7,
                                  condition=condition)

buffer_size = (bounds[1] - bounds[0] + factor) // factor + 1

rec = SparseTimeFunction(name='rec', grid=grid, npoint=1, nt=nt)

u = TimeFunction(name='u', grid=grid, space_order=2)
usaved = TimeFunction(name='usaved', grid=grid, space_order=2, time_dim=time_under, save=buffer_size)

eq = [Eq(usaved, u)] + rec.interpolate(u)

op = Operator(eq)
op(time_m=1, time_M=nt-1, usaved=usaved, rec=rec)

produces the error ValueError: Unable to find unique value for key time_M, candidates: [199, range(1, 139)].

I just tried it and I can confirm this is still an issue