<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div>  Marco,<div class=""><br class=""></div><div class="">     I have confirmed your results. </div><div class=""><br class=""></div><div class="">     Urgg, it appears we do not have something well documented. The removal of the null space only works for left preconditioned solvers and FGMRES only works with right preconditioning. Here is the reasoning. </div><div class=""><br class=""></div><div class="">     The Krylov space for left preconditioning is built from [r, BAr, (BA)^2 r, ...] and the solution space is built from this basis. If A has a null space of n then the left preconditioned Krylov methods simply remove n from the "full" Krylov space after applying each B preconditioner and the resulting "reduced" Krylov space has no components in the n directions hence the solution built by GMRES naturally has no component in the n.  </div><div class=""><br class=""></div><div class="">     But with right preconditioning the Krylov space is [s ABs (AB)^2 s, ....] We would need to remove B^-1 n from the Krylov space so that (A B) B^-1 n = 0 In general we don't have any way of applying B^-1 to a vector so we cannot create the appropriate "reduced" Krylov space. </div><div class=""><br class=""></div><div class="">     If I run with GMRES (which defaults to left preconditioner) and the options <span style="font-family: Menlo; font-size: 14px;" class="">./testPreconditioners -pc_type gamg -ksp_type gmres -ksp_monitor_true_residual -ksp_rtol 1.e-12 -ksp_view -mg_coarse_pc_type svd</span></div><div class=""><br class=""></div><div class=""><div>  Then  it handles the null space correctly and the solution has <span style="font-family: Menlo; font-size: 14px;" class="">Solution mean = 4.51028e-17</span></div><div><font face="Menlo" class=""><span style="font-size: 14px;" class=""><br class=""></span></font></div><div>Is there any reason to use FGMRES instead of GMRES? You just cannot use GMRES as the smoother inside GAMG if you use GMRES on the outside, but for pressure equations you don't want use such a strong smoother anyways.</div><div><br class=""></div><div>  Barry</div><div><br class=""></div><div>  I feel we should add some information to the documentation on the removal of the null space to the user's manual when using right preconditioning and maybe even have an error check in the code so that people don't fall into this trap. But I am not sure exactly what to do. When the A and B are both symmetric I think special stuff happens that doesn't require providing a null space; but I am not sure. </div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 21, 2022, at 12:41 PM, Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" class="">marco.cisternino@optimad.it</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">Thank you, Mark.<br class="">However, doing this with my toy code<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">mpirun -n 1 ./testpreconditioner -pc_type gamg -pc_gamg_use_parallel_coarse_grid_solver -mg_coarse_pc_type jacobi -mg_coarse_ksp_type cg<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">I get 16 inf elements. Do I miss anything?<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">Thanks again<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="IT" style="font-family: "Mulish Medium";" class="">Marco Cisternino</span><span lang="IT" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="IT" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class=""><o:p class=""> </o:p></span></div><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" class="">From:</span></b><span lang="EN-US" class=""><span class="Apple-converted-space"> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov" style="color: blue; text-decoration: underline;" class="">mfadams@lbl.gov</a>><span class="Apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>lunedì 21 marzo 2022 17:31<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" style="color: blue; text-decoration: underline;" class="">marco.cisternino@optimad.it</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" style="color: blue; text-decoration: underline;" class="">petsc-users@mcs.anl.gov</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [petsc-users] Null space and preconditioners<o:p class=""></o:p></span></div></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">And for GAMG you can use:<o:p class=""></o:p></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">-pc_gamg_use_parallel_coarse_grid_solver -mg_coarse_pc_type jacobi -mg_coarse_ksp_type cg<o:p class=""></o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Note if you are using more that one MPI process you can use 'lu' instead of 'jacobi'<o:p class=""></o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">If GAMG converges fast enough it can solve before the constant creeps in and works without cleaning in the KSP method.<o:p class=""></o:p></div></div></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div class=""><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">On Mon, Mar 21, 2022 at 12:06 PM Mark Adams <<a href="mailto:mfadams@lbl.gov" style="color: blue; text-decoration: underline;" class="">mfadams@lbl.gov</a>> wrote:<o:p class=""></o:p></div></div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0cm 0cm 0cm 6pt; margin-left: 4.8pt; margin-right: 0cm;" class=""><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">The solution for Neumann problems can "float away" if the constant is not controlled in some way because floating point errors can introduce it even if your RHS is exactly orthogonal to it.<o:p class=""></o:p></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">You should use a special coarse grid solver for GAMG but it seems to be working for you.<o:p class=""></o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I have lost track of the simply way to have the KSP solver clean the constant out, which is what you want.<o:p class=""></o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">can someone help Marco?<o:p class=""></o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Mark<o:p class=""></o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div></div></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div class=""><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">On Mon, Mar 21, 2022 at 8:18 AM Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" style="color: blue; text-decoration: underline;" class="">marco.cisternino@optimad.it</a>> wrote:<o:p class=""></o:p></div></div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0cm 0cm 0cm 6pt; margin-left: 4.8pt; margin-right: 0cm;" class=""><div class=""><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">Good morning,</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">I’m observing an unexpected (to me) behaviour of my code.</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">I tried to reduce the problem in a toy code here attached.<br class="">The toy code archive contains a small main, a matrix and a rhs.</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">The toy code solves the linear system and check the norms and the mean of the solution.</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">The problem into the matrix and the rhs is the finite volume discretization of the pressure equation of an incompressible NS solver.</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">It has been cooked as tiny as possible (16 cells!).</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">It is important to say that it is an elliptic problem with homogeneous Neumann boundary conditions only, for this reason the toy code sets a null space containing the constant.</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class=""> </span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">The unexpected (to me) behaviour is evident by launching the code using different preconditioners, using -pc-type <pctype><br class="">I tested using PCNONE (“none”), PCGAMG (“gamg”) and PCILU (“ilu”). The default solver is KSPFGMRES.</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">Using the three PC, I get 3 different solutions. It seems to me that they differ in the mean value, but GAMG is impressive.</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">PCNONE gives me the zero mean solution I expected. What about the others?</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class=""> </span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">Asking for residuals monitor, the ratio ||r||/||b|| shows convergence for PCNONE and PCILU (~10^-16), but it stalls for PCGAMG (~10^-4).</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">I cannot see why. Am I doing anything wrong or incorrectly thinking about the expected behaviour?</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class=""> </span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">Generalizing to larger mesh the behaviour is similar.</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class=""> </span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class="">Thank you for any help.</span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Light", serif;" class=""> </span><o:p class=""></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-family: "Mulish Medium";" class="">Marco Cisternino</span></div></div></div></blockquote></div></blockquote></div></div></div></blockquote></div><br class=""></div></body></html>