Calling function from outside of SNES
Dear Developers, Is there a clear way to call an independent function from outside of SNES context within the procedure of nonlinear solution? Regards, BehZad
On Wed, Apr 4, 2012 at 07:57, behzad baghapour <[email protected]>wrote:
Is there a clear way to call an independent function from outside of SNES context within the procedure of nonlinear solution?
What do you want to do? Monitoring, changing the system, etc?
Actually I want to change the system, applying some modifications to the solution after each Newton iteration.
On Wed, Apr 4, 2012 at 08:13, behzad baghapour <[email protected]>wrote:
Actually I want to change the system, applying some modifications to the solution after each Newton iteration.
in petsc-dev http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/SNES/SNESLineSearchS... or, in 3.2 http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESLineSea...
On Wed, Apr 4, 2012 at 08:33, behzad baghapour <[email protected]>wrote:
Thanks, Is it work with "-snes_ls basic" ?
Yes
I already applied PostCheck routine for SNES but this function is not called during the Newton iteration since "print to screen alarm" is not demonstrated. Is there a flag to activate postcheck, running code with prescribed option, etc? Thanks a lot
I could solve the problem by shifting the postCheck below the SNESSetFromOptions but still have another problem with passing defined context: All my calcualtions are saved into global FieldContext including flow-field variables. I passed it to PostCheck. I could apply my desired change on the context BUT the results came back to the original values (before postCheck function) and therefore my efferts to modify the Newton procedure did not achieved. How should I handle it? Thanks again.
On Thu, Apr 5, 2012 at 05:02, behzad baghapour <[email protected]>wrote:
I could solve the problem by shifting the postCheck below the SNESSetFromOptions but still have another problem with passing defined context:
All my calcualtions are saved into global FieldContext including flow-field variables. I passed it to PostCheck. I could apply my desired change on the context BUT the results came back to the original values (before postCheck function) and therefore my efferts to modify the Newton procedure did not achieved.
How should I handle it?
You will have to explain more completely what is happening. If you want the postcheck to modify a context, you have to make sure that it sees the same context. PETSc NEVER does anything with the context pointers, it just passes it through to the callbacks.
Thanks about your comment. I've got it. I think it is better to apply changes to the solution vector (x) obtained by SNES, then implement all what is gained to the my defined context at the end of the procedure.
participants (2)
-
behzad baghapour -
Jed Brown