<div dir="ltr"><div><div><div><div><div>Dear PETSc users,<br><br></div>I'm solving a linear system in KSP and trying to setup the solver in codes. But I feel strange because my codes don't converge unless I call KSPGMRESSetRestart twice.<br>
<br></div>My codes looks like<br><br>call KSPSetOperators ( pet_solv, pet_mat_mf_shell, pet_matp, DIFFERENT_NONZERO_PATTERN, ierpetsc )<br>call KSPSetType ( pet_solv, 'gmres', ierpetsc )<br>call KSPGMRESSetRestart ( pet_solv, 30, ierpetsc )<br>
call KSPGetPC ( pet_solv, pet_precon, ierpetsc )<br>call PCSetType ( pet_precon, 'asm', ierpetsc )<br>call PCASMSetOverlap ( pet_precon, 1, ierpetsc )<br>call KSPSetUp ( pet_solv, ierpetsc )<br>call PCASMGetSubKSP ( pet_precon, n_local, first_local, pet_solv_sub, ierpetsc )  ! n_local is one<br>
call KSPGetPC ( pet_solv_sub(1), pet_precon_sub, ierpetsc )<br>call PCSetType ( pet_precon_sub, 'jacobi', ierpetsc )<br>call PCJacobiSetUseRowMax ( pet_precon_sub, ierpetsc )<br>call KSPSetFromOptions ( pet_solv, ierpetsc )<br>
<span style="color:rgb(255,0,0)">call KSPGMRESSetRestart ( pet_solv, 29, ierpetsc )           ! adding this line, the codes converge</span><br>call KSPSolve ( pet_solv, pet_rhsp, pet_solup, ierpetsc )<br><br></div><span style="color:rgb(0,0,255)">runing with 1 CPU  WITHOUT the line with red color and the codes don't converge  </span><br>
<br>  <span style="color:rgb(0,0,255)">runtime options:   -ksp_monitor_true_residual -ksp_view</span><br>  0 KSP preconditioned resid norm 6.585278940829e+00 true resid norm 9.619278462343e-03 ||r(i)||/||b|| 1.000000000000e+00<br>
  1 KSP preconditioned resid norm 6.585278219510e+00 true resid norm 9.619278462343e-03 ||r(i)||/||b|| 1.000000000000e+00<br>  2 KSP preconditioned resid norm 2.198638170622e+00 true resid norm 1.365132713014e-01 ||r(i)||/||b|| 1.419163317039e+01<br>
  3 KSP preconditioned resid norm 1.599896387215e+00 true resid norm 1.445988845022e-01 ||r(i)||/||b|| 1.503219654865e+01<br>.......<br> 28 KSP preconditioned resid norm 4.478466011191e-01 true resid norm 1.529879309381e-01 ||r(i)||/||b|| 1.590430420920e+01<br>
 29 KSP preconditioned resid norm 4.398129572260e-01 true resid norm 1.530132924055e-01 ||r(i)||/||b|| 1.590694073413e+01<br> 30 KSP preconditioned resid norm 2.783227613716e+12 true resid norm 1.530369123550e-01 ||r(i)||/||b|| 1.590939621450e+01<br>
<br>KSP Object: 1 MPI processes<br>  type: gmres<br>    GMRES: restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement<br>    GMRES: happy breakdown tolerance 1e-30<br>  maximum iterations=10000, initial guess is zero<br>
  tolerances:  relative=1e-05, absolute=1e-50, divergence=10000<br>  left preconditioning<br>  using PRECONDITIONED norm type for convergence test<br>PC Object: 1 MPI processes<br>  type: asm<br>    Additive Schwarz: total subdomain blocks = 1, amount of overlap = 1<br>
    Additive Schwarz: restriction/interpolation type - RESTRICT<br>    [0] number of local blocks = 1<br>    Local solve info for each block is in the following KSP and PC objects:<br>    - - - - - - - - - - - - - - - - - -<br>
    [0] local block number 0, size = 22905<br>    KSP Object:    (sub_)     1 MPI processes<br>      type: preonly<br>      maximum iterations=10000, initial guess is zero<br>      tolerances:  relative=1e-05, absolute=1e-50, divergence=10000<br>
      left preconditioning<br>      using NONE norm type for convergence test<br>    PC Object:    (sub_)     1 MPI processes<br>      type: jacobi<br>      linear system matrix = precond matrix:<br>      Matrix Object:       1 MPI processes<br>
        type: seqbaij<br>        rows=22905, cols=22905, bs=5<br>        total: nonzeros=785525, allocated nonzeros=785525<br>        total number of mallocs used during MatSetValues calls =0<br>            block size is 5<br>
    - - - - - - - - - - - - - - - - - -<br>  linear system matrix followed by preconditioner matrix:<br>  Matrix Object:   1 MPI processes<br>    type: shell<br>    rows=22905, cols=22905<br>  Matrix Object:   1 MPI processes<br>
    type: seqbaij<br>    rows=22905, cols=22905, bs=5<br>    total: nonzeros=785525, allocated nonzeros=785525<br>    total number of mallocs used during MatSetValues calls =0<br>        block size is 5<br>     WARNING: zero iteration in iterative solver<br>
<br></div><span style="color:rgb(0,0,255)">runing with 1 CPU  WITH  the line with red color and the codes converge  </span><br><br><span style="color:rgb(0,0,255)">runtime options:   -ksp_monitor_true_residual -ksp_view</span><br>
  0 KSP preconditioned resid norm 6.585278940829e+00 true resid norm 9.619278462343e-03 ||r(i)||/||b|| 1.000000000000e+00<br>  1 KSP preconditioned resid norm 2.566248171026e+00 true resid norm 4.841043870812e-03 ||r(i)||/||b|| 5.032647604250e-01<br>
  2 KSP preconditioned resid norm 1.410418402651e+00 true resid norm 3.347509391208e-03 ||r(i)||/||b|| 3.480000505561e-01<br>  3 KSP preconditioned resid norm 9.665409287757e-01 true resid norm 2.289877121679e-03 ||r(i)||/||b|| 2.380508195748e-01<br>
  4 KSP preconditioned resid norm 4.469486152454e-01 true resid norm 1.283813398084e-03 ||r(i)||/||b|| 1.334625463968e-01<br>  5 KSP preconditioned resid norm 2.474889829653e-01 true resid norm 7.956009139680e-04 ||r(i)||/||b|| 8.270900120862e-02<br>
  ............<br> 24 KSP preconditioned resid norm 9.518780877620e-05 true resid norm 6.273993696172e-07 ||r(i)||/||b|| 6.522312167937e-05<br> 25 KSP preconditioned resid norm 6.837876679998e-05 true resid norm 4.612861071815e-07 ||r(i)||/||b|| 4.795433555514e-05<br>
 26 KSP preconditioned resid norm 4.864361942316e-05 true resid norm 3.394754589076e-07 ||r(i)||/||b|| 3.529115621682e-05<br>KSP Object: 1 MPI processes<br>  type: gmres<br>    GMRES: restart=29, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement<br>
    GMRES: happy breakdown tolerance 1e-30<br>  maximum iterations=10000, initial guess is zero<br>  tolerances:  relative=1e-05, absolute=1e-50, divergence=10000<br>  left preconditioning<br>  using PRECONDITIONED norm type for convergence test<br>
PC Object: 1 MPI processes<br>  type: asm<br>    Additive Schwarz: total subdomain blocks = 1, amount of overlap = 1<br>    Additive Schwarz: restriction/interpolation type - RESTRICT<br>    [0] number of local blocks = 1<br>
    Local solve info for each block is in the following KSP and PC objects:<br>    - - - - - - - - - - - - - - - - - -<br>    [0] local block number 0, size = 22905<br>    KSP Object:    (sub_)     1 MPI processes<br>      type: preonly<br>
      maximum iterations=10000, initial guess is zero<br>      tolerances:  relative=1e-05, absolute=1e-50, divergence=10000<br>      left preconditioning<br>      using NONE norm type for convergence test<br>    PC Object:    (sub_)     1 MPI processes<br>
      type: jacobi<br>      linear system matrix = precond matrix:<br>      Matrix Object:       1 MPI processes<br>        type: seqbaij<br>        rows=22905, cols=22905, bs=5<br>        total: nonzeros=785525, allocated nonzeros=785525<br>
        total number of mallocs used during MatSetValues calls =0<br>            block size is 5<br>    - - - - - - - - - - - - - - - - - -<br>  linear system matrix followed by preconditioner matrix:<br>  Matrix Object:   1 MPI processes<br>
    type: shell<br>    rows=22905, cols=22905<br>  Matrix Object:   1 MPI processes<br>    type: seqbaij<br>    rows=22905, cols=22905, bs=5<br>    total: nonzeros=785525, allocated nonzeros=785525<br>    total number of mallocs used during MatSetValues calls =0<br>
        block size is 5<br>     WARNING: zero iteration in iterative solver<br><br><br></div>What would be my error here? Thank you.<br></div>