[petsc-users] user provided local preconditioner with additive schwarz preconditioner

Barry Smith bsmith at mcs.anl.gov
Thu Jun 30 18:09:40 CDT 2016


   I don't think we have an example that does exactly that.

   If you are working with KSP directly and not SNES here is how to proceed

   KSPGetPC(ksp,&pc);
   PCSetType(pc,PCASM);
   KSPSetOperators()
   KSPSetUp()                        <--- this must be called before the code below otherwise the subksps don't exist yet
   
   PetscInt n_local;
   KSP     *subksps;

   PCASMGetSubKSP(pc,&n_local,NULL,&subksps);
   for (i=0; i<n_local; i++) {
      PC subpc;

      KSPGetPC(subksps[i],&subpc);
      PCSetType(subpc,PCSHELL);
      PCShellSetApply(subpc,yourapplyfunction);
      anything else you need to set for your shell preconditioner here
   }
   KSPSetUpOnBlocks(ksp);

   KSPSolve();

   Now if you want to solve with a different right hand side or different entries in you matrix just call
   KSPSolve() again  you don't need to repeat the code above.

  Barry

 Note that any of PETSc's preconditioners can be used on the subdomains so normally you can just -sub_pc_type typeyouwant and you don't need to mess with shell preconditioners.



   


    
> On Jun 30, 2016, at 5:49 PM, Duan Zhaowen <dzw.pku at gmail.com> wrote:
> 
> Hi,
> 
> I was trying to define a shell preconditioner for local partition, and let it work with global additive schwarz preconditioner for parallel computing. Is any one can give an example on this kind of preconditioners combination. Thanks!
> 
> ZW



More information about the petsc-users mailing list