[petsc-users] Setting up nonlinear preconditioning with petsc4py
Blauth, Sebastian
sebastian.blauth at itwm.fraunhofer.de
Wed Dec 4 03:44:13 CST 2024
Hi everyone,
I wanted to try nonlinear preconditioning for solving nonlinear systems. The
problems arise from PDEs discretized with FEniCS and I have successfully
implemented a wrapper for SNES. However, once I want to try nonlinear
preconditioning by adding the option -npc_snes_type newtonls (or other
solvers such as nrichardson), I get the error code 56.
My approach looks something like this
from petsc4py import PETSc
snes = PETSc.SNES().create()
snes.setFunction(self.assemble_function, self.residual_petsc)
snes.setJacobian(self.assemble_jacobian, self.A_petsc, self.P_petsc)
snes.setFromOptions()
snes.solve(None, self.u.vector().vec())
snes.destroy()
I dont think that my user defined functions are problematic. The code runs
well with the options (just an example)
-snes_type newtonls
-snes_rtol 1e-6
-snes_monitor
-ksp_type gmres
-ksp_monitor_true_residual
-pc_type lu
-pc_factor_mat_solver_type mumps
-mat_mumps_icntl_24
Here, the gmres is just used to verify that the direct solver works as
expected. Newton Krylov methods also work well.
However, once I use
-snes_type nrichardson
-npc_snes_type newtonls
-npc_snes_max_it 4
(as discussed e.g. in
https://climatemodeling.org/~rmills/talks/PSU-ACM-seminar-2024.pdf) I get
the error message
File "/p/tv/blauths/cashocs/cashocs/nonlinear_solvers/snes.py", line 250, in
solve
snes.solve(None, self.u.vector().vec())
File "petsc4py/PETSc/SNES.pyx", line 1555, in petsc4py.PETSc.SNES.solve
petsc4py.PETSc.Error: error code 56
I would be really grateful if someone could point me to the right direction
on how to use nonlinear precondition with petsc4py.
Thanks a lot in advance,
Sebastian
--
Dr. Sebastian Blauth
Fraunhofer-Institut für
Techno- und Wirtschaftsmathematik ITWM
Abteilung Transportvorgänge
Fraunhofer-Platz 1, 67663 Kaiserslautern
Telefon: +49 631 31600-4968
<mailto:sebastian.blauth at itwm.fraunhofer.de>
sebastian.blauth at itwm.fraunhofer.de
<https://www.itwm.fraunhofer.de> https://www.itwm.fraunhofer.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20241204/fc9cc15a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 7943 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20241204/fc9cc15a/attachment-0001.p7s>
More information about the petsc-users
mailing list