[petsc-dev] SNESConvergedDefault() side effect?
Jed Brown
jedbrown at mcs.anl.gov
Wed Jul 24 14:24:19 CDT 2013
Dmitry Karpeyev <karpeev at mcs.anl.gov> writes:
> It appears that SNESConvergedDefault() sets snes->ttol here
> https://bitbucket.org/petsc/petsc/src/40bc6eb114e6a8e7f27fd216b5c1226efddf337a/src/snes/interface/snesut.c?at=master#cl-462
>
> That should be harmless, albeit unnecessary, since snes->ttol is also set
> at the beginning of the solve in SNESSolve_NEWTONLS() (and other
> SNESSolve_XXX) right before calling the convergence test:
> https://bitbucket.org/petsc/petsc/src/40bc6eb114e6a8e7f27fd216b5c1226efddf337a/src/snes/impls/ls/ls.c?at=master#cl-202
>
>
> However, this might make for some fragile code and may confuse the user
> modeling a custom convergence test on SNESConvergedDefault(). In
> particular, a local reading of SNESConvergedDefault() creates the
> impression that it is the convergence monitor that is responsible for
> setting snes->ttol on the zeroth iteration -- snes->ttol is used outside of
> SNES, for example, in one of the variants of the EW code (maybe only
> there). That would require access to SNES internals by user code.
Well, when using SNESSkipConverged (should have been named
SNESConvergedSkip when changing to SNESConvergedDefault!), we don't need
an initial function norm, so setting ttol outside the convergence test
is wasteful. (I'm thinking in terms of reductions when using an
inexpensive SNES iteration like a point smoother.) If the convergence
test implementation wants to use a relative tolerance, then it should
store the target tolerance (or equivalently, the initial residual) in
its own context. I think all reference to ttol should be removed from
outside the convergence tests.
> More generally, should this sort of thing be handled everywhere using
> snes->norm_init for consistency and to prevent potential breakage?
snes->norm_init goes with SNESSetInitialFunctionNorm and I don't think
it's used otherwise.
> At the very least, should snes->ttol = ... be removed from
> SNESConvergedDefault()?
> Thanks.
> Dmitry.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130724/3f729b71/attachment.sig>
More information about the petsc-dev
mailing list