<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Jan 27, 2018 at 1:55 AM, Smith, Barry F. <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On Jan 26, 2018, at 3:39 AM, Stephen Wornom <<a href="mailto:stephen.wornom@inria.fr">stephen.wornom@inria.fr</a>> wrote:<br>
><br>
> I am disparate to implement  the petsc library gmres in an CFD code and need a little help to get going.<br>
><br>
> 23 years ago, gmres was implemented/written in the code by Y. Saad, modified by A. Malevsky, version February 1, 1995.<br>
<br>
   Off by a decade or so.<br>
><br>
> petsc, most likely started with the same version, added new solvers, ...etc and maintained and corrected bugs reported by users<br>
> and I would like to use the latest petsc version of gmres<br>
><br>
> Why?<br>
> Normally we have no convergence problems using gmres.<br>
> However sometimes gmres diverges instantaneously, no warning, just a negative density.<br>
<br>
   A negative density likely has nothing to do with your gmres.  You should run your code with a very tight GMRES convergence tolerance and see what happens and how and when the density goes negative; put in debugging code in your solver and your GEMRES that checks for negative density at each step. Does a tighter tolerance lead to a later time for the negative density?<br>
<br>
   GMRES is GMRES, I don't think converting to the PETSc GMRES will make an difference with your negative density problem.<br></blockquote><div><br></div><div>As long as we are making guesses, there are different algorithms for orthogonalization, some of which are better at dealing</div><div>with ill-conditioned matrices. If you are using classical Gram-Schmidt, you could try Householder or modified GS.</div><div><br></div><div>   Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> Our code is parallel mpi, unstructured, uses a low Mach preconditioner, FV Roe scheme.<br>
><br>
> Thus I would like to add an petsc option.<br>
> Would  someone outline, in detail, the steps that I need to follow?<br>
> I need all the encourage that I can get to add the option in the code.<br>
> petsc is installed on our computers<br>
> Thanks in advance,<br>
> Stephen<br>
><br>
><br>
>             IF ( petsc .EQ. 1 ) THEN<br>
> c petsc        CALL MatAssembleBegin<br>
> c petsc        CALL MatAssembleEnd<br>
> ... add steps<br>
>             ELSE<br>
>                CALL GMRESASR ! from our code<br>
>             ENDIF<br>
><br>
><br>
><br>
> This is from our code which may be useful information<br>
> c-----------------------------<wbr>------------------------------<wbr>------------<br>
> c flexible GMRES routine. This is a version of GMRES which allows a<br>
> c a variable preconditioner. Implemented with a reverse communication<br>
> c protocole for flexibility -<br>
> c DISTRIBUTED VERSION (USES DISTDOT FOR DDOT)<br>
> c explicit (exact) residual norms for restarts<br>
> c written by Y. Saad, modified by A. Malevsky, version February 1, 1995<br>
> c-----------------------------<wbr>------------------------------<wbr>------------<br>
> c This Is A Reverse Communication Implementation.<br>
> c-----------------------------<wbr>--------------------<br>
> c USAGE: (see also comments for icode below). CGMRES<br>
> c should be put in a loop and the loop should be active for as<br>
> c long as icode is not equal to 0. On RETURN fgmres will<br>
> c    1) either be requesting the new preconditioned vector applied<br>
> c       to wk1 in case icode.eq.1 (result should be put in wk2)<br>
> c    2) or be requesting the product of A applied to the vector wk1<br>
> c       in case icode.eq.2 (result should be put in wk2)<br>
> c    3) or be terminated in case icode .eq. 0.<br>
> c on entry always set icode = 0. So icode should be set back to zero<br>
> c upon convergence.<br>
> c-----------------------------<wbr>------------------------------<wbr>------------<br>
> c Here is a typical way of running fgmres:<br>
> c<br>
> c      icode = 0<br>
> c 1    continue<br>
> c      CALL fgmres (n,im,rhs,sol,i,vv,w,wk1, wk2,eps,maxits,iout,icode)<br>
> c<br>
> c      if (icode .eq. 1) then<br>
> c         CALL  precon(n, wk1, wk2)    <--- user's variable preconditioning<br>
> c         goto 1<br>
> c      else if (icode .ge. 2) then<br>
> c         CALL  matvec (n,wk1, wk2)    <--- user's matrix vector product.<br>
> c         goto 1<br>
> c      else<br>
> c         ----- done ----<br>
> c         .........<br>
><br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div>
</div></div>