Skip to content

Commit

Permalink
examples: add rotated fd section to userapi notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Mar 5, 2024
1 parent bc75bf1 commit 3e585c3
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 49 deletions.
12 changes: 6 additions & 6 deletions devito/finite_differences/derivative.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ def _process_kwargs(cls, expr, *dims, **kwargs):

def __call__(self, x0=None, fd_order=None, side=None, method=None):
if self.ndims == 1:
_fd_order = fd_order or self._fd_order
_side = side or self._side
_method = method or self._method
new_x0 = {self.dims[0]: x0} if x0 is not None else self.x0
return self._new_from_self(fd_order=_fd_order, side=_side, x0=new_x0,
method=_method)
fd_order = fd_order or self._fd_order
side = side or self._side
method = method or self._method
x0 = {self.dims[0]: x0} if x0 is not None else self.x0
return self._new_from_self(fd_order=fd_order, side=side, x0=x0,
method=method)

if side is not None:
raise TypeError("Side only supported for first order single"
Expand Down
5 changes: 3 additions & 2 deletions devito/finite_differences/finite_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def first_derivative(expr, dim, fd_order=None, side=centered, matvec=direct, x0=
finite difference. Defaults to `direct`.
x0 : dict, optional
Origin of the finite-difference scheme as a map dim: origin_dim.
coefficients : strong, optional
coefficients : string, optional
Use taylor or custom coefficients (weights). Defaults to taylor.
expand : bool, optional
If True, the derivative is fully expanded as a sum of products,
Expand Down Expand Up @@ -220,7 +220,8 @@ def make_derivative(expr, dim, fd_order, deriv_order, side, matvec, x0, coeffici
indices, x0 = generate_indices(expr, dim, fd_order, side=side, matvec=matvec,
x0=x0)

# Finite difference weights from Taylor approximation given these positions
# Finite difference weights corresponding to the indices. Computed via the
# `coefficients` method (`taylor` or `symbolic`)
weights = fd_weights_registry[coefficients](expr, deriv_order, indices, x0)

# Enforce fixed precision FD coefficients to avoid variations in results
Expand Down
163 changes: 122 additions & 41 deletions examples/userapi/01_dsl.ipynb

Large diffs are not rendered by default.

0 comments on commit 3e585c3

Please sign in to comment.