[petsc-users] KSPGMRES preconditioned with a MATSHELL

Barry Smith bsmith at mcs.anl.gov
Fri Oct 14 10:16:22 CDT 2011


  You never set the PC or PCType for your inner KSP hence it is trying to use the default of ILU. If pA is a MATSHELL then it cannot use ILU. Do you plan to use a preconditioner in the inner solver or PCNONE?

   Barry

On Oct 14, 2011, at 6:23 AM, Thomas Leissing wrote:

> Matt,
> 
> 	Could you send the error message?
> 
> Here is the relevant part of the code:
> 
> Variables: 
> solver is my outer solver (KSPFGMRES)
> A is the matrix associated with the outer solver (MATSHELL)
> b is my RHS vector
> x is my solution vector
> precond is the outer solver preconditioner (PCKSP)
> pcSolver is the inner solver (KSPGMRES)
> pA is the matrix associated with the inner solver (preconditioner,
> MATSHELL too)
> 
> 
> [...]
> call KSPCreate(PETSC_COMM_WORLD, solver, pCode)
> call KSPGetPC(solver, precond, pCode)
> call PCSetType(precond, PCKSP, pCode)
> call PCKSPGetKSP(precond, pcSolver, pCode)
> call KSPCreate(PETSC_COMM_WORLD, pcSolver, pCode)
> call KSPSetType(pcSolver, KSPGMRES, pCode)
> call KSPSetOperators(pcSolver, pA, pA, SAME_NONZERO_PATTERN, pcode)
> call KSPSetOperators(solver, A, pA, SAME_NONZERO_PATTERN, pcode)
> call KSPSetType(solver, KSPFGMRES, pCode)
> call KSPSolve(solver, b, x, pCode)
> [...]
> 
> and the error message is:
> 
> [0]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [0]PETSC ERROR: No support for this operation for this object type!
> [0]PETSC ERROR: Matrix format shell does not have a built-in PETSc ILU!
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 3, Fri Sep 30
> 10:28:33 CDT 2011 
> 
> 
> 	What we normally do is explicitly construct the low-order matrix. Then
> you can just pass it as the second Mat argument to
> KSPSetOperators(). The PC is built using that Mat, instead of the system
> Mat which is a MATSHELL.
> 
> Yes, but in my case, and if I understood what you meant, I cannot do
> that since my PC Mat is necessarily a MATSHELL...
> 
> 
> Thanks, 
> Thomas
> 
> 
> 
> -------- Message initial --------
> De: Matthew Knepley <knepley at gmail.com>
> Reply-to: PETSc users list <petsc-users at mcs.anl.gov>
> À: PETSc users list <petsc-users at mcs.anl.gov>
> Sujet: Re: [petsc-users] KSPGMRES preconditioned with a MATSHELL
> Date: Fri, 14 Oct 2011 05:26:44 -0500
> 
> On Fri, Oct 14, 2011 at 2:42 AM, Thomas Leissing
> <thomas.leissing at cstb.fr> wrote:
>        Dear all,
> 
>        I need to solve a system of equation Ax = b in which A is a
>        MatShell object for which I defined a matrix-vector
>        multiplication routine with MatShellSetOperation. Let's call
>        this routine MyMatMult. The MyMatMult routine gives me an
>        approximate matrix vector product, and I'm able to tune the
>        parameters of MyMatMult so that I can choose a trade-off between
>        calculation time and accuracy of the product. I successfully
>        solved this problem with a KSPGMRES solver.
>        So far so good...
> 
>        Now I'd like to precondition the system to accelerate the
>        solving stage. To do this I'd like to use a lower-order (less
>        accurate but faster) solution of Ax=b.
> 
>        I tried to do this with a PCKSP type preconditioner, but it
>        doesn't seem to accept MatShell objects as preconditioning
>        matrix.
> 
> 
> 
> Could you send the error message?
> 
>        I also tried to use a PCSHELL preconditioner for which the
>        PCApply routine consists in solving the lower order Ax=b system.
> 
>        I didn't manage to get this working properly: the outer solver
>        doesn't converge to the expected rate. Indeed if I use for the
>        inner loop the same accuracy than for the outer loop, the outer
>        loop should converge in one iteration, which is not the case...
> 
>        Is there another way of doing this ?
> 
> 
> 
> What we normally do is explicitly construct the low-order matrix. Then
> you can just pass it as the second Mat argument to
> KSPSetOperators(). The PC is built using that Mat, instead of the system
> Mat which is a MATSHELL.
> 
> 
>  Thanks,
> 
> 
>      Matt
> 
>        Any hint ?
> 
>        Thanks for your help,
>        Thomas Leissing
> 
> 
> 
> 
> -- 
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which
> their experiments lead.
> -- Norbert Wiener
> 



More information about the petsc-users mailing list