Hi All,

Can I control KSP solver iteration by user defined criteria? I would like to check both preconditioned residual norm and true residual norm in every iteration, and force the solver to stop iteration if either criteria matches.

If using KSPSetConvergenceTest, can I get the true residual norm directly from a function or shall I compute it in the user-defined convergence function:

      call KSPBuildSolution(ksp,PETSC_NULL_OBJECT,x,ierr)
      call KSPGetRhs(ksp, b, ierr)
call KSPGetOperators(ksp,a,PETSC_NULL_OBJECT ,PETSC_NULL_OBJECT, ierr)
      call MatMult(a, x, u, ierr)
      call VecAXPY(u, -1.0d0, b, ierr)
      call VecNormBegin(u, Norm_2, rnorm_true, ierr)
      call VecNormEnd(u, Norm_2, rnorm_true, ierr)

Thanks and regards,

Danyang

Reply via email to