Skip to content

Commit 1b5c219

Browse files
committed
Fix BaseFormOperator.ufl_function_space
1 parent e491e30 commit 1b5c219

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

test/test_interpolate.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ def test_symbolic_adjoint(V1, V2):
7575
V2_dual = V2.dual()
7676

7777
u = Argument(V1, 1)
78-
vstar = Cofunction(V2_dual)
79-
Iu = Interpolate(u, vstar)
78+
form = inner(1, Argument(V2, 0)) * dx
79+
cofun = Cofunction(V2_dual)
8080

81-
assert Iu.ufl_function_space() == V2_dual
82-
assert Iu.argument_slots() == (vstar, u)
83-
assert Iu.arguments() == (u,)
84-
assert Iu.ufl_operands == (u,)
81+
for vstar in (form, cofun):
82+
Iu = Interpolate(u, vstar)
83+
84+
assert Iu.ufl_function_space() == V2_dual
85+
assert Iu.argument_slots() == (vstar, u)
86+
assert Iu.arguments() == (u,)
87+
assert Iu.ufl_operands == (u,)
8588

8689

8790
def test_action_adjoint(V1, V2):

ufl/core/base_form_operator.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from numbers import Number
1818

1919
from ufl.argument import Argument, Coargument
20-
from ufl.coefficient import BaseCoefficient
2120
from ufl.constantvalue import as_ufl
2221
from ufl.core.operator import Operator
2322
from ufl.core.ufl_type import ufl_type
@@ -135,9 +134,9 @@ def count(self):
135134

136135
@property
137136
def ufl_shape(self):
138-
"""Return the UFL shape of the coefficient.produced by the operator."""
137+
"""Return the UFL shape of the coefficient produced by the operator."""
139138
arg, *_ = self.argument_slots()
140-
if not isinstance(arg, BaseCoefficient) and isinstance(arg, (BaseForm, Coargument)):
139+
if not isinstance(arg, Coargument):
141140
arg, *_ = arg.arguments()
142141
return arg._ufl_shape
143142

@@ -147,9 +146,9 @@ def ufl_function_space(self):
147146
I.e. return the dual of the base form operator's Coargument space.
148147
"""
149148
arg, *_ = self.argument_slots()
150-
if not isinstance(arg, BaseCoefficient) and isinstance(arg, (BaseForm, Coargument)):
149+
if not isinstance(arg, Coargument):
151150
arg, *_ = arg.arguments()
152-
return arg.ufl_function_space()
151+
return arg.ufl_function_space().dual()
153152

154153
def _ufl_expr_reconstruct_(
155154
self, *operands, function_space=None, derivatives=None, argument_slots=None

0 commit comments

Comments
 (0)