Skip to content

BUG: LinearSolver always uses a non-zero initial guess #4142

@jrmaddison

Description

@jrmaddison

Describe the bug
The ksp_initial_guess_nonzero parameter is ignored by LinearSolver.

Steps to Reproduce

from firedrake import *

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": "preonly",
                                         "pc_type": "jacobi",
                                         "ksp_max_it": 1,
                                         "ksp_initial_guess_nonzero": False})
b = assemble(inner(Constant(1), test) * dx)

u = Function(space, name="u")

u.assign(0)
solver.solve(u, b)
print(u.dat.data_ro)

u.assign(1)
solver.solve(u, b)
print(u.dat.data_ro)

displays

[1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]

Expected behavior
The non-zero initial value should be ignored in the second case, the linear solver should use a zero initial guess, and the results of the two solves should be the same.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions