Repository navigation
Interpolate - #515
Interpolate#515schnellerhase wants to merge 5 commits into
Conversation
| 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 |
There was a problem hiding this comment.
What does this mean for the adjoint, i.e. Interpolate(Argument, Cofunction)?
| 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))): |
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Is this needed to enable derivative(interpolate(u, V1)*dx, u)? Should this be the default?
|
|
||
|
|
||
| def apply_derivatives(expression): | ||
| def apply_derivatives(expression, differentiate_through_operators: bool = False): |
There was a problem hiding this comment.
I don't understand. Is False going to be ignoring what's inside a BaseFormOperator? Why is it the default? I think preserve_types in #451 might be a related mechanism.
| if isinstance(do, Zero): | ||
| return Zero(g.ufl_shape) | ||
| return apply_grads(do) | ||
| self.pending_operations += (o,) |
There was a problem hiding this comment.
this pending_operations nonsense is removed in #544
Supporting FEniCS/ffcx#881.