Skip to content

Commit c8f2b37

Browse files
committed
update expr arg check
1 parent 99aa9e5 commit c8f2b37

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

firedrake/interpolation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import finat.ufl
1313
from ufl.algorithms import extract_arguments, extract_coefficients
1414
from ufl.domain import as_domain, extract_unique_domain
15+
from ufl.duals import is_dual
1516

1617
from pyop2 import op2
1718
from pyop2.caching import memory_and_disk_cache
@@ -96,8 +97,8 @@ def __init__(self, expr, V,
9697
expr = ufl.as_ufl(expr)
9798
if isinstance(V, functionspaceimpl.WithGeometry):
9899
# Need to create a Firedrake Argument so that it has a .function_space() method
99-
expr_args = extract_arguments(expr)
100-
is_adjoint = len(expr_args) and expr_args[0].number() == 0
100+
expr_arg_numbers = {arg.number() for arg in extract_arguments(expr) if not is_dual(arg)}
101+
is_adjoint = len(expr_arg_numbers) and expr_arg_numbers[0] == 0
101102
V = Argument(V.dual(), 1 if is_adjoint else 0)
102103

103104
target_shape = V.arguments()[0].function_space().value_shape

0 commit comments

Comments
 (0)