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

source injection onto multiple time functions when source term has non-grid dimensions fails

deckerla opened this issue · comments

import devito

nt = 10
nfreq = 2
g = devito.Grid(shape=(5,6))
u1 = devito.TimeFunction(name="u1", grid=g, time_order=0)
u2 = devito.TimeFunction(name="u2", grid=g, time_order=0)

stf = devito.SparseTimeFunction(name="stf", nt=nt, npoint=1, grid=g)
stf.data[:] = 1.
stf.coordinates_data[:] = 0.5
freq_dim = devito.DefaultDimension(name="freq_dim", default_value=nfreq)
f = devito.Function(name="f", dimensions=(freq_dim,), shape=(nfreq,), grid=g)
f.data[:] = 2.

inj_u1 = stf.inject(field=u1.forward, expr=stf*f)
inj_u2 = stf.inject(field=u2.forward, expr=stf*f)

op1 = devito.Operator([inj_u1], opt=("advanced", {"min-storage":True}), name="inj_u1")
print(op1.parameters)
op1.apply()

op2 = devito.Operator([inj_u2], opt=("advanced", {"min-storage":True}), name="inj_u2")
print(op2.parameters)
op2.apply()

op3 = devito.Operator([inj_u1, inj_u2], opt=("advanced", {"min-storage":True}), name="Failing")
print(op3.parameters)
op3.apply()

this results in:

cvx@cbox-lukedecker-ela2d:~/.julia/dev/JetPackDevitoPSD/test$ python mfe.py 
(f(freq_dim), stf(time, p_stf), stf_coords(p_stf, d), u1(t, x, y), x_M, x_m, y_M, y_m, freq_dim_M, freq_dim_m, h_x, h_y, o_x, o_y, p_stf_M, p_stf_m, time_M, time_m, nthreads_nonaffine, timers)
Operator `inj_u1` ran in 0.04 s
(f(freq_dim), stf(time, p_stf), stf_coords(p_stf, d), u2(t, x, y), x_M, x_m, y_M, y_m, freq_dim_M, freq_dim_m, h_x, h_y, o_x, o_y, p_stf_M, p_stf_m, time_M, time_m, nthreads_nonaffine, timers)
Operator `inj_u2` ran in 0.01 s
(f(freq_dim), stf(time, p_stf), stf_coords(p_stf, d), u1(t, x, y), u2(t, x, y), x_M, x_m, y_M, y_m, freq_dim_M, freq_dim_m, h_x, h_y, o_x, o_y, p_stf_M, p_stf_m, posx, posy, time_M, time_m, nthreads_nonaffine, timers)
Traceback (most recent call last):
  File "/home/cvx/.julia/dev/JetPackDevitoPSD/test/mfe.py", line 29, in <module>
    op3.apply(posx=0.5, posy=0.5)
  File "/home/cvx/.conda/envs/conda_jl/lib/python3.10/site-packages/devito/operator/operator.py", line 812, in apply
    args = self.arguments(**kwargs)
  File "/home/cvx/.conda/envs/conda_jl/lib/python3.10/site-packages/devito/operator/operator.py", line 653, in arguments
    args = self._prepare_arguments(**kwargs)
  File "/home/cvx/.conda/envs/conda_jl/lib/python3.10/site-packages/devito/operator/operator.py", line 604, in _prepare_arguments
    p._arg_check(args, self._dspace[p], am=self._access_modes.get(p))
AttributeError: 'Symbol' object has no attribute '_arg_check'