[petsc-users] Cannot iterate well when using Newton iteration of SNES

Matthew Knepley knepley at gmail.com
Thu Nov 21 09:37:37 CST 2024


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

  Thanks,

     Matt

On Thu, Nov 21, 2024 at 10:35 AM Jed Brown <jed at jedbrown.org> 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"        <12431140 at mail.sustech.edu.cn> writes:
>
> > I am using the Newton iteration to solve a nonlinear 1D heat equation
> problem by using FEM.
> >
> >
> > I attached my source code named "SNES_heat.cpp" 
> >
> >
> > when I run the code
> >
> >   0 SNES Function norm 1.206289245288e+01
> >
> >   1 SNES Function norm 7.128802192789e+00
> >
> >   2 SNES Function norm 6.608812909525e+00
> >
> >
> >
> > you can find that it only iterate 3 steps, and then do all the function
> evaluation and finally just stop the program. 
> >
> >
> > 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.
> >
> >
> > But when I set it as a nonlinear, the residual seems reduces as not
> expected. 
> >
> >
> > I doubt that whether my understanding of the newton iteration is
> different from SNES's newton iteration process.
> >
> >
> >
> >
> >
> >
> >
> >
> > David Jiawei LUO LIANG
> >
> >
> >
> > 南方科技大学/学生/研究生/2024
> >
> >
> >
> > 广东省深圳市南山区学苑大道1088号
> >
> >
> >
> >
> >  
>


-- 
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!Z_i28V-z4i339qw9rz21qC1sKBK1hY750356Y2SekU_d3pHw-mdIgh0mJCT_Qp5HPuu0XkvutxpF0oHTYsJE$  <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Z_i28V-z4i339qw9rz21qC1sKBK1hY750356Y2SekU_d3pHw-mdIgh0mJCT_Qp5HPuu0XkvutxpF0qBbFLUd$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20241121/a9ba0649/attachment-0001.html>


More information about the petsc-users mailing list