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

Accessing Petsc solver submethods in FEniCS python interface

+4 votes

Hello. I am using Dolfin 1.2.0 installed through Dorsal.

We are looking to better configure our solver for parallel computing using MPI. Currently we have set:

problem = LinearVariationalProblem(a, L, u, bcs)
solver = LinearVariationalSolver(problem)
solver.parameters['linear_solver'] = 'gmres'
solver.parameters['preconditioner'] = 'additive_schwarz'

which returns the report:

PETSc Krylov solver (gmres, asm) converged in 2 iterations.
PETSc Krylov solver preconditioner (asm) submethods: (preonly, ilu)

This solver works great in serial, but the method fails to converge under the same parameters as we increase the number of processes. Is it possible to change the PETSc Krylov preconditioner parameter 'preonly'?

Thank you,
Brian

asked Aug 19, 2013 by b_brennan FEniCS Novice (220 points)

I should add that the solver converges quickly in serial (2 iterations in the posted example) but fails to converge in 3000 iterations when running in parallel.

2 Answers

+2 votes
 
Best answer

Hi Brian, I can't say I've had experience with parallel computing but I managed to change some of the petsc parameters directly by adding the line:

from dolfin import *
parameters.parse()

in my file, and then launching the program by running:

python 2Component_snes.py --petsc.ksp_type preonly --petsc.pc_type lu --petsc.snes_ls_alpha 1e-2

With this I was able to change some of the petsc parameters directly although it doesn't work for all of them. Just add '--petsc.' to a petsc word given in the manual.

answered Aug 20, 2013 by mwelland FEniCS User (8,410 points)
selected Aug 20, 2013 by b_brennan

This is exactly what I needed. Thank you!

+4 votes

In addition to the answer from mwelland, the development version of DOLFIN now has a wrapper for PETSc options. You can now do, for example,

PETScOptions::set("pc_type", "ml");  

from C++, and

PETScOptions.set("pc_type", "ml")  

from Python.

answered Aug 28, 2013 by Garth N. Wells FEniCS Expert (35,930 points)
...