Coincidentally, Matt. I am gonna write the 2d heat dynamic problem. 


Now I still not that much understand how DM mesh works.


It is a good chance to learn DM by studying your example. 


Hope you the best!










David Jiawei LUO LIANG



南方科技大学/学生/研究生/2024



广东省深圳市南山区学苑大道1088号




 
 
 
------------------ Original ------------------
From: &nbsp;"Matthew&nbsp;Knepley"<knep...@gmail.com&gt;;
Date: &nbsp;Thu, Nov 21, 2024 11:37 PM
To: &nbsp;"Jed Brown"<j...@jedbrown.org&gt;; 
Cc: &nbsp;"David Jiawei LUO LIANG"<12431...@mail.sustech.edu.cn&gt;; 
"petsc-users"<petsc-users@mcs.anl.gov&gt;; 
Subject: &nbsp;Re: [petsc-users] Cannot iterate well when using Newton 
iteration of SNES

&nbsp;

One more suggestion email. I solve the linear version myself in 
ts/tutorials/ex45.c

&nbsp; Thanks,


&nbsp; &nbsp; &nbsp;Matt


On Thu, Nov 21, 2024 at 10:35 AM Jed Brown <j...@jedbrown.org&gt; wrote:

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.
 
 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
 
 ./SNES_heat -{snes,ksp}_monitor -{snes,ksp}_converged_reason 
-snes_linesearch_monitor -ksp_view_mat
 
 with and without -snes_fd.
 
 For readability, I would suggest consistency in "u" vs "x".
 
 "David Jiawei LUO LIANG"&nbsp; &nbsp; &nbsp; &nbsp; 
<12431...@mail.sustech.edu.cn&gt; writes:
 
 &gt; I am using the Newton iteration to solve a nonlinear 1D heat equation 
problem by using FEM.
 &gt;
 &gt;
 &gt; I attached my source code named "SNES_heat.cpp"&amp;nbsp;
 &gt;
 &gt;
 &gt; when I run the code
 &gt;
 &gt; &amp;nbsp; 0 SNES Function norm 1.206289245288e+01
 &gt;&nbsp; 
 &gt; &amp;nbsp; 1 SNES Function norm 7.128802192789e+00
 &gt;&nbsp; 
 &gt; &amp;nbsp; 2 SNES Function norm 6.608812909525e+00
 &gt;
 &gt;
 &gt;
 &gt; you can find that it only iterate 3 steps, and then do all the function 
evaluation and finally just stop the program.&amp;nbsp;
 &gt;
 &gt;
 &gt; 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.
 &gt;
 &gt;
 &gt; But when I set it as a nonlinear, the residual seems reduces as not 
expected.&amp;nbsp;
 &gt;
 &gt;
 &gt; I doubt that whether my understanding of the newton iteration is 
different from SNES's newton iteration process.
 &gt;
 &gt;
 &gt;
 &gt;
 &gt;
 &gt;
 &gt;
 &gt;
 &gt; David Jiawei LUO LIANG
 &gt;
 &gt;
 &gt;
 &gt; 南方科技大学/学生/研究生/2024
 &gt;
 &gt;
 &gt;
 &gt; 广东省深圳市南山区学苑大道1088号
 &gt;
 &gt;
 &gt;
 &gt;
 &gt; &amp;nbsp;
 



-- 
What most experimenters take for granted before they begin their experiments is 
infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener


https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!dSL2GSpljTIMB0tcY__f9j77VbVzQe3qtLiTf_zyXLkjYGis3L_HhIi6Zd3Xebfl90gusl7j3fAmWfqFsna4Ipv55wHVlbA1$
 

Reply via email to