[petsc-users] Matrix-free preconditioner using shell matrix
Jed Brown
jed at jedbrown.org
Fri May 18 09:16:31 CDT 2018
Praveen C <cpraveen at gmail.com> 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 <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