Dear Developers,<br><br>I need to change "rtol" manually for each KSP linear solver in each SNES iteration (some sort of inexact Newton method).<br><br>I decided to use SNESSetConvergenceTest() as bellow:<br><br>
in main code:<br><br>ierr = SNESSetConvergenceTest( snes, SNESConvTest, PETSC_NULL, PETSC_NULL ); CHKERRQ( ierr );<br><br>in convergence function:<br><br>PetscErrorCode SNESConvTest( SNES snes, PetscInt it, PetscReal xn, PetscReal pn, PetscReal fn, SNESConvergedReason* res, void* ctx)
<br>{
<br> KSP ksp2;<br> PetscReal rtol, atol;<br> SNESGetKSP ( snes, &ksp2 );<br> KSPGetTolerances ( ksp2, &rtol, PETSC_NULL, PETSC_NULL, PETSC_NULL );<br> SNESGetTolerances ( snes, &atol, PETSC_NULL, PETSC_NULL, PETSC_NULL, PETSC_NULL );<br>
if( fn > 1e-3 ){
<br> rtol = 0.01;
<br> }else{
<br> rtol = 1e-5;
<br> }<br> KSPSetTolerances( ksp2, rtol, PETSC_NULL, PETSC_NULL, PETSC_NULL );
<br> if( fn < atol ){<br> *res = SNES_CONVERGED_FNORM_ABS;<br> return 0;<br> }else{<br> *res = SNES_CONVERGED_ITERATING;<br> } <br>}
<br><br>BUT I really don't know how to control the convergence criterion for SNES. So when I run my previous code with the new convergence test I received divergence error after "first iteration":<br><br>Linear solve did not converge due to DIVERGED_DTOL iterations 0<br>
Nonlinear solve did not converge due to DIVERGED_LINEAR_SOLVE<br><br>How should I possibly deal with this??<br><br>Thanks a lot,<br>BehZad<br>