[petsc-users] Help with KSPSetConvergenceTest
Edoardo alinovi
edoardo.alinovi at gmail.com
Sun May 7 08:21:35 CDT 2023
Hello guys,
Today I am about to write a custom convergence test for KSP doing the
following job:
- if the number of ksp iterations is less than a given threshold, iterate
until that threshold is met
- if the number of ksp iterations is bigger than the threshold, use the
standard convergence checks.
As far as I understood from the examples, this is the function I need to
use:
KSPSetConvergenceTest
<https://petsc.org/main/manualpages/KSP/KSPSetConvergenceTest/>(ksp,MyKSPConverged,0,PETSC_NULL_FUNCTION,ierr)
With MyKSPConverge a subroutine (I am in fortran) where my custom
checks are implemented.
Here is how I have coded MyKSPConverged:
* subroutine MyKSPConverged(ksp,n,rnorm,flag,dummy,ierr) KSP
ksp PetscErrorCode ierr PetscInt n,dummy
KSPConvergedReason flag PetscReal rnorm if (n>1) then
call KSPConvergedDefault(ksp, n, rnorm, flag, ierr) else
flag = 0 endif ierr = 0 end subroutine
MyKSPConverged*
However I get this error:
[0]PETSC ERROR: KSPSolve has not converged, reason DIVERGED_DTOL
which I believe to be triggered by *KSPConvergedDefault. *This is odd,
as this simulation converge perfectly if I comment ou my dodgy
convergence test.
*Do you have any advice for me?*
*thank you! *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230507/9e9c6c1a/attachment-0001.html>
More information about the petsc-users
mailing list