[petsc-users] Understanding 'snes' object
Zou, Ling
lzou at anl.gov
Tue Aug 26 09:24:00 CDT 2025
Barry, thanks very much for the insight, and you are right!
For the purpose of sharing information, in case anyone is interested, here are some details.
The problem at hand is a *nearly* incompressible flow problem, such that part of the diagonal Jacobian term (d(rho)_dp) is very close to but not truly zero.
I have noticed that Option-2 complained about zero pivot, and I can see that the diagonal Jacobian term is zero by outputting the Jacobian.
Option-1 was Ok, and I can see that the diagonal Jacobian term is very small but non-zero.
So you are right, they behave very similarly but produces a tiny bit of difference.
Best,
-Ling
From: Barry Smith <bsmith at petsc.dev>
Date: Sunday, August 24, 2025 at 3:30 PM
To: Zou, Ling <lzou at anl.gov>
Cc: Stefano Zampini <stefano.zampini at gmail.com>, PETSc <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] Understanding 'snes' object
You should have very similar behavior, but not identical behavior. The Jacobian-vector product will produce slightly different values with the two approaches, which means that the computed residual norms displayed with -ksp_monitor -snes_monitor
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
You should have very similar behavior, but not identical behavior. The Jacobian-vector product will produce slightly different values with the two approaches, which means that the computed residual norms displayed with -ksp_monitor -snes_monitor etc will be somewhat different. With long runs that involve many nonlinear solves the differences in the norms computed will become nontrivial and you will start getting different iteration counts, but the solutions computed should remain very similar.
Barry
On Aug 23, 2025, at 10:03 AM, Zou, Ling via petsc-users <petsc-users at mcs.anl.gov> wrote:
Thank you both Jed and Stefano.
Then, somehow, I may have introduced inconsistence in my code, because I expected they have exactly the same behavior.
Best,
-Ling
From: Stefano Zampini <stefano.zampini at gmail.com<mailto:stefano.zampini at gmail.com>>
Date: Friday, August 22, 2025 at 4:42 PM
To: Zou, Ling <lzou at anl.gov<mailto:lzou at anl.gov>>
Cc: PETSc <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>>
Subject: Re: [petsc-users] Understanding 'snes' object
Il giorno sab 23 ago 2025 alle ore 00: 25 Zou, Ling via petsc-users <petsc-users@ mcs. anl. gov> ha scritto: Hi all, Can someone please help me understand the output of the following two outputs using ‘-snes_view’? Option 1: SNES Object: 1
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Il giorno sab 23 ago 2025 alle ore 00:25 Zou, Ling via petsc-users <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>> ha scritto:
Hi all,
Can someone please help me understand the output of the following two outputs using ‘-snes_view’?
Option 1:
SNES Object: 1 MPI process
type: newtonls
maximum iterations=15, maximum function evaluations=10000
tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
total number of linear solver iterations=5
total number of function evaluations=14
norm schedule ALWAYS
Jacobian is built using finite differences with coloring
Option 2:
SNES Object: 1 MPI process
type: newtonls
maximum iterations=50, maximum function evaluations=10000
tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
total number of linear solver iterations=8
total number of function evaluations=17
norm schedule ALWAYS
Jacobian is applied matrix-free with differencing
Preconditioning Jacobian is built using finite differences with coloring
Does it mean that
* Option 1 uses Newton’s method, such that J du = b is solved with J being explicitly constructed?
yes
*
* Option 2 uses matrix free method, such that J du = b is solved with J v ~ (F(u + dv) – F(u)) / h when needed, e.g., in a Krylov method.
yes, and the preconditioner is constructed using an explicitly constructed Jacobian matrix
*
Thanks,
-Ling
--
Stefano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250826/91962a42/attachment-0001.html>
More information about the petsc-users
mailing list