@@ -133,7 +133,22 @@ def dm(self):
133
133
134
134
@staticmethod
135
135
def compute_bc_lifting (J , u , L = 0 ):
136
- """Return the action of the bilinear form J (without bcs) on a Function u."""
136
+ """Compute the residual after lifting DirichletBCs.
137
+
138
+ Parameters
139
+ ----------
140
+ J : ufl.BaseForm or slate.TensorBase
141
+ The Jacobian bilinear form.
142
+ u : firedrake.Function
143
+ The Function on which DirichletBCs are applied.
144
+ L : ufl.BaseForm or slate.TensorBase
145
+ The unlifted residual linear form.
146
+
147
+ Return
148
+ ------
149
+ F : ufl.BaseForm or slate.TensorBase
150
+ The residual J*u-L after lifting DirichletBCs.
151
+ """
137
152
if isinstance (J , MatrixBase ) and J .has_bcs :
138
153
# Extract the full form without bcs
139
154
if not isinstance (J .a , (ufl .BaseForm , slate .slate .TensorBase )):
@@ -399,14 +414,12 @@ def __init__(self, a, L, u, bcs=None, aP=None,
399
414
"""
400
415
# In the linear case, the Jacobian is the equation LHS (J=a).
401
416
# Jacobian is checked in superclass, but let's check L here.
402
- if not isinstance (L , (ufl .BaseForm , slate .slate .TensorBase )) and L == 0 :
403
- F = self .compute_bc_lifting (a , u )
404
- else :
405
- if not isinstance (L , (ufl .BaseForm , slate .slate .TensorBase )):
406
- raise TypeError ("Provided RHS is a '%s', not a Form or Slate Tensor" % type (L ).__name__ )
417
+ if isinstance (L , (ufl .BaseForm , slate .slate .TensorBase )):
407
418
if len (L .arguments ()) != 1 and not L .empty ():
408
419
raise ValueError ("Provided RHS is not a linear form" )
409
- F = self .compute_bc_lifting (a , u , L = L )
420
+ elif L != 0 :
421
+ raise TypeError (f"Provided RHS is a '{ type (L ).__name__ } ', not a Form or Slate Tensor" )
422
+ F = self .compute_bc_lifting (a , u , L = L )
410
423
411
424
super (LinearVariationalProblem , self ).__init__ (F , u , bcs = bcs , J = a , Jp = aP ,
412
425
form_compiler_parameters = form_compiler_parameters ,
0 commit comments