[petsc-users] Preconditioning Matrix-free SNES, preconditioner update, PCView

Juris Vencels juris.vencels at gmail.com
Tue Mar 31 21:03:13 CDT 2015


Hello PETSc Users,

I am using Matrix-Free SNES solver with the following options
    PETSC_OPTIONS="ksp_type gmres -snes_monitor_short -snes_mf 
-user_precond"

and shell-ILU preconditioner that I create as following:

! ===============================

       call PCSetType(pc,PCSHELL,ierr)
       call PCShellSetUp
       call PCShellSetApply(pc,PCShellApply,ierr)
       call PCShellSetName(pc,"ShellPC",ierr)

! ===============================

   subroutine PCShellSetUp()
     implicit none

      call SetInitialMatrix   ! Assambles matrix A

      call PCCreate(PETSC_COMM_WORLD,mf_prec,ierr)
      call PCSetType(mf_prec,PCILU,ierr)
      call PCSetOperators(mf_prec,A,A,ierr)
      call PCSetUp(mf_prec,ierr)
      call PCShellSetName(mf_prec,"LinPC",ierr)

   end subroutine PCShellSetUp

! ===============================

   subroutine PCShellApply(pc_tmp,x_tmp,y_tmp,ierr)
     implicit none
     PC  :: pc_tmp
     Vec :: x_tmp,y_tmp
     PetscErrorCode :: ierr

     call PCApply(mf_prec,x_tmp,y_tmp,ierr)

   end subroutine PCShellApply

! ===============================

* If matrix A changes during a simulation, how can I update 
preconditioner? Is calling "PCSetUp(mf_prec,ierr)" enough?

* Function PCView prints out information about type and size of 
preconditioner. Can I view/get preconditioner matrix itself? I want to 
compare it with reference matrix.

If I try to MatView factored matrix:
     call PCFactorGetMatrix(mf_prec,pcmat,ierr)
     call MatView(pcmat, PETSC_VIEWER_STDOUT_SELF,ierr)

Then I get the following error:
     [0]PETSC ERROR: No viewers for factored matrix except ASCII info or 
info_detailed

Thanks!



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150331/8d1b7256/attachment.html>


More information about the petsc-users mailing list