Skip to content

Commit 1d9a838

Browse files
committed
Defensively hold references to matrices
1 parent 058c570 commit 1d9a838

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

firedrake/adjoint/transformed_functional.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def space(self):
3838
def pc(self):
3939
import petsc4py.PETSc as PETSc
4040

41-
pc = self._pc
4241
if self._pc is None:
4342
M = fd.assemble(fd.inner(fd.TrialFunction(self.space), fd.TestFunction(self.space)) * fd.dx,
4443
mat_type="aij")
@@ -49,8 +48,11 @@ def pc(self):
4948
pc.setFactorSolverType(PETSc.Mat.SolverType.PETSC)
5049
pc.setOperators(M_local)
5150
pc.setUp()
52-
if self._constant_jacobian:
53-
self._pc = pc
51+
52+
if self._constant_jacobian:
53+
self._pc = M, M_local, pc
54+
else:
55+
_, _, pc = self._pc
5456

5557
return pc
5658

0 commit comments

Comments
 (0)