Custom Newton Step in PETSc SNES

Hello,

In order to solve a set of Navier-Stokes equations, I am trying to implement within PETSc a modified version of Newton’s method which theoretically converges faster (cubic instead of quadratic). I was wondering about what the cleanest way to achieve this is, ideally I would only like to touch the SNES object associated to the non-linear variational solver (and its method solve() in particular). I would appreciate any help in doing this.

Thanks a lot in advance.

Are you talking about legacy FEniCS or DOLFINx here, as the approach to do it in the two frameworks are quite different.

For SNES in DOLFINx, you can work with: dolfinx/python/test/unit/nls/test_newton.py at 617b35892e40a43d392954d81af7408aed641a1e · FEniCS/dolfinx · GitHub
and modify J and F as seem fit.

Hello @dokken,
Thanks for your answer. I am talking about DOLFINx, sorry I should have been more precise. However, with respect to the link you sent, I would need to change the Newton step at every iteration.

Then this is a pure PETSc/Snes question right?
You could use the DOLFINx Newton solver, and add hooks into that, but I guess that is not what you want either.

Hello,
Yes it is indeed a pure PETSc/SNES question… I just want to change how every Newton-Raphson iteration is carried out.

In that case, you may be better off asking at the PETSc support channel.