# [petsc-users] Petsc ILU PC Change between 3.6.4 and 3.7.x?

Klaij, Christiaan C.Klaij at marin.nl
Mon Aug 28 02:55:47 CDT 2017

```Hi Jed,

Thanks for clarifying, I understand the two-sided bound and the
condition number. So for left preconditioning we would have P_L A
instead of A in this bound and P_L r instead of r. For right
preconditioning it is less obvious to me. How much would that
loosen the bound?

Chris

dr. ir. Christiaan Klaij  | Senior Researcher | Research & Development
MARIN | T +31 317 49 33 44 | mailto:C.Klaij at marin.nl | http://www.marin.nl

MARIN news: http://www.marin.nl/web/News/News-items/Improved-modelling-of-sheet-cavitation-dynamics-on-Delft-Twistll-Hydrofoil-1.htm

________________________________________
From: Jed Brown <jed at jedbrown.org>
Sent: Thursday, August 24, 2017 6:01 PM
To: Klaij, Christiaan; Matthew Knepley; Barry Smith
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] Petsc ILU PC Change between 3.6.4 and 3.7.x?

"Klaij, Christiaan" <C.Klaij at marin.nl> writes:

> Matt,
>
> Thanks, I can understand the lower condition number of P A, but
> what about r? Doesn't that change to P r and if so why can we
> assume that ||r|| and ||P r|| have the same order?

Matt's equation was of course wrong in a literal sense, but is based on
the right moral convictions.  We have

r = A (x - x_exact)

which implies that

||r|| <= ||A|| || x - x_exact ||.

We also have

x - x_exact = A^{-1} r

so

|| x - x_exact || <= || A^{-1} || ||r||.

Combining these gives the two-sided bound

|| A ||^{-1} ||r|| <= || x - x_exact || <= || A^{-1} || ||r||.

The ratio of the high and low bounds is the condition number.  Our
convergence tolerance controls the norm of the residual (in a relative
or absolute sense).  If the condition number is smaller, we get tighter
control on the error.  If you are confident that your preconditioner
reduces the condition number, it makes sense to measure convergence in
the preconditioned norm (this is natural with left preconditioning for
GMRES), in which the bounds above are in terms of the preconditioned
operator.

The main reason for PETSc to keep the preconditioned norm as a default
is that many users, especially beginners, produce poorly scaled
equations, e.g., with penalty boundary conditions or with disparate
scales between fields with different units (displacement, pressure,
velocity, energy, etc.).  You will often see the unpreconditioned
residual drop by 10 orders of magnitude on the first iteration because
the penalty boundary conditions are satisfied despite the solution being
completely wrong inside the domain.

On the other hand, the preconditioned residual causes misdiagnosis of
convergence if the preconditioner is (nearly) singular, as is the case
with some preconditioners applied to saddle point problems, for example.
But this is easy to identify using -ksp_monitor_true_residual.

>
> Chris
>
>
> dr. ir. Christiaan Klaij | Senior Researcher | Research & Development
> MARIN | T +31 317 49 33 44 | C.Klaij at marin.nl<mailto:C.Klaij at marin.nl> | www.marin.nl<http://www.marin.nl>
>
> MARIN news: New C-DRONE - for undisturbed wave spectrum measurements<http://www.marin.nl/web/News/News-items/New-CDRONE-for-undisturbed-wave-spectrum-measurements-1.htm>
>
> ________________________________
> From: Matthew Knepley <knepley at gmail.com>
> Sent: Wednesday, August 23, 2017 8:37 AM
> To: Barry Smith
> Cc: Klaij, Christiaan; petsc-users at mcs.anl.gov
> Subject: Re: [petsc-users] Petsc ILU PC Change between 3.6.4 and 3.7.x?
>
> On Wed, Aug 23, 2017 at 2:30 AM, Barry Smith <bsmith at mcs.anl.gov<mailto:bsmith at mcs.anl.gov>> wrote:
>
>    Some argue that the preconditioned residual is "closer to" the norm of the error than the unpreconditioned norm. I don't have a solid mathematical reason to prefer left preconditioning with the preconditioned norm.
>
> Because you have || x - x_exact || < k(A) || r ||
>
> where r is the residual and k is the condition number of A. If instead of A you use P A, which we assume has a lower condition number, then
> this bound is improved.
>
>   Thanks,
>
>      Matt
>
>
>    Barry
>
>
>
>> On Aug 22, 2017, at 11:27 PM, Klaij, Christiaan <C.Klaij at marin.nl<mailto:C.Klaij at marin.nl>> wrote:
>>
>> Barry,
>>
>> Thanks for the explanation.
>>
>> We do have some rare cases that give false convergence, but
>> decided to use
>>
>> CALL KSPSetNormType(ksp,KSP_NORM_UNPRECONDITIONED,ierr)
>>
>> so that convergence is always based on the true residual. Our
>> results are much more consistent now. So that could have been
>> your protection against the rare case as well, right? Why do you
>> prefer left preconditioning?
>>
>> Chris
>>
>>
>>
>> dr. ir. Christiaan Klaij  | Senior Researcher | Research & Development
>> MARIN | T +31 317 49 33 44<tel:%2B31%20317%2049%2033%2044> | mailto:C.Klaij at marin.nl<mailto:C.Klaij at marin.nl> | http://www.marin.nl
>>
>> MARIN news: http://www.marin.nl/web/News/News-items/BlueWeek-October-911-Rostock.htm
>>
>> ________________________________________
>> From: Barry Smith <bsmith at mcs.anl.gov<mailto:bsmith at mcs.anl.gov>>
>> Sent: Tuesday, August 22, 2017 6:25 PM
>> To: Klaij, Christiaan
>> Cc: petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>
>> Subject: Re: [petsc-users] Petsc ILU PC Change between 3.6.4 and 3.7.x?
>>
>>> On Aug 22, 2017, at 6:49 AM, Klaij, Christiaan <C.Klaij at marin.nl<mailto:C.Klaij at marin.nl>> wrote:
>>>
>>> We also faced this problem in our code. So I've added:
>>>
>>> CALL PetscOptionsSetValue(PETSC_NULL_OBJECT,"-sub_pc_factor_shift_type","nonzero",ierr)
>>>
>>> since there seems to be no setter function for this (correct me
>>> if I'm wrong). Then everythings fine again.
>>>
>>> Out of curiosity, what was the reason to change the default
>>> behaviour?
>>
>>   The reason we changed this is that we would rather have a failure that makes the user aware of a serious problem then to produce "garbage" results. In some rare cases the shift can cause a huge jump in the preconditioned residual which then decreases rapidly while the true residual does not improve. This results in the KSP thinking it has converged while in fact it has essentially garbage for an answer. Under the previous model, where we shifted by default, users would in this rare case think they had reasonable solutions when they did not.
>>
>>   For many users, such as yourself, the previous default behavior was fine because you didn't have the "rare case" but we decided it was best to protect against the rare case even though it would require other users such as yourself to add the option.
>>
>>   Barry
>
>
>
>
> --
> 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
>
> http://www.caam.rice.edu/~mk51/
```