Skip to content

Commit

Permalink
Fix action space check
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Dec 12, 2024
1 parent 08351d0 commit 4aafdc5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ufl/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ufl.core.base_form_operator import BaseFormOperator
from ufl.core.ufl_type import ufl_type
from ufl.differentiation import CoefficientDerivative
from ufl.duals import is_dual, is_primal
from ufl.form import BaseForm, Form, FormSum, ZeroBaseForm
from ufl.matrix import Matrix

Expand Down Expand Up @@ -159,6 +160,10 @@ def __hash__(self):

def _check_function_spaces(left, right):
"""Check if the function spaces of left and right match."""
if is_primal(left) or is_dual(right):
# We can always assume action(dual, primal) since
# action(left, right) == action(right, left)
left, right = right, left
if isinstance(right, CoefficientDerivative):
# Action differentiation pushes differentiation through
# right as a consequence of Leibniz formula.
Expand Down

0 comments on commit 4aafdc5

Please sign in to comment.