|
1 | 1 | """Apply derivatives algorithm which computes the derivatives of a form of expression.""" |
2 | 2 |
|
3 | | -# Copyright (C) 2008-2016 Martin Sandve Alnæs |
| 3 | +# Copyright (C) 2008-2026 Martin Sandve Alnæs |
4 | 4 | # |
5 | 5 | # This file is part of UFL (https://www.fenicsproject.org) |
6 | 6 | # |
|
17 | 17 | from ufl.action import Action |
18 | 18 | from ufl.algorithms.analysis import extract_arguments, extract_coefficients |
19 | 19 | from ufl.algorithms.map_integrands import map_integrands |
| 20 | +from ufl.algorithms.remove_complex_nodes import remove_complex_nodes |
20 | 21 | from ufl.algorithms.replace_derivative_nodes import replace_derivative_nodes |
21 | 22 | from ufl.argument import Argument, BaseArgument, Coargument |
22 | 23 | from ufl.averaging import CellAvg, FacetAvg |
@@ -2204,10 +2205,13 @@ def _(self, o: Expr) -> Expr: |
2204 | 2205 | # d (grad_X(x))/d x => grad_X(Argument(x.function_space()) |
2205 | 2206 | for w, v in zip(self._w, self._v): |
2206 | 2207 | if extract_unique_domain(o) == extract_unique_domain(w) and isinstance( |
2207 | | - v.ufl_operands[0], # type: ignore |
| 2208 | + remove_complex_nodes(v).ufl_operands[0], # type: ignore |
2208 | 2209 | FormArgument, |
2209 | 2210 | ): |
2210 | | - return ReferenceGrad(v) |
| 2211 | + if isinstance(v, Conj): |
| 2212 | + return Conj(ReferenceGrad(remove_complex_nodes(v))) |
| 2213 | + else: |
| 2214 | + return ReferenceGrad(v) |
2211 | 2215 | return self.independent_terminal(o) |
2212 | 2216 |
|
2213 | 2217 |
|
|
0 commit comments