[petsc-users] PCDiagonalScale

Barry Smith bsmith at mcs.anl.gov
Wed Mar 2 12:57:38 CST 2011


On Mar 1, 2011, at 2:28 AM, Klaij, Christiaan wrote:

> Barry,
> 
> I do not want to use it for the reason given in the manual.
> 
> Instead I'm trying to use SIMPLE as a preconditioner for a colocated, cell-centered FV discretization of the incompressible Navier-Stokes equations. I'm using a matfree approach for the matrix and the (right) preconditioner. I would like to scale the system as D A M D^{-1} z = D b but I get the feeling that PCDiagonalScaleSet with GCR doesn't do anything.
> 
> How about Jed's comment:
> 
> "GCR also tolerates a variable preconditioner and it does not have such a check. I don't know if that means it can use diagonal scaling or just that someone forgot to check, but you could try it."

   KSPSolve_GCR() is not coded for using that extra diagonal scaling and does not check to see if you have requested it.  So, as you saw, if you turn it on it has no effect.

   I have added an error check in petsc-dev so it will tell you that it does not use it.  Thank you for letting us know about this bug.

   You may be able to add support for it.  The code is in src/ksp/ksp/impls/gcr/grc.c  Note that the current code has the lines

  ierr = PCApply( pc, r, s ); CHKERRQ(ierr); /* s = B^{-1} r */
    ierr = MatMult( A, s, v ); CHKERRQ(ierr);  /* v = A s */

  to fix the code to do the diagonal scaling you need to do a few things

1) replace the two lines above with a single call to KSP_PCApplyBAorAB() this will incorporate the scaling in the application of    A*B so instead it provides D A B D^{-1} 

2) this is more difficult. Understand the code well enough to fix it so that it properly takes into account the diagonal scaling if the initial guess is nonzero and also the fact that you are solving D A B D^{-1} y = D b instead of A B z = b  and hence  A x = b where x = B z so x = B *D^{-1} y

  Barry

> 
> Is it just that the check is missing for GCR so that it doesn't apply diagonal scaling and doesn't tell me?
> 
> Chris
> 
> 
> Message: 3
> Date: Thu, 24 Feb 2011 08:08:42 -0600
> From: Barry Smith <bsmith at mcs.anl.gov>
> Subject: Re: [petsc-users] PCDiagonalScale
> To: PETSc users list <petsc-users at mcs.anl.gov>
> Message-ID: <699188CA-750D-446A-AD58-C62CB2A75CE2 at mcs.anl.gov>
> Content-Type: text/plain; charset=us-ascii
> 
> 
> On Feb 23, 2011, at 9:45 AM, Klaij, Christiaan wrote:
> 
>> I'm trying to understand the use of PCDiagonalScale since I want to apply additional diagonal scaling when solving my linear system.
> 
>   Do you want to use it exactly for the reason given in
>   PCSetDiagonalScale - Indicates the left scaling to use to apply an additional left and right
>      scaling as needed by certain time-stepping codes.
> 
>   Logically Collective on PC
> 
>   Input Parameters:
> +  pc - the preconditioner context
> -  s - scaling vector
> 
>   Level: intermediate
> 
>   Notes: The system solved via the Krylov method is
> $           D M A D^{-1} y = D M b  for left preconditioning or
> $           D A M D^{-1} z = D b for right preconditioning
> 
> 
> dr. ir. Christiaan Klaij
> CFD Researcher
> Research & Development
> E mailto:C.Klaij at marin.nl
> T +31 317 49 33 44
> 
> MARIN
> 2, Haagsteeg, P.O. Box 28, 6700 AA Wageningen, The Netherlands
> T +31 317 49 39 11, F +31 317 49 32 45, I www.marin.nl
> 



More information about the petsc-users mailing list