[petsc-users] SNESSetFunctionDomainError

Dmitry Karpeyev karpeev at mcs.anl.gov
Sun Aug 24 22:20:47 CDT 2014


On Sun, Aug 24, 2014 at 9:40 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> On Aug 24, 2014, at 9:06 PM, Derek Gaston <friedmud at gmail.com> wrote:
>
> > There must be something I'm missing about SNESSetFunctionDomainError().
> >
> > I'm using a matrix free newton solve and I was hoping that calling
> SNESSetFunctionDomainError() would completely stop the nonlinear solver...
> but that doesn't appear to be the case.
> >
> > Now - if I call that function during the initial residual computation it
> appears to work (the solve never starts).  However, if I call it during the
> _middle_ of a matrix free nonlinear solve during a residual calculation -
> it appears to do absolutely nothing.
>
>    You are not missing anything. The way SNESSetFunctionDomainError()
> works is it merely sets a flag in the SNES object. The solver code then can
> check that flag after a function evaluation and generate an if that flag is
> set (or perhaps do some kind of recovery). So, for example, at the
> beginning of SNESSolve_NewtonLS() we have
>
>  } else {
>     if (!snes->vec_func_init_set) {
>       ierr = SNESComputeFunction(snes,X,F);CHKERRQ(ierr);
>       ierr = SNESGetFunctionDomainError(snes, &domainerror);CHKERRQ(ierr);
>       if (domainerror) {
>         snes->reason = SNES_DIVERGED_FUNCTION_DOMAIN;
>         PetscFunctionReturn(0);


> Now the reason it is not erroring out for you is because
>
> 1) our MatMult_MFFD() totally ignores the SNES domain error business
> because it doesn’t even know about SNES
>
> 2) inside the various nonlinear solvers and many complicated line search
> codes we may not always be checking the domainerror flag.
>
>   Both of these things, of course, should be fixed. We need to add support
> to the MatMult_MFFD() to indicate domain errors and we need to check all
> the code to make sure we always handle the domain error flag.
>
> In particular, we check for domain errors inside the linesearch and after
the linear update. Which means that, if after the linear update you are
still hitting a domain error, the solver will quit.

This problem is somewhat related to the question of what to do inside
SNESVI (bounded) MF solves: if a constraint is active, it's quite possible
that differencing in a given direction will cause a domain error (this
situation might arise, for example, in Relap-7 with its bounds on
densities). For reduced space methods we might simply mask out the active
components of a differencing direction, since the linear solve ignores
those anyway.  It's less clear to me what to do with the bounds that are
hit, but are inactive. Or even interior points that are within a
differencing parameter of the boundary of the feasible set? The same goes
for semismooth solvers (or, perhaps, other methods that we might want to
eventually incorporate from Tao).

Also, while we are at it, we ought to unify MatMFFD with
SNESComputeJacobianDefault(), which more or less duplicates the MFFD
algorithms.

Dmitry.

>    Barry
>
>
> >
> > Here's my stupid debugging code that's at the top of my residual
> callback method:
> >
> >     static int count = 0;
> >     count++;
> >
> >     if (count == 5)
> >     {
> >       std::cout<<"stopping solve!"<<std::endl;
> >       SNESSetFunctionDomainError(snes);
> >     }
> >
> >
> > During the solve "stopping solve!" gets printed out after computing the
> 3rd linear iteration of the first newton step... but the solve just
> continues without stopping...
> >
> > Is there something more I need to do here?
> >
> > Thanks!
> >
> > Derek
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140824/4e1e2f5c/attachment.html>


More information about the petsc-users mailing list