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

How to change the krylov_solver parameters

0 votes

Hi all,
i'm trying to solve a linear problem (time-dependant) using PETSc as linear_algebra_backend and the the classes LinearVariationalProblem and LinearVariationalSolver in this manner

LinearVariationalProblem  Problem1(a, L, u, bcs);
LinearVariationalSolver  Solver1(Problem1);
Solver1.parameters["linear_solver"]  = "gmres";

The linear system (by default) is solved using PETSc Krylov solver.

I would like to know, in particular, how to change the absolute and relative tolerance of krylov solver, or in more global sense, how to change the parameters of the krylov solver.

Many thanks in advance!

asked Dec 19, 2015 by hernan_mella FEniCS Expert (19,460 points)
edited Jan 25, 2016 by hernan_mella

I have tried to change those parameters adding the next lines to my code,

Solver1.parameters["krylov_solver"]["relative_tolerance"] = 1E-14;
Solver1.parameters["krylov_solver"]["absolute_tolerance"] = 1E-25;

but i'm getting the next error because of them

error: conversion from ‘dolfin::Parameter’ to ‘long int’ is ambiguous

Maybe try as 2 lines:

Parameters& p = Solver1.parameters["krylov_solver"];
p["relative_tolerance"]=1e-12;

You can also try :

help(dolfin.PETScKrylovSolver)

thanks for the answers but i can't change the parameters using yours seggestions. When i use

Parameters& p = Solver1.parameters["krylov_solver"];
p["relative_tolerance"]=1e-12;

i get the next error:

error: invalid initialization of reference of type ‘dolfin::Parameters&’ from expression of type ‘dolfin::Parameter’
...