devitocodes / devito

DSL and compiler framework for automated finite-differences and stencil computation

Home Page:http://www.devitoproject.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

default time_M value in presence of saved TimeFunction is wrong

FabioLuporini opened this issue · comments

Reproducer

import numpy as np
from devito import Eq, Grid, TimeFunction, Operator

grid = Grid(shape=(4, 4))

u = TimeFunction(name='u', grid=grid)
usave = TimeFunction(name='usave', grid=grid, save=5)

eqns = [Eq(u.forward, u + 1),
        Eq(usave, u)]

op = Operator(eqns)

assert op.arguments()['time_M'] == 4

op.apply()

assert all(np.all(usave.data[i] == i) for i in range(5))

The issue stems from the fact that op._dspace sets [0,1] as the time dimension's data space bounds, and that "1" will cause the default value to become 3. Which is clearly wrong, since 4 is perfectly fine here.

This violates the principle of least surprise.