[petsc-users] Inquiry Regarding Callback Implementation for SNES in PETSc

Rene Chenard rene.chenard at icloud.com
Tue Nov 14 14:50:09 CST 2023


Dear PETSc Developers,

I hope this message finds you well. My name is René Chenard, and I am a Research Professional at Université Laval. We are currently working on implementing a wrapper for the SNES in our project and are seeking guidance on incorporating callbacks at different stages of the resolution process.

Specifically, our objective is to implement a callback that triggers at the initiation of every nonlinear iteration and another that activates at the conclusion of each nonlinear iteration. In our exploration, we discovered the potential use of SNESSetUpdate and SNESSetConvergenceTest for this purpose.

However, we encountered a challenge with SNESSetUpdate, as it seems to be ineffective for the ngmres and anderson solver types, the latter of which appears to be based on the implementation of ngmres. We are reaching out to seek clarification on whether this behavior is intentional and to explore alternative approaches that might better suit our needs.

To facilitate a clearer understanding of our observations, we have prepared a reproduction example in the file named test_snes.c. This file outlines the specific scenarios where we encountered challenges with SNESSetUpdate and provides a context for our inquiries.

Here are our specific questions:

1. Is SNESSetUpdate designed to function uniformly across all types of SNES solvers?
2. What would be the recommended approach to implement custom callbacks around every nonlinear iteration, especially considering the apparent limitations with SNESSetUpdate for certain solver types?
3. We observed a discrepancy in the iteration/step numbering between the update function (set by SNESSetUpdate) and the convergence function (set by SNESSetConvergenceTest). Could you provide clarification on this, considering the documentation's description of SNESSetUpdate as the function "called at the beginning of every iteration of the nonlinear solve"?

We genuinely appreciate your expertise in this matter, and your insights will be invaluable in guiding our implementation. Thank you in advance for your consideration and support.

Warm regards,

—René Chenard
Research Professional at Université Laval
rene.chenard.1 at ulaval.ca <mailto:rene.chenard.1 at ulaval.ca>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231114/ba4d2923/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_snes.c
Type: application/octet-stream
Size: 13581 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231114/ba4d2923/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231114/ba4d2923/attachment-0001.html>


More information about the petsc-users mailing list