Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jrmaddison opened this issue Mar 21, 2025 · 0 comments
Open

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

jrmaddison opened this issue Mar 21, 2025 · 0 comments
Assignees
Labels

Comments

@jrmaddison
Copy link
Contributor

jrmaddison commented Mar 21, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants