This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Setting solver parameters

0 votes

I would like to define my problem as follows:
...
problem = NonlinearVariationalProblem (F, w, bcs=bcs)
solver = NonlinearVariationalSolver(problem)
solver.parameters["linear_solver"] = "gmres"
...

I get the error:
KeyError: "'linear_solver' is not a parameter"

Can please someone help me with this problem?

asked Jun 17, 2015 by meipaff FEniCS Novice (320 points)

1 Answer

+1 vote

Try solver.parameters["nonlinear_solver"]

answered Jun 17, 2015 by chris_richardson FEniCS Expert (31,740 points)

I would like to set the linear solver inside the nonlinear solver, and I don't know the syntax.
parameters["nonlinear_solver"] is correct syntax, but I cannot set
parameters["nonlinear_solver"] = "gmres"
because GMRES is a linear solver?
How do I set the linear solver?

Take a look at the contact-vi-snes demo. It should be something like, e.g.

solver.parameters["newton_solver"]["linear_solver"] = "gmres"

Thank you very much, that is what I was looking for.

...