Skip to content

Commit 9eabd47

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

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

firedrake/adjoint/transformed_functional.py

Lines changed: 4 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,10 @@ 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+
if self._constant_jacobian:
52+
self._pc = M, M_local, pc
53+
else:
54+
_, _, pc = self._pc
5455

5556
return pc
5657

0 commit comments

Comments
 (0)