Skip to content

Commit

Permalink
misc: make builtin grid unit spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Nov 17, 2024
1 parent 3c8edd9 commit 5f93400
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion devito/builtins/initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ def fset(f, g):
# Create the padded grid:
objective_domain = ObjectiveDomain(lw)
shape_padded = tuple([np.array(s) + 2*l for s, l in zip(shape, lw)])
grid = dv.Grid(shape=shape_padded, subdomains=objective_domain)
extent_padded = tuple([s-1 for s in shape_padded])
grid = dv.Grid(shape=shape_padded, subdomains=objective_domain,
extent=extent_padded)

f_c = dv.Function(name='f_c', grid=grid, space_order=2*max(lw), dtype=dtype)
f_o = dv.Function(name='f_o', grid=grid, dtype=dtype)
Expand Down
3 changes: 2 additions & 1 deletion devito/finite_differences/finite_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def make_derivative(expr, dim, fd_order, deriv_order, side, matvec, x0, coeffici

# Adimensional weight from custom coeffs need to multiply by h^order
scale = None
if wdim is None and not weights[0].has(dim.spacing):
if wdim is None and not all(w.has(dim.spacing) for w in weights if w != 0):
print(weights)
scale = dim.spacing**(-deriv_order)

# Transpose the FD, if necessary
Expand Down

0 comments on commit 5f93400

Please sign in to comment.