Skip to content

Commit

Permalink
Fix BaseFormOperator.ufl_function_space
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Feb 19, 2025
1 parent 31e5be7 commit 3af144b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ufl/core/base_form_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from collections import OrderedDict

from ufl.argument import Argument, Coargument
from ufl.coefficient import BaseCoefficient
from ufl.constantvalue import as_ufl
from ufl.core.operator import Operator
from ufl.core.ufl_type import ufl_type
Expand Down Expand Up @@ -134,20 +135,19 @@ def count(self):
def ufl_shape(self):
"""Return the UFL shape of the coefficient.produced by the operator."""
arg, *_ = self.argument_slots()
if isinstance(arg, BaseForm):
if not isinstance(arg, BaseCoefficient) and isinstance(arg, (BaseForm, Coargument)):
arg, *_ = arg.arguments()
return arg._ufl_shape

def ufl_function_space(self):
"""Return the function space associated to the operator.
I.e. return the dual of the base form operator's Coargument.
I.e. return the dual of the base form operator's Coargument space.
"""
arg, *_ = self.argument_slots()
if isinstance(arg, BaseForm):
if not isinstance(arg, BaseCoefficient) and isinstance(arg, (BaseForm, Coargument)):
arg, *_ = arg.arguments()
return arg._ufl_function_space
return arg._ufl_function_space.dual()
return arg._ufl_function_space

def _ufl_expr_reconstruct_(
self, *operands, function_space=None, derivatives=None, argument_slots=None
Expand Down

0 comments on commit 3af144b

Please sign in to comment.