From 5a237a2ed964abcf1c9658dcb3df65031a93d4fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9cile?= Date: Tue, 3 Dec 2024 11:35:07 +0100 Subject: [PATCH] Fix lhs / rhs : No need to extract blocks if parts=() --- ufl/algorithms/formtransformations.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ufl/algorithms/formtransformations.py b/ufl/algorithms/formtransformations.py index 229114327..3d38f5ded 100644 --- a/ufl/algorithms/formtransformations.py +++ b/ufl/algorithms/formtransformations.py @@ -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: @@ -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