[petsc-users] Matrix-free preconditioner using shell matrix
Praveen C
cpraveen at gmail.com
Fri May 18 09:09:23 CDT 2018
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.
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 <jed at jedbrown.org> wrote:
>
> See examples at the bottom of the page.
>
> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCShellSetApply.html
>
> Praveen C <cpraveen at gmail.com> 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
More information about the petsc-users
mailing list