# [petsc-users] SNES norm control

Dave May dave.mayhem23 at gmail.com
Tue Jan 12 07:24:29 CST 2016

```On 12 January 2016 at 14:14, Gideon Simpson <gideon.simpson at gmail.com>
wrote:

> That seems to to allow for me to cook up a convergence test in terms of
> the 2 norm.
>

While you are only provided the 2 norm of F, you are also given access to
the SNES object. Thus inside your user convergence test function, you can
call SNESGetFunction() and SNESGetSolution(), then you can compute your
convergence criteria and set the converged reason to what ever you want.

See

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESGetFunction.html

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESGetSolution.html

Cheers,
Dave

> What I’m really looking for is the ability to change things to be
> something like the 2 norm of the vector with elements
>
> F_i/|x_i|
>
> where I am looking for a root of F(x).  I can just build that scaling into
> the form function, but is there a way to do it without rewriting that piece
> of the code?
>
>
> -gideon
>
> On Jan 12, 2016, at 12:14 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
>
>   You can use SNESSetConvergenceTest() to use whatever test you want to
> decide on convergence.
>
> Barry
>
> On Jan 11, 2016, at 3:26 PM, Gideon Simpson <gideon.simpson at gmail.com>
> wrote:
>
> I’m solving nonlinear problem for a complex valued function which is
> decomposed into real and imaginary parts, Q = u + i v.  What I’m finding is
> that where |Q| is small, the numerical phase errors tend to be larger.  I
> suspect this is because it’s using the 2-norm for convergence in the SNES,
> so, where the solution is already, the phase errors are seen as small too.
> Is there a way to use something more like an infinity norm with SNES, to
> get more point wise control?
>
> -gideon
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160112/0486fb2e/attachment.html>
```