Skip to content

Interpolate - #515

Draft
schnellerhase wants to merge 4 commits into
mainfrom
schnellerhase/interpolate
Draft

schnellerhase wants to merge 4 commits into
mainfrom
schnellerhase/interpolate

Conversation

@schnellerhase

@schnellerhase schnellerhase commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Supporting FEniCS/ffcx#881.

Comment thread ufl/core/interpolate.py
Comment on lines +161 to +168
def target_space(self) -> AbstractFunctionSpace:
"""Return the function space that the expression is interpolated into.

Unlike `ufl_function_space` this does not depend on the argument
numbering, so it stays correct when the interpolated expression holds an
argument of the enclosing form.
"""
return self._function_space

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does this mean for the adjoint, i.e. Interpolate(Argument, Cofunction)?

Comment thread ufl/core/interpolate.py
raise ValueError("Same argument numbers in first and second operands to interpolate.")
if expr_arg_numbers | dual_arg_numbers not in [set(), {0}, {0, 1}]:
argument_numbers = expr_arg_numbers | dual_arg_numbers
if argument_numbers and argument_numbers != set(range(len(argument_numbers))):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we need this check? I think the main purpose is to ensure unique argument numbers, but we should not be constraining the arguments to always start from 0 and be contiguous.

Comment thread ufl/core/interpolate.py
n = 1 if expr_arg_numbers == {0} else 0
# Take the lowest free number, so that an expression linear in
# several arguments stays representable.
n = min(set(range(len(expr_arg_numbers) + 1)) - expr_arg_numbers)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should add tests for this

of its target space, and the expression it interpolates is evaluated
separately.
"""
return expr._ufl_is_terminal_ or isinstance(expr, Interpolate)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this pattern repeats through other files. I don't agree with the name. In which sense are terminals "modifiable"?

operator is linear in it, instead of recording the derivative as an
action to be assembled separately. This composes to higher
derivatives and keeps the result an ordinary form, which a form
compiler that evaluates the operator cell-locally needs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this needed to enable derivative(interpolate(u, V1)*dx, u)? Should this be the default?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants