[petsc-users] Composite shell preconditiner

Barry Smith bsmith at mcs.anl.gov
Fri Aug 17 15:34:06 CDT 2012


On Aug 17, 2012, at 8:54 AM, Alexander Grayver <agrayver at gfz-potsdam.de> wrote:

> On 17.08.2012 15:45, Jed Brown wrote:
>> 
>> What I would like to do is very simple: every N iterations I want to take current solution vector x_i from KSP and calculate:
>> x_i = x_i + c,
>> where c is a correction vector.
>> 
>> How do you want to compute c?
> 
> I was planning to do it inside ShellPCApply. 
> The correction itself is calculated as a solution of Poisson equation with rhs being divergence of current density and current density is calculated based on x_i


     A preconditioner step can only be written in the form      c  =  B(b  - A x_i)     where B is any linear operator and b is the right hand side and A is the original operator.  So if your calculation of c of this form (note that you need not form B explicitly as a sparse matrix but it must be some linear operator. From you description above "with rhs being divergence of current density and current density is calculated based on x_i" I suspect it cannot be written in this form.   

    The way to write this is 

     KSPSetInitialGuessNonzero(kspmain);
     KSPSetTolerance(kspmain,    set number of inner iterations you wish to use before the "filtering step"
      for j=1,….. number outer iterations
               KSPSolve(kspmain,b,x)   
               compute    rhs via "rhs being divergence of current density and current density is calculated based on x_i"
               KSPSolve(ksppoisson,rhs,c)
              x = x + c
      endfor

    I don't think you can, or want to "munge" it into some kind of single complicated KSPSolve 
     

> This trick is often applied to suppress spurious solution arising during solution of Maxwell equations and it works very well. 
> 
>> For a general KSP, this is not allowed because the preconditioner must be constant. (You can do it anyway by checking the iteration number in your PCShell, but it won't converge.) You can play these games with a flexible method like FGMRES, for which you can also do an inner-outer, e.g.
>> 
>> -ksp_type fgmres -pc_type composite -pc_composite_type multiplicative -pc_composite_pcs ksp,shell -sub_0_ksp_ksp_type tfqmr -sub_0_ksp_ksp_max_it 10 -sub_0_ksp_pc_type ilu
> 
> Looks a bit tricky. The number of fgmres iterations then defines number of the cycles correction will be applied, doesn't it?
> 
> 
> -- 
> Regards,
> Alexander
> 



More information about the petsc-users mailing list