Skip to content

Conversation

@mloubout
Copy link
Contributor

@mloubout mloubout commented Aug 8, 2024

Fix an FD hack to use proper interpolation.

@mloubout mloubout added the API api (symbolics, types, ...) label Aug 8, 2024
@codecov
Copy link

codecov bot commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 98.50746% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.02%. Comparing base (731f595) to head (bebafe3).
Report is 6 commits behind head on master.

Files Patch % Lines
devito/finite_differences/differentiable.py 95.23% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2439   +/-   ##
=======================================
  Coverage   87.01%   87.02%           
=======================================
  Files         236      236           
  Lines       44901    44938   +37     
  Branches     8361     8369    +8     
=======================================
+ Hits        39071    39107   +36     
- Misses       5101     5102    +1     
  Partials      729      729           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mloubout mloubout force-pushed the fd-interp-x0 branch 2 times, most recently from 7c92da6 to 0f557eb Compare August 8, 2024 16:48
# Step 1: Evaluate derivatives within expression
# Step 1: Evaluate non-derivative x0. We currently enforce a simple 2nd order
# interpolation to avoid very expensive finite differences on top of it.
x0_interp = {k: v for k, v in self.x0.items() if k not in self.dims
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is hardly readable, I'd turn it into a plain for loop and separate statements
also, k -> d

- 1: Evaluate derivatives within the expression. For example given
- 1: Interpolate non-derivative shifts.
I.e u[x, y].dx(x0={y: y + h_y/2}) requires to interpolate `u` in `y`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E.g.

"""
# Step 1: Evaluate derivatives within expression
# Step 1: Evaluate non-derivative x0. We currently enforce a simple 2nd order
# interpolation to avoid very expensive finite differences on top of it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no full stop

@mloubout mloubout force-pushed the fd-interp-x0 branch 5 times, most recently from 101b343 to c18c25b Compare August 13, 2024 02:44
x0_expr = {d: v for d, v in x0.items() if v is not expr.indices_ref[d]}
if x0_expr and not expr.is_parameter:
dims = tuple((d, 0) for d in x0_expr)
fd_o = tuple([2]*len(dims))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fd_o = (2,)*len(dims)

Copy link
Contributor

@FabioLuporini FabioLuporini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some DSE tests are failing due to a different op count. Why is the number of operations decreasing?

return expr


@interp_for_fd.register(Add)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just the default behaviour? in the absence of args return expr otherwise this?

sounds safer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made general to sympy.Expr

@mloubout
Copy link
Contributor Author

Why is the number of operations decreasing?

Slightly different indices in some rare cases

@mloubout mloubout force-pushed the fd-interp-x0 branch 2 times, most recently from a185b83 to 6b8446c Compare August 20, 2024 03:24
@mloubout mloubout force-pushed the fd-interp-x0 branch 2 times, most recently from cae161d to 7e372da Compare August 20, 2024 13:43
@mloubout mloubout merged commit f923ebe into master Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API api (symbolics, types, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants