Open
Description
Describe the bug
If a linear solver failure is encountered and a firedrake.exceptions.ConvergenceError
is raised, the solution value is unchanged.
Steps to Reproduce
from firedrake import *
import petsc4py.PETSc as PETSc
mesh = UnitIntervalMesh(10)
space = FunctionSpace(mesh, "CG", 1)
test, trial = TestFunction(space), TrialFunction(space)
solver = LinearSolver(assemble(inner(trial, test) * dx),
solver_parameters={"ksp_type": "cg",
"pc_type": "none",
"ksp_max_it": 1,
"ksp_atol": 1.0e-2})
b = assemble(inner(Constant(1), test) * dx)
u = Function(space, name="u")
u.assign(-1)
try:
solver.solve(u, b)
except firedrake.exceptions.ConvergenceError:
assert solver.ksp.getConvergedReason() == PETSc.KSP.ConvergedReason.DIVERGED_MAX_IT
print("ConvergenceError")
print(u.dat.data_ro)
displays
ConvergenceError
[-1. -1. -1. -1. -1. -1. -1. -1. -1. -1. -1.]
Expected behavior
The solution should be updated to the state obtained from the linear solve -- in the above after 1 CG iteration.
Additional Info
I think the behaviour changed in #4012