Skip to content

Commit 4ab9490

Browse files
committed
Split EquationBCSplit
1 parent 8952e3f commit 4ab9490

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

firedrake/formmanipulation.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def cofunction(self, o):
160160
return Cofunction(W, val=MixedDat(o.dat[i] for i in indices))
161161

162162
def matrix(self, o):
163-
from firedrake.bcs import DirichletBC
163+
from firedrake.bcs import DirichletBC, EquationBCSplit
164164
ises = []
165165
args = []
166166
for a in o.arguments():
@@ -180,6 +180,7 @@ def matrix(self, o):
180180
args.append(asplit)
181181

182182
submat = o.petscmat.createSubMatrix(*ises)
183+
183184
bcs = []
184185
spaces = [a.function_space() for a in o.arguments()]
185186
for bc in o.bcs:
@@ -191,11 +192,14 @@ def matrix(self, o):
191192
V = args[number].function_space()
192193
field = self.blocks[number]
193194
if isinstance(bc, DirichletBC):
194-
sub_bc = bc.reconstruct(field=field, V=V, g=bc.function_arg)
195-
else:
196-
raise NotImplementedError(f"Extracting matrix subblocks not supported with {type(bc).__name__}. Please get in touch if you need this.")
197-
if sub_bc is not None:
198-
bcs.append(sub_bc)
195+
bc_temp = bc.reconstruct(field=field, V=V, g=bc.function_arg, use_split=True)
196+
elif isinstance(bc, EquationBCSplit):
197+
row_field = self.blocks[0]
198+
col_field = self.blocks[1]
199+
bc_temp = bc.reconstruct(field=field, V=V, row_field=row_field, col_field=col_field, use_split=True)
200+
if bc_temp is not None:
201+
bcs.append(bc_temp)
202+
199203
return AssembledMatrix(tuple(args), tuple(bcs), submat)
200204

201205
def zero_base_form(self, o):

firedrake/solving_utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,6 @@ def form_jacobian(snes, X, J, P):
523523
ctx.set_nullspace(ctx._nullspace_T, ises, transpose=True, near=False)
524524
ctx.set_nullspace(ctx._near_nullspace, ises, transpose=False, near=True)
525525

526-
# Bump petsc matrix state of each split by assembling them.
527-
# Ensures that if the matrix changed, the preconditioner is
528-
# updated if necessary.
529-
for fields, splits in ctx._splits.items():
530-
for subctx in splits:
531-
subctx._jac.assemble()
532-
if subctx.Jp is not None:
533-
subctx._pjac.assemble()
534-
535526
@staticmethod
536527
def compute_operators(ksp, J, P):
537528
r"""Form the Jacobian for this problem

0 commit comments

Comments
 (0)