<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link="#0563C1" vlink="#954F72" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>Hi everyone,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>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.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>My approach looks something like this<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>from petsc4py import PETSc<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>snes = PETSc.SNES().create()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>snes.setFunction(self.assemble_function, self.residual_petsc)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>snes.setJacobian(self.assemble_jacobian, self.A_petsc, self.P_petsc)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>snes.setFromOptions()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>snes.solve(None, self.u.vector().vec())<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>snes.destroy()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I don’t think that my user defined functions are problematic. The code runs well with the options (just an example)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-snes_type newtonls<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-snes_rtol 1e-6<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-snes_monitor<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-ksp_type gmres<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-ksp_monitor_true_residual<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-pc_type lu<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-pc_factor_mat_solver_type mumps<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-mat_mumps_icntl_24<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Here, the gmres is just used to verify that the direct solver works as expected. Newton Krylov methods also work well.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>However, once I use<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>-snes_type nrichardson<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-npc_snes_type newtonls<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>-npc_snes_max_it 4<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>(as discussed e.g. in <a href="https://climatemodeling.org/~rmills/talks/PSU-ACM-seminar-2024.pdf">https://climatemodeling.org/~rmills/talks/PSU-ACM-seminar-2024.pdf</a>) I get the error message<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>File "/p/tv/blauths/cashocs/cashocs/nonlinear_solvers/snes.py", line 250, in solve<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> snes.solve(None, self.u.vector().vec())<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> File "petsc4py/PETSc/SNES.pyx", line 1555, in petsc4py.PETSc.SNES.solve<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>petsc4py.PETSc.Error: error code 56<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I would be really grateful if someone could point me to the right direction on how to use nonlinear precondition with petsc4py.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks a lot in advance,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Sebastian<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>--<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Dr. Sebastian Blauth<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Fraunhofer-Institut für<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Techno- und Wirtschaftsmathematik ITWM<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Abteilung Transportvorgänge<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Fraunhofer-Platz 1, 67663 Kaiserslautern<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Telefon: +49 631 31600-4968<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'><a href="mailto:sebastian.blauth@itwm.fraunhofer.de"><span style='color:blue'>sebastian.blauth@itwm.fraunhofer.de</span></a><o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'><a href="https://www.itwm.fraunhofer.de"><span style='color:blue'>https://www.itwm.fraunhofer.de</span></a><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>