FEniCS / FEniCS/ufl

Lazy Replace

Open
#171 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
150
Forks
79
Avg merge
1d 16h
Merged PRs (30d)
10

Description

It would be very useful to have a lazy version of replace, which only gets applied when the expression tree is traversed.

**Example:**
Say I have an expression `expr` which contains a `ufl.ConstantValue` named `c` as a parameter. If I want to have the derivative of `expr` wrt. `c` I can do so by creating a `ufl.Coefficient` named `f` and doing:
```
ufl.replace(expr, {c: f})
ufl.derivative(expr, f)
```
However this traverses the expression tree twice.

(This issue would also be fixed by implementing derivative wrt. `ufl.ConstantValue`, but there are more examples where this is desirable). This came up as a discussion point when reviewing a recent Firedrake PR. Tagging @dham .

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.