I am disparate to implement the petsc library gmres in an CFD code and need a 
little help to get going. 

23 years ago, gmres was implemented/written in the code by Y. Saad, modified by 
A. Malevsky, version February 1, 1995. 

petsc, most likely started with the same version, added new solvers, ...etc and 
maintained and corrected bugs reported by users 
and I would like to use the latest petsc version of gmres 

Why? 
Normally we have no convergence problems using gmres. 
However sometimes gmres diverges instantaneously, no warning, just a negative 
density. 
Our code is parallel mpi, unstructured, uses a low Mach preconditioner, FV Roe 
scheme. 

Thus I would like to add an petsc option. 
Would someone outline, in detail, the steps that I need to follow? 
I need all the encourage that I can get to add the option in the code. 
petsc is installed on our computers 
Thanks in advance, 
Stephen 


IF ( petsc .EQ. 1 ) THEN 
c petsc CALL MatAssembleBegin 
c petsc CALL MatAssembleEnd 
... add steps 
ELSE 
CALL GMRESASR ! from our code 
ENDIF 



This is from our code which may be useful information 
c----------------------------------------------------------------------- 
c flexible GMRES routine. This is a version of GMRES which allows a 
c a variable preconditioner. Implemented with a reverse communication 
c protocole for flexibility - 
c DISTRIBUTED VERSION (USES DISTDOT FOR DDOT) 
c explicit (exact) residual norms for restarts 
c written by Y. Saad, modified by A. Malevsky, version February 1, 1995 
c----------------------------------------------------------------------- 
c This Is A Reverse Communication Implementation. 
c------------------------------------------------- 
c USAGE: (see also comments for icode below). CGMRES 
c should be put in a loop and the loop should be active for as 
c long as icode is not equal to 0. On RETURN fgmres will 
c 1) either be requesting the new preconditioned vector applied 
c to wk1 in case icode.eq.1 (result should be put in wk2) 
c 2) or be requesting the product of A applied to the vector wk1 
c in case icode.eq.2 (result should be put in wk2) 
c 3) or be terminated in case icode .eq. 0. 
c on entry always set icode = 0. So icode should be set back to zero 
c upon convergence. 
c----------------------------------------------------------------------- 
c Here is a typical way of running fgmres: 
c 
c icode = 0 
c 1 continue 
c CALL fgmres (n,im,rhs,sol,i,vv,w,wk1, wk2,eps,maxits,iout,icode) 
c 
c if (icode .eq. 1) then 
c CALL precon(n, wk1, wk2) <--- user's variable preconditioning 
c goto 1 
c else if (icode .ge. 2) then 
c CALL matvec (n,wk1, wk2) <--- user's matrix vector product. 
c goto 1 
c else 
c ----- done ---- 
c ......... 

Reply via email to