[petsc-dev] How to precondition a direct solve ?

Barry Smith bsmith at mcs.anl.gov
Fri Aug 25 16:21:35 CDT 2017


  By "precondition" a direct solver I assume you mean "scale the linear system so that the direct solver produces a more accurate solution"?

1) For most matrices this is not necessary

2) Some of the direct solvers do some of this internally so no reason for you to do this

3) Instead of doing a scaling you can just use "iterative refinement" where you run with, for example GMRES, instead of PREONLY and it does additional iterations, if needed to get a more accurate solution

4) If you really want to do it then yes you need to do the product yourself, but first try 3 since it is much cheaper and tells you if it is really needed.


  Barry





> On Aug 25, 2017, at 10:51 AM, Franck Houssen <franck.houssen at inria.fr> wrote:
> 
> How to precondition a direct solve ?
> 
> My understanding is that to solve AX=B with an iterative method (say GMRES + jacobi), I need to follow these steps:
> KSPSetType(ksp, KSPGMRES);
> PCSetType(pc, PCJACOBI);
> KSPSolve(ksp, B);
> 
> Also, to solve AX=B with a direct method, my understanding is that I need to follow these steps:
> KSPSetType(ksp, KSPPREONLY);
> PCSetType(pc, PCLU);
> PCFactorSetMatSolverPackage(pc, "mumps"); // To choose the direct solver
> KSPSolve(ksp, B);
> 
> OK, so far so good.
> 
> Now what if I want to solve a preconditioned system (say MAX=MB that is AX=B "modified" by M) with a direct method : what is the "PETSc way" to do that ? What would be the "steps to follow" ?
> The short answer would be : replace A and B by MA and MB. But then, I'll have to compute M by myself which may not be an easy thing (if not a jacobi - ilu, sor, mg, ....). I wondered if there is a more natural way to do that with PETSc.
> 
> My understanding is that KSPPREONLY is a "trick" to mimic a direct solve within an iterative solve. Is there such a trick to precondition a direct solve ?
> 
> Franck



More information about the petsc-dev mailing list