Re: [petsc-users] how to check state of form residual of snes, for solving ksp or line search?

2024-02-24 Thread Yi Hu
Dear Barry, Thanks for the quick response. It indeed prints out all of my matrix values, so I need to set a threshold to get a sense of it. You are right that even I have a approximate Jacobian, the solution can converge in a quasi newton way.  ZjQcmQRYFpfptBannerStart

Re: [petsc-users] how to check state of form residual of snes, for solving ksp or line search?

2024-02-24 Thread Barry Smith
> On Feb 24, 2024, at 10: 50 AM, Yi Hu wrote: > > 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() ZjQcmQRYFpfptBannerStart This Message Is From an External Sender

Re: [petsc-users] how to check state of form residual of snes, for solving ksp or line search?

2024-02-24 Thread Yi Hu
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 ZjQcmQRYFpfptBannerStart

Re: [petsc-users] how to check state of form residual of snes, for solving ksp or line search?

2024-02-14 Thread Barry Smith
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. Barr

[petsc-users] how to check state of form residual of snes, for solving ksp or line search?

2024-02-14 Thread Yi Hu
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