Skip to content

Commit

Permalink
Fix lhs / rhs : No need to extract blocks if parts=()
Browse files Browse the repository at this point in the history
  • Loading branch information
cdaversin committed Dec 3, 2024
1 parent 934249d commit 5a237a2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ufl/algorithms/formtransformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ def compute_form_lhs(form):
a = u*v*dx + f*v*dx
a = lhs(a) -> u*v*dx
"""
parts = tuple(sorted(set(part for a in form.arguments() if (part := a.part()) is not None)))
if parts == ():
return compute_form_with_arity(form, 2)

form_blocks = extract_blocks(form, arity=2)
lhs = 0
for bi in form_blocks:
Expand All @@ -375,10 +379,15 @@ def compute_form_rhs(form):
a = u*v*dx + f*v*dx
L = rhs(a) -> -f*v*dx
"""
parts = tuple(sorted(set(part for a in form.arguments() if (part := a.part()) is not None)))
if parts == ():
return -compute_form_with_arity(form, 1)

form_blocks = extract_blocks(form, arity=1)
rhs = 0
for bi in form_blocks:
rhs += compute_form_with_arity(bi, 1)
if bi is not None:
rhs += compute_form_with_arity(bi, 1)
return -rhs


Expand Down

0 comments on commit 5a237a2

Please sign in to comment.