On Tue, Mar 31, 2015 at 9:03 PM, Juris Vencels <[email protected]> wrote:
> 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: > This is not the canonical PETSc way to do this. We would suggest using the matrix A as the preconditioner matrix which you would give back in FormJacobian(). Then all the reforming would be handled automatically. Matt > ! =============================== > > 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! > > > > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
