Crash when specifying "linear_solver = iterative"
Bug #1172680 reported by
Marie Rognes
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dolfin-adjoint |
Confirmed
|
Low
|
Marie Rognes |
Bug Description
The adjoint computation below fails. If "linear_solver" is "gmres", "cg" or "lu" all is well.
from dolfin import *
from dolfin_adjoint import *
mesh = UnitSquareMesh(2, 2)
V = FunctionSpace(mesh, "CG", 1)
f = Constant(1.0)
u = project(f, V)
v = TestFunction(V)
F = u*u*v*dx - f*v*dx
info_green("Running forward")
pde = NonlinearVariat
solver = NonlinearVariat
solver.
solver.solve()
J = Functional(
info_green(
z = compute_adjoint(J)
for x in z:
print x
To post a comment you must log in.
I'm going to pin this one on dolfin. Because there is no identity representation in UFL, we have to use KrylovSolver/ LUSolver even if solve(a == L), solve(F == 0), or the OO interface is used in the forward model. This is caused by the inconsistent treatment of "iterative" across the LA interfaces in dolfin.
There are at least three opinions about what "iterative" means in dolfin. In dolfin/ fem/LinearVaria tionalSolver. cpp:
if (solver_type == "iterative" || solver_type == "krylov")
{
// Adjust iterative solver type
if (symmetric)
solver_type = "cg";
else
solver_type = "gmres";
}
In dolfin/ la/LinearSolver .cpp:
else if (method == "iterative")
method = "gmres";
(no mention of "cg")
and dolfin/ la/KrylovSolver .cpp crashes if you pass it method="iterative" (which is what is happening here):
File "/home/ pef/src/ dolfin- adjoint/ dolfin_ adjoint/ adjlinalg. py", line 399, in wrap_solve KrylovSolver( method, pc) ------- ------- ------- ------- ------- ------- ------- ------- ------- --- solver_ methods( ) to list available Krylov methods.
solver = dolfin.
*** -------
*** Error: Unable to solve linear system using Krylov iteration.
*** Reason: Unknown Krylov method "iterative". Use list_krylov_
I could patch over this in dolfin-adjoint, but the Right Thing To Do is fix it in dolfin (preferably by taking the LinearVariation alSolver logic and porting it to LinearSolver, KrylovSolver and anywhere else it's needed, like the backend-specific objects).