-
Notifications
You must be signed in to change notification settings - Fork 173
refactor interpolation #4595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
refactor interpolation #4595
Conversation
fix bcs
6d080b1
to
0934e61
Compare
49b1760
to
cc0276b
Compare
cc0276b
to
15bdd53
Compare
firedrake/interpolation.py
Outdated
self.operand = operand | ||
self.dual_arg = dual_arg | ||
self.target_space = dual_arg.function_space().dual() | ||
self.target_mesh = as_domain(self.target_space) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.target_mesh = as_domain(self.target_space) | |
self.target_mesh = self.target_space.mesh() |
firedrake/interpolation.py
Outdated
def _interpolate(self, *args, **kwargs): | ||
""" | ||
Compute the interpolation operation of interest. | ||
def _build_callable(self, output: Function | Cofunction | MatrixBase | None = None) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output
-> tensor
for consistency
|
||
@PETSc.Log.EventDecorator() | ||
def interpolate(expr, V, subset=None, access=None, allow_missing_dofs=False, default_missing_val=None, matfree=True): | ||
def interpolate(expr: Expr, V: WithGeometry | ufl.BaseForm, **kwargs) -> Interpolate: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def interpolate(expr: Expr, V: WithGeometry | ufl.BaseForm, **kwargs) -> Interpolate: | |
def interpolate(expr: Expr, V: ufl.FunctionSpace | ufl.BaseForm, **kwargs) -> Interpolate: |
else: | ||
return self._interpolate(*cofunctions, output=tensor, adjoint=needs_adjoint, | ||
default_missing_val=default_missing_val) | ||
assert isinstance(tensor, Function | Cofunction | None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the 0-form interpolate we should also allow Constant
here, it also supports assign
.
Simplifies interpolation code and introduces new features. Currently includes #4582. So far:
InterpolateOptions
dataclass. We get type hinting, better IDE support, single source of truth for these options.__new__
method and dispatch instead with aget_interpolator
function.