This Message Is From an External Sender
This message came from outside your organization.
Dear Barry,
Thanks for the hint. This works for my purpose. I did not need to access my form function value, so I did not call SNESGetFunction() in my callback function. Maybe another small question about Jacobian test. I implemented a matrix-free jacobian in my snes solver, then i ran my code with "-snes_type newtonls -ksp_type gmres -snes_linesearch_type bt -snes_test_jacobian -snes_test_jacobian_view". It gave message like this ||J - Jfd||_F/||J||_F = 0.321634, ||J - Jfd||_F = 6.81067e+12 which is much larger than the expected scale 1e-8, however the above ratio is constant and my |J-Jfd|_F is gradually changing at this scale around 6.81e+12. Is my own hand-coded matrix-free jacobian wrong? In fact my code has a converged and reasonable result for various cases. I guess Jfd is an approximation, so I could still have a possibly correct Jacobian. Best wishes, Yi On 2/15/24 04:35, Barry Smith wrote: > Use SNESSetUpdate() to provide a callback function that gets called by SNES automatically immediately before each linear solve. Inside your callback use SNESGetFunction(snes,f,NULL,NULL); to access the last computed value of your function, from this you can update your global variable. > > Barry > > >> On Feb 14, 2024, at 4:28 PM, Yi Hu <[email protected]> wrote: >> >> Dear PETSc team, >> >> I am using a newtonls snes solver. I know that form residual is invoked at several locations of the algorithm, first evaluated for the rhs of ksp solver, then several times for obtaining the optimal step of line search. >> >> In my problem I have a global variable that is updated every time when form residual is called, which is not desired in the context of netwonls. Basically, it should be only evaluated for the purpose of rhs of ksp (and not in line search). So is it possible to know in which context my form residual is used for? Then I can just skip my line of updating global variable depending on this condition. If not possible, could you suggest a workaround? Or do I need to design a customized line search routine? >> >> Thanks for your help. >> >> Best regards, >> >> Yi >> >> >> >> ------------------------------------------------- >> Stay up to date and follow us on LinkedIn, Twitter and YouTube. >> >> Max-Planck-Institut für Eisenforschung GmbH >> Max-Planck-Straße 1 >> D-40237 Düsseldorf >> Handelsregister B 2533 Amtsgericht Düsseldorf >> Geschäftsführung >> Prof. Dr. Gerhard Dehm >> Prof. Dr. Jörg Neugebauer >> Prof. Dr. Dierk Raabe >> Dr. Kai de Weldige >> Ust.-Id.-Nr.: DE 11 93 58 514 Steuernummer: 105 5891 1000 >> >> >> Please consider that invitations and e-mails of our institute are only valid if they end with …@mpie.de. If you are not sure of the validity please contact [email protected] >> >> Bitte beachten Sie, dass Einladungen zu Veranstaltungen und E-Mails >> aus unserem Haus nur mit der Endung …@mpie.de gültig sind. In Zweifelsfällen wenden Sie sich bitte an [email protected] >> ------------------------------------------------- >> ------------------------------------------------- Stay up to date and follow us on LinkedIn, Twitter and YouTube. Max-Planck-Institut für Eisenforschung GmbH Max-Planck-Straße 1 D-40237 Düsseldorf Handelsregister B 2533 Amtsgericht Düsseldorf Geschäftsführung Prof. Dr. Gerhard Dehm Prof. Dr. Jörg Neugebauer Prof. Dr. Dierk Raabe Dr. Kai de Weldige Ust.-Id.-Nr.: DE 11 93 58 514 Steuernummer: 105 5891 1000 Please consider that invitations and e-mails of our institute are only valid if they end with …@mpie.de. If you are not sure of the validity please contact [email protected] Bitte beachten Sie, dass Einladungen zu Veranstaltungen und E-Mails aus unserem Haus nur mit der Endung …@mpie.de gültig sind. In Zweifelsfällen wenden Sie sich bitte an [email protected] -------------------------------------------------
