<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span class="smartReply">Will do. The output is very long, I'm sending you the last 20 iteration of KSP when the nonlinear solver did not converge. That's what i have:</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span class="smartReply"><br>
</span></div>
Linear solve converged due to CONVERGED_ITS iterations 1
<div class="ContentPasted0"> 9980 KSP preconditioned resid norm 7.911586848688e-14 true resid norm 3.571299151668e-13 ||r(i)||/||b|| 1.088933920648e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9981 KSP preconditioned resid norm 7.773677194223e-14 true resid norm 3.519061016604e-13 ||r(i)||/||b|| 1.073005857832e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9982 KSP preconditioned resid norm 7.142532169111e-14 true resid norm 3.536747918236e-13 ||r(i)||/||b|| 1.078398816059e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9983 KSP preconditioned resid norm 6.325819556307e-14 true resid norm 3.698647905235e-13 ||r(i)||/||b|| 1.127764153463e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9984 KSP preconditioned resid norm 6.119227152008e-14 true resid norm 3.563406240582e-13 ||r(i)||/||b|| 1.086527273025e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9985 KSP preconditioned resid norm 6.075666963630e-14 true resid norm 3.710895872549e-13 ||r(i)||/||b|| 1.131498712373e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9986 KSP preconditioned resid norm 5.985095889340e-14 true resid norm 3.509409502428e-13 ||r(i)||/||b|| 1.070062990062e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9987 KSP preconditioned resid norm 5.243339292054e-14 true resid norm 3.627159951643e-13 ||r(i)||/||b|| 1.105966579450e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9988 KSP preconditioned resid norm 4.491198445126e-14 true resid norm 4.006851442317e-13 ||r(i)||/||b|| 1.221739278968e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9989 KSP preconditioned resid norm 4.410245117574e-14 true resid norm 4.031793308619e-13 ||r(i)||/||b|| 1.229344366950e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9990 KSP preconditioned resid norm 4.072064997637e-13 true resid norm 4.072064997637e-13 ||r(i)||/||b|| 1.241623710224e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9991 KSP preconditioned resid norm 2.614566817566e-13 true resid norm 3.327810250174e-13 ||r(i)||/||b|| 1.014691099513e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9992 KSP preconditioned resid norm 2.214885215262e-13 true resid norm 3.122694737130e-13 ||r(i)||/||b|| 9.521488059891e-04</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9993 KSP preconditioned resid norm 1.937414464538e-13 true resid norm 2.949371229399e-13 ||r(i)||/||b|| 8.993002937814e-04</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9994 KSP preconditioned resid norm 1.683143904883e-13 true resid norm 3.116491153488e-13 ||r(i)||/||b|| 9.502572555001e-04</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9995 KSP preconditioned resid norm 1.455417378095e-13 true resid norm 3.848207009730e-13 ||r(i)||/||b|| 1.173366600951e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9996 KSP preconditioned resid norm 1.254552363609e-13 true resid norm 3.494786173247e-13 ||r(i)||/||b|| 1.065604153515e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9997 KSP preconditioned resid norm 1.187610795222e-13 true resid norm 3.364834320451e-13 ||r(i)||/||b|| 1.025980203084e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9998 KSP preconditioned resid norm 1.126887893465e-13 true resid norm 4.347573700680e-13 ||r(i)||/||b|| 1.325629770605e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 9999 KSP preconditioned resid norm 1.067379754742e-13 true resid norm 3.907245052617e-13 ||r(i)||/||b|| 1.191368040981e-03</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0">Linear solve converged due to CONVERGED_ITS iterations 1</div>
<div class="ContentPasted0"> 10000 KSP preconditioned resid norm 1.027326121286e-13 true resid norm 4.122100161195e-13 ||r(i)||/||b|| 1.256880059386e-03</div>
<div class="ContentPasted0"> Linear solve did not converge due to DIVERGED_ITS iterations 10000</div>
<div class="ContentPasted0">Nonlinear solve did not converge due to DIVERGED_LINEAR_SOLVE iterations 1</div>
Linear solve converged due to CONVERGED_ITS iterations 1<br>
</div>
<div id="appendonsend"></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size: 11pt; color: rgb(0, 0, 0);" face="Calibri, sans-serif"><b>De :</b> Barry Smith <bsmith@petsc.dev><br>
<b>Envoyé :</b> mercredi 20 septembre 2023 16:26<br>
<b>À :</b> Harry-Arthur Cousin <harry-arthur@hotmail.fr><br>
<b>Cc :</b> petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Objet :</b> Re: [petsc-users] Problem with snes: petsc 3.4.5</font>
<div> </div>
</div>
<div style="line-break:after-white-space">
<div><br>
</div>
Run with -snes_monitor and -ksp_monitor_true_residual and send the output<br>
<div><br>
<blockquote type="cite">
<div>On Sep 20, 2023, at 9:34 AM, Harry-Arthur Cousin <harry-arthur@hotmail.fr> wrote:</div>
<br class="x_Apple-interchange-newline">
<div>
<div class="x_elementToProof x_ContentPasted0" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Hello,</div>
<div style="font-family:Helvetica; font-size:18px; font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<br>
</div>
<div class="x_elementToProof x_ContentPasted2" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
I'm on petsc version 3.4.5.</div>
<div class="x_elementToProof x_ContentPasted2" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_elementToProof x_ContentPasted2" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
My program has a time loop where I have to solve a non-linear system of the form F(X) = D*L*J + I + kappa(X) where X is an unknown vector, D and L are diagonal square matrices, J is a vector that can be calculated by solving a linear system with X and kappa
is a non-linear application. I use the "-snes_mf" option to, as I understand it, approximate the Jacobian using finite differences.</div>
<div class="x_elementToProof x_ContentPasted2" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_elementToProof x_ContentPasted2 x_ContentPasted4" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
A first version of my problem could be solved, so I made it more complex by changing the values of the matrix L, which used to have the same value on the whole diagonal and now has values of the same order of magnitude but different. This second version takes
longer and doesn't converge after a while. I get the message: Nonlinear solve did not converge due to DIVERGED_LINEAR_SOLVE. However, when I look at the faq (<a href="https://petsc.org/release/faq/#why-is-newton-s-method-snes-not-converging-or-converges-slowly" data-auth="NotApplicable" id="OWA7b878f93-5f0e-b945-4fa7-729dffb4f909" class="x_OWAAutoLink x_ContentPasted3">https://petsc.org/release/faq/#why-is-newton-s-method-snes-not-converging-or-converges-slowly</a>),
it indicates that it's probably a Jacobian problem. What should I do? Do I have to calculate the explicit Jacobian? The explicit Jacobian requires the inversion of a matrix (due to the linear system for solving J).</div>
<div class="x_elementToProof x_ContentPasted2 x_ContentPasted4 x_ContentPasted5 x_ContentPasted7" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_elementToProof x_ContentPasted2 x_ContentPasted4 x_ContentPasted5" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_elementToProof x_ContentPasted2 x_ContentPasted4 x_ContentPasted5 x_ContentPasted6" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Kind regards,</div>
<div class="x_elementToProof x_ContentPasted2 x_ContentPasted4 x_ContentPasted5 x_ContentPasted6" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_elementToProof x_ContentPasted2 x_ContentPasted4 x_ContentPasted5" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Harry Cousin</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>