Praveen C <[email protected]> writes: > Thanks, I will check these out. > > I am solving a non-linear problem using TS. I will use -snes_mf so that > jacobian action is computed by petsc using finite differences. > > I am trying to use shell matrix for preconditioner P as follows.
You don't need to use a shell matrix to implement a shell preconditioner. When using a shell PC, you need to call KSPSetPC() -- you can unwrap that from TS -> SNES -> KSP. > call MatCreateShell(PETSC_COMM_WORLD, n, n, & > PETSC_DETERMINE, PETSC_DETERMINE, & > ctx, P, ierr); CHKERRQ(ierr) > call MatShellSetOperation(P, MATOP_MULT, ApplyPC, ierr); CHKERRQ(ierr) > call TSSetRHSJacobian(ts, P, P, RHSJacobian, ctx, ierr); CHKERRQ(ierr) > > Is ApplyPC supposed to do the following ? > > subroutine ApplyPC(P, x, y, ierr) > > ! Compute y = P^(-1) * x > > end subroutine ApplyPC > > Thanks > praveen > >> On 18-May-2018, at 7:23 PM, Jed Brown <[email protected]> wrote: >> >> See examples at the bottom of the page. >> >> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCShellSetApply.html >> >> Praveen C <[email protected]> writes: >> >>> Dear all >>> >>> I am looking for any example code that shows how to use my own matrix-free >>> preconditioner using a shell matrix. I am using TS to solve my problem. >>> >>> Thanks >>> praveen
