From 43a08eec1daf4585d687ccbfbb0e1745e01084ee Mon Sep 17 00:00:00 2001 From: mloubout Date: Sun, 17 Nov 2024 00:04:31 -0500 Subject: [PATCH] misc: make builtin grid unit spacing --- devito/builtins/initializers.py | 4 +++- devito/finite_differences/finite_difference.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/devito/builtins/initializers.py b/devito/builtins/initializers.py index aa7869e3f7..dbe271eac1 100644 --- a/devito/builtins/initializers.py +++ b/devito/builtins/initializers.py @@ -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) diff --git a/devito/finite_differences/finite_difference.py b/devito/finite_differences/finite_difference.py index 237f7438d1..6714178b90 100644 --- a/devito/finite_differences/finite_difference.py +++ b/devito/finite_differences/finite_difference.py @@ -166,7 +166,7 @@ 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): scale = dim.spacing**(-deriv_order) # Transpose the FD, if necessary