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

Is there a way to supply the action of a preconditioner on a vector for a krylov sover?

0 votes

If I have a way of computing $M^{-1} r$ where $M \approx A$ for a problem $Ax=b$, how would I go about applying the preconditioner in a krylov method for $Ax=b$ assuming that $M$ on it's own is not available. The set_operators method seems to do something other than what I'm looking for. I'm working in python, and I don't see an interface to the PETScUserPreconditioner class. What can I do?

asked Nov 18, 2015 by brk888 FEniCS Novice (990 points)

1 Answer

0 votes

If you can define your preconditoner in PETSc, you should be able to set it through petsc4py:

pc = <define preconditioner>
solver = PETScKrylovSolver()
ksp = solver.ksp()
pc = ksp.setPC(pc)
answered Nov 18, 2015 by Øyvind Evju FEniCS Expert (17,700 points)

Actually, my preconditioner is based on computing a domain decomposition solution that mimicks the application of $M^{-1} r$. I use FEniCS to assemble and solve subomain problems, so I don't think that I can define this operation in PETSc. I'm hoping that there is some way to just supply a function that evaluates $M^{-1} r$ give some vector $r$, where that function does a bunch of FEniCS 'stuff'.

The PETScKrylovSolver is simply an interface to PETSc, so your preconditioner would probably need to be compatible with PETSc. Have a look at the PETSc PCRegister, and if needed try to find the functionality in petsc4py.

FEniCS does not implement any iterative solvers, it's only an interface.

...