<div>Coincidentally, Matt. I am gonna write the 2d heat dynamic problem. </div><div><br></div><div>Now I still not that much understand how DM mesh works.</div><div><br></div><div>It is a good chance to learn DM by studying your example. </div><div><br></div><div>Hope you the best!</div><div><font><br></font></div><div><sign signid="99"><div><font><br></font><font><br></font><font><br></font><font><br></font><div style="color:#909090;font-family:Arial Narrow;font-size:12px"></div></div><div style="font-size:14px;font-family:Verdana;color:#000;" class="signRealArea"><div><div class="logo" style="width:305px;height:35px;line-height:35px;margin:20px 0 0 0;"><img src="https://exmail.qq.com/cgi-bin/viewfile?type=logo&domain=mail.sustech.edu.cn" onerror=""></div><div class="c_detail" style="margin:10px 0 0 0;"><h4 class="name" style="margin:0;font-size:14px;font-weight:bold;line-height:28px;zoom:1;">David Jiawei LUO LIANG</h4><p class="position" style="margin:0;line-height:22px;color:#a0a0a0;"></p><p class="department" style="margin:0;line-height:22px;color:#a0a0a0;">南方科技大学/学生/研究生/2024</p><p class="phone" style="margin:0;line-height:22px;color:#a0a0a0;"></p><p class="addr" style="margin:0;line-height:22px;color:#a0a0a0;">广东省深圳市南山区学苑大道1088号</p></div></div></div></sign></div><div> </div><div><includetail><div> </div><div> </div><div style="font:Verdana normal 14px;color:#000;"><div style="FONT-SIZE: 12px;FONT-FAMILY: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="FONT-SIZE: 12px;background:#efefef;padding:8px;"><div id="menu_sender"><b>From: </b> "Matthew Knepley"<knepley@gmail.com>;</div><div><b>Date: </b> Thu, Nov 21, 2024 11:37 PM</div><div><b>To: </b> "Jed Brown"<jed@jedbrown.org>; <wbr></div><div><b>Cc: </b> "David Jiawei LUO LIANG"<12431140@mail.sustech.edu.cn>; "petsc-users"<petsc-users@mcs.anl.gov>; <wbr></div><div><b>Subject: </b> Re: [petsc-users] Cannot iterate well when using Newton iteration of SNES</div></div><div> </div><div style="position:relative;"><div id="tmpcontent_res"></div><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!dSL2GSpljTIMB0tcY__f9j77VbVzQe3qtLiTf_zyXLkjYGis3L_HhIi6Zd3Xebfl90gusl7j3fAmWfqFsna4Ipv554lrYPbQ$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div>
</div></div><!--<![endif]--></includetail></div>