<div dir="ltr"><div><div><div>Yeah. Thank you all. I think there are bugs in my function evaluation. I just wondering if I could guess where the bug might be from the residual history. I would check my function evaluation. Thank you very much.<br>
<br></div>I tried add -ksp_norm_type unpreconditioned, but got an error.<br><br>run with<br> -ksp_max_it 10 -ksp_gmres_restart 30 -ksp_monitor_true_residual  -ksp_converged_reason -ksp_view <span style="color:rgb(255,0,0)">-ksp_norm_type unpreconditioned  -ksp_pc_side right  -pc_type none</span><br>
</div><br></div>The error is <br>[0]PETSC ERROR: --------------------- Error Message ------------------------------------<br>[0]PETSC ERROR: No support for this operation for this object type!<br>[0]PETSC ERROR: KSP gmres does not support UNPRECONDITIONED with LEFT!<br>
[0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: Petsc Release Version 3.3.0, Patch 6, Mon Feb 11 12:26:34 CST 2013 <br>[0]PETSC ERROR: See docs/changes/index.html for recent updates.<br>
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.<br>[0]PETSC ERROR: See docs/index.html for manual pages.<br>[0]PETSC ERROR: ------------------------------------------------------------------------<br><br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 17, 2014 at 5:28 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">Song Gao <<a href="mailto:song.gao2@mail.mcgill.ca">song.gao2@mail.mcgill.ca</a>> writes:<br>
<br>
> Hello,<br>
><br>
> I am using KSP framework to solve the problem   A \Delta x = b in the<br>
> matrix free fashion. where A is the matrix free matrix. I have another<br>
> assembled matrix for preconditioning, but I'm NOT using it.  My code is not<br>
> working so I'm debugging it.<br>
> I run the code with options -ksp_pc_side left -ksp_max_it 10<br>
> -ksp_gmres_restart 30 -ksp_monitor_true_residual -pc_type none -ksp_view<br>
><br>
> I think if pc_type is none, the precondiitoned resid norm should equal to<br>
> true resid norm (Am I correct?). But this doesn't happen. So maybe it would<br>
> be helpful if I know how preconditioned resid norm and true resid norm are<br>
> computed.<br>
><br>
> Website says true resid norm is just b - A \Delta x.   But how is<br>
> preconditioned resid norm computed?<br>
<br>
</div>Just apply the preconditioner P^{-1} to the residual above.  In<br>
practice, it is usually computed indirectly via a recurrence in the<br>
Krylov method, but they should agree up to rounding error.<br>
<div class=""><br>
>   0 KSP preconditioned resid norm 9.619278462343e-03 true resid norm<br>
> 9.619278462343e-03 ||r(i)||/||b|| 1.000000000000e+00<br>
>   1 KSP preconditioned resid norm 9.619210849854e-03 true resid norm<br>
> 2.552369536916e+06 ||r(i)||/||b|| 2.653389801437e+08<br>
>   2 KSP preconditioned resid norm 9.619210847390e-03 true resid norm<br>
> 2.552458142544e+06 ||r(i)||/||b|| 2.653481913988e+08<br>
>   3 KSP preconditioned resid norm 9.619210847385e-03 true resid norm<br>
> 2.552458343191e+06 ||r(i)||/||b|| 2.653482122576e+08<br>
>   4 KSP preconditioned resid norm 9.619210847385e-03 true resid norm<br>
> 2.552458344014e+06 ||r(i)||/||b|| 2.653482123432e+08<br>
>   5 KSP preconditioned resid norm 9.619210847385e-03 true resid norm<br>
> 2.552458344015e+06 ||r(i)||/||b|| 2.653482123433e+08<br>
<br>
</div>Try the above with -ksp_norm_type unpreconditioned.  The output below<br>
claims there is no preconditioner, so the most likely cause is that your<br>
operator is nonlinear.  With MFFD, I would speculate that it is caused<br>
by your nonlinear function being discontinuous, or by reusing some<br>
memory without clearing it (thus computing nonsense after the first<br>
iteration).<br>
<div class="HOEnZb"><div class="h5"><br>
> Linear solve did not converge due to DIVERGED_ITS iterations 10<br>
> KSP Object: 1 MPI processes<br>
>   type: gmres<br>
>     GMRES: restart=30, using Classical (unmodified) Gram-Schmidt<br>
> Orthogonalization with no iterative refinement<br>
>     GMRES: happy breakdown tolerance 1e-30<br>
>   maximum iterations=10, initial guess is zero<br>
>   tolerances:  relative=1e-06, absolute=1e-50, divergence=100000<br>
>   left preconditioning<br>
>   using PRECONDITIONED norm type for convergence test<br>
> PC Object: 1 MPI processes<br>
>   type: none<br>
>   linear system matrix followed by preconditioner matrix:<br>
>   Matrix Object:   1 MPI processes<br>
>     type: mffd<br>
>     rows=22905, cols=22905<br>
>       Matrix-free approximation:<br>
>         err=1.49012e-08 (relative error in function evaluation)<br>
>         Using wp compute h routine<br>
>             Does not compute normU<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>
</div></div></blockquote></div><br></div>