<div class="gmail_quote">On Fri, Mar 9, 2012 at 08:53, Abdul Hanan Sheikh <span dir="ltr">&lt;<a href="mailto:hanangul12@yahoo.co.uk">hanangul12@yahoo.co.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="color:#000;background-color:#fff;font-family:verdana,helvetica,sans-serif;font-size:10pt"><div><span><br></span></div><div> </div><div><span style="color:rgb(0,0,255)"><span style="font-family:verdana,helvetica,sans-serif"><span style="font-family:lucida console,sans-serif"></span></span></span><span style="color:rgb(0,0,255)"><span style="font-family:verdana,helvetica,sans-serif"></span></span></div>
<div><br><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;margin-top:5px;padding-left:5px">  <div style="font-family:verdana,helvetica,sans-serif;font-size:10pt"> <div style="font-family:times new roman,new york,times,serif;font-size:12pt">
 <div dir="ltr"> <font face="Arial"><div class="im"> <hr size="1">  <b><span style="font-weight:bold">From:</span></b> Jed Brown &lt;<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>&gt;<br> <b><span style="font-weight:bold">To:</span></b> Abdul Hanan Sheikh
 &lt;<a href="mailto:hanangul12@yahoo.co.uk" target="_blank">hanangul12@yahoo.co.uk</a>&gt; <br><b><span style="font-weight:bold">Cc:</span></b> &quot;<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>&quot; &lt;<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>&gt; <br>
 </div><b><span style="font-weight:bold">Sent:</span></b> Friday, 9 March 2012, 14:08<div class="im"><br> <b><span style="font-weight:bold">Subject:</span></b> Re: [petsc-users] Projection preconditioner as PCMG<br> </div>
</font> </div> <br><div><div><div class="im">On Fri, Mar 9, 2012 at 05:16, Abdul Hanan Sheikh <span dir="ltr">&lt;<a rel="nofollow" href="mailto:hanangul12@yahoo.co.uk" target="_blank">hanangul12@yahoo.co.uk</a>&gt;</span> wrote:<br>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="color:#000;background-color:#fff;font-family:verdana,helvetica,sans-serif;font-size:10pt"><div><span>Dear, </span></div><div><br><span></span></div><div><span>To my earlier querry: <br></span></div><div>

<div><br><span></span></div><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>What if I want to approximate my all coarse matrices with any Krylov iteration ?</div></blockquote></div>
<div>

reply: <br></div><div><div>The methods on each 
level are independent, you can set them with -mg_coarse_ksp_type gmres 
-mg_levels_1_ksp_type cg -mg_levels_1_ksp_max_it 100 
-mg_levels_2_ksp_type minres ... <br></div></div><div> <br>This command line option changes the ksp_type on both ksp_pre and ksp_post (pre and post smoothing) . <br>Where as I need to fix the ksp_post_type as RICHARDSON to get my Prec = C + I - AC ; <br>

</div></div></div></blockquote><div><br></div></div><div><div class="im">Do you want this on every level or still just the finest?<br></div><span style="color:rgb(0,0,255)">I need this on every level.</span></div></div></div>
</div></div></blockquote></div></div></div></blockquote><div>You can set each with code or you can do it all with the following options. Some notes:</div><div><br></div><div>1. I use Chebychev instead of Richardson because I don&#39;t like tuning Richardson. The option -ksp_richardson_self_scale make the preconditioner nonlinear, in which case we&#39;d have to use FGMRES or GCR on the outside. Chebychev(1) is equivalent to Richardson with some damping factor. I found the Chebychev bounds (3,9) by running with -mg_levels_ksp_chebychev_estimate_eigenvalues 0,0.3,0,1.1 which targets the upper end of the spectrum (from 0.3*maxeig to 1.1*maxeig where maxeig is an estimate of the largest eigenvalue on each level). I ran with -snes_view and noticed that those bounds happened to be about the same on all levels, so I just set them directly. You can translate that to a Richardson relaxation if you like, but it tends to be more fragile.</div>
<div><br></div><div>2. The unpreconditioned norm gives much more accurate condition number estimates here.</div><div><br></div><div>3. You can also do Kaskade multigrid (which is exactly what you are asking for) with -pc_mg_smoothdown 0 -pc_mg_smoothup 1.</div>
<div><br></div><div>4. If you have variable coefficients, you will need to use the diagonal in the Richardson smoother for scaling (-mg_levels_pc_type jacobi). Remember that this will force you to recompute your Chebychev/Richardson bounds (or keep doing it automatically with -mg_levels_ksp_chebychev_estimate_eigenvalues 0,0.3,0,1.1).</div>
<div><br></div><div><div><font face="&#39;courier new&#39;, monospace">$ ./ex5 -da_grid_x 257 -da_grid_y 257 -snes_max_it 1 -ksp_type gmres -ksp_norm_type unpreconditioned -ksp_monitor_singular_value -ksp_compute_eigenvalues -pc_type mg -pc_mg_levels 9 -pc_mg_type kaskade -mg_levels_ksp_type chebychev -mg_levels_ksp_chebychev_eigenvalues 3,9 -mg_levels_pc_type none</font></div>
<div><font face="&#39;courier new&#39;, monospace">    0 KSP Residual norm 1.062542528908e+00 % max 1.000000000000e+00 min 1.000000000000e+00 max/min 1.000000000000e+00</font></div><div><font face="&#39;courier new&#39;, monospace">    1 KSP Residual norm 2.376610964454e-01 % max 1.001957907202e+00 min 1.001957907202e+00 max/min 1.000000000000e+00</font></div>
<div><font face="&#39;courier new&#39;, monospace">    2 KSP Residual norm 4.282525183085e-02 % max 1.139043558191e+00 min 8.730762970080e-01 max/min 1.304632323767e+00</font></div><div><font face="&#39;courier new&#39;, monospace">    3 KSP Residual norm 4.732778291888e-03 % max 1.148710370654e+00 min 7.632757295550e-01 max/min 1.504974318158e+00</font></div>
<div><font face="&#39;courier new&#39;, monospace">    4 KSP Residual norm 7.292121371221e-04 % max 1.148751387861e+00 min 7.091101704841e-01 max/min 1.619990003919e+00</font></div><div><font face="&#39;courier new&#39;, monospace">    5 KSP Residual norm 8.739575412872e-05 % max 1.152691180981e+00 min 6.760500858171e-01 max/min 1.705038140166e+00</font></div>
<div><font face="&#39;courier new&#39;, monospace">    6 KSP Residual norm 1.511456466330e-05 % max 1.154316560884e+00 min 6.659327122249e-01 max/min 1.733383177750e+00</font></div><div><font face="&#39;courier new&#39;, monospace">    7 KSP Residual norm 2.020623105869e-06 % max 1.154629497508e+00 min 6.591981750318e-01 max/min 1.751566586865e+00</font></div>
<div><font face="&#39;courier new&#39;, monospace">Iteratively computed eigenvalues</font></div><div><font face="&#39;courier new&#39;, monospace">0.659531 + 0i</font></div><div><font face="&#39;courier new&#39;, monospace">0.742062 + 0i</font></div>
<div><font face="&#39;courier new&#39;, monospace">0.815314 + 0i</font></div><div><font face="&#39;courier new&#39;, monospace">0.96316 + 0.0106016i</font></div><div><font face="&#39;courier new&#39;, monospace">0.96316 - 0.0106016i</font></div>
<div><font face="&#39;courier new&#39;, monospace">1.08027 + 0i</font></div><div><font face="&#39;courier new&#39;, monospace">1.11294 + 0i</font></div></div><div><font face="&#39;courier new&#39;, monospace"><br></font></div>
<div><div><font face="&#39;courier new&#39;, monospace">$ ./ex5 -da_grid_x 257 -da_grid_y 257 -snes_max_it 1 -ksp_type gmres -ksp_norm_type unpreconditioned -ksp_monitor_singular_value -ksp_compute_eigenvalues -pc_type mg -pc_mg_levels 9 -pc_mg_type multiplicative -mg_levels_ksp_type chebychev -mg_levels_ksp_chebychev_eigenvalues 3,9 -mg_levels_pc_type none</font></div>
<div><font face="&#39;courier new&#39;, monospace">    0 KSP Residual norm 1.062542528908e+00 % max 1.000000000000e+00 min 1.000000000000e+00 max/min 1.000000000000e+00</font></div><div><font face="&#39;courier new&#39;, monospace">    1 KSP Residual norm 3.178344085522e-02 % max 9.704936480137e-01 min 9.704936480137e-01 max/min 1.000000000000e+00</font></div>
<div><font face="&#39;courier new&#39;, monospace">    2 KSP Residual norm 1.968390067011e-03 % max 9.897660772730e-01 min 9.220434626490e-01 max/min 1.073448397356e+00</font></div><div><font face="&#39;courier new&#39;, monospace">    3 KSP Residual norm 1.145527676866e-04 % max 9.992147688651e-01 min 8.443712510420e-01 max/min 1.183383218735e+00</font></div>
<div><font face="&#39;courier new&#39;, monospace">    4 KSP Residual norm 5.642680559393e-06 % max 1.001387939323e+00 min 8.242353430425e-01 max/min 1.214929628747e+00</font></div><div><font face="&#39;courier new&#39;, monospace">Iteratively computed eigenvalues</font></div>
<div><font face="&#39;courier new&#39;, monospace">0.824026 + 0i</font></div><div><font face="&#39;courier new&#39;, monospace">0.918072 + 0i</font></div><div><font face="&#39;courier new&#39;, monospace">0.968702 + 0i</font></div>
<div><font face="&#39;courier new&#39;, monospace">1.00085 + 0i</font></div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:verdana,helvetica,sans-serif;font-size:10pt">
<div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;margin-top:5px;padding-left:5px"><div style="font-family:verdana,helvetica,sans-serif;font-size:10pt"><div style="font-family:times new roman,new york,times,serif;font-size:12pt">
<div><div><div><br></div><div class="im"><div> </div><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="color:#000;background-color:#fff;font-family:verdana,helvetica,sans-serif;font-size:10pt"><div><br>If adapt pre_smoother as follows : <br><br>ierr = MGGetSmootherDown(pcmg,lev,&amp;ksp_pre); CHKERRQ(ierr); <br>

</div>ierr = KSPSetType(ksp_pre, KSPGMRES);CHKERRQ(ierr);<br><br>Does ONLY setting pre_smoother as GMRES means that GMRES iterates on coarse matrix at level = lev ? <br></div></div></blockquote><span style="color:rgb(0,0,255)"><br>
</span><div>Yes, this will only affect the pre-smoother (so it will then go to the next coarser grid, come back, and do a post-smoother). You may have to increase the number of iterations. I strongly recommend configuring the solver using the command line and checking that it is the method you intended by reading the output of -ksp_view.</div>

</div></div>
</div><span style="color:rgb(0,0,255)">Yes I always see what Multilevel solver do by -ksp_view.. Thanks a lot. </span><br><br> </div> </div> </blockquote></div>   </div></div></blockquote></div><br>