<div dir="ltr">One more suggestion email. I solve the linear version myself in ts/tutorials/ex45.c<div><br></div><div> Thanks,</div><div><br></div><div> Matt</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 21, 2024 at 10:35 AM Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">You should add VecZeroEntries(f) near the top of your FormFunction (it's currently accumulating into whatever was there last) and MatZeroEntries(B) to FormJacobian.<br>
<br>
I reduced to nElem = 5 for ease of viewing. With these changes, I see quadratic convergence but the problem is still nonlinear. To explore further, consider using these diagnostics<br>
<br>
./SNES_heat -{snes,ksp}_monitor -{snes,ksp}_converged_reason -snes_linesearch_monitor -ksp_view_mat<br>
<br>
with and without -snes_fd.<br>
<br>
For readability, I would suggest consistency in "u" vs "x".<br>
<br>
"David Jiawei LUO LIANG" <<a href="mailto:12431140@mail.sustech.edu.cn" target="_blank">12431140@mail.sustech.edu.cn</a>> writes:<br>
<br>
> I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM.<br>
><br>
><br>
> I attached my source code named "SNES_heat.cpp" <br>
><br>
><br>
> when I run the code<br>
><br>
> 0 SNES Function norm 1.206289245288e+01<br>
> <br>
> 1 SNES Function norm 7.128802192789e+00<br>
> <br>
> 2 SNES Function norm 6.608812909525e+00<br>
><br>
><br>
><br>
> you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program. <br>
><br>
><br>
> I think it is not reasonble. I check my code, it is correct if I set it as a linear problem. it means my Jacobian and Residual function is correct.<br>
><br>
><br>
> But when I set it as a nonlinear, the residual seems reduces as not expected. <br>
><br>
><br>
> I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process.<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> David Jiawei LUO LIANG<br>
><br>
><br>
><br>
> 南方科技大学/学生/研究生/2024<br>
><br>
><br>
><br>
> 广东省深圳市南山区学苑大道1088号<br>
><br>
><br>
><br>
><br>
> <br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Z_i28V-z4i339qw9rz21qC1sKBK1hY750356Y2SekU_d3pHw-mdIgh0mJCT_Qp5HPuu0XkvutxpF0qBbFLUd$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div>