[petsc-users] Can we force SNES solver to do at least Newton step?

Matthew Knepley knepley at gmail.com
Sat Sep 2 14:23:35 CDT 2023


On Sat, Sep 2, 2023 at 3:05 PM David Knezevic via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hi all,
>
> I'm using the SNES solver for a plasticity model, and the issue I've run
> into is that in some time steps the solver terminates after "NL step 0"
> since the initial residual (based on the solution from the previous time
> step) is below the specified tolerance.
>
> I gather that "NL step 0" only checks the residual and doesn't actually do
> a Newtown update, and hence it seems that this is leading to inaccurate
> results in some cases.
>

I do not understand this comment. What do you mean by "inaccurate"? Since
we do not have the true solution, we usually say "inaccurate" for large
residual, but you already said that the residual is small.
Why would you want to do another iterate?


> I can of course specify a smaller convergence tolerance to avoid this
> issue, but I've found it difficult to find a smaller tolerance that works
> well in all cases (e.g. it leads to too many iterations or
> non-convergence). So instead what I would like to do is ensure that the
> solver does at least 1 Newton iteration instead of terminating at "NL step
> 0". Is there a way to enforce this behavior, e.g. by skipping "NL step 0",
> or specifying a "minimum number of iterations"? I didn't see anything like
> this in the documentation, so I was wondering if there are any suggestions
> on how to proceed for this.
>

The easiest way to do this is to write a custom convergence test that looks
like this

PetscErrorCode SNESConvergedDefault(SNES snes, PetscInt it, PetscReal
xnorm, PetscReal snorm, PetscReal fnorm, SNESConvergedReason *reason, void
*dummy)
{
  PetscFunctionBeginUser;
  if (!it) {
    *reason = SNES_CONVERGED_ITERATING;
    PetscFunctionReturn(PETSC_SUCCESS);
  }
  PetscCall(SNESConvergedDefault(snes, it, xnorm, snorm, fnorm, reason,
dummy));
  PetscFunctionReturn(PETSC_SUCCESS);
}

  Thanks,

     Matt


> Thanks,
> David
>


-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230902/f5a0518c/attachment.html>


More information about the petsc-users mailing list