[petsc-users] Use of KSPSetOperators

Chung-Kan Huang ckhuangf at gmail.com
Tue Mar 17 16:26:56 CDT 2015


Hi,

I am a little confused about the statement in KSPSateOperators.


        KSP <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSP.html#KSP>/PCGetOperators
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCGetOperators.html#PCGetOperators>(ksp/pc,&mat,&pmat);
is equivalent to

          set size, type, etc of mat and pmat

         MatCreate
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreate.html#MatCreate>(comm,&mat);

        MatCreate
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreate.html#MatCreate>(comm,&pmat);

        KSP <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSP.html#KSP>/PCSetOperators
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCSetOperators.html#PCSetOperators>(ksp/pc,mat,pmat);

        PetscObjectDereference
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectDereference.html#PetscObjectDereference>((PetscObject
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObject.html#PetscObject>)mat);

        PetscObjectDereference
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectDereference.html#PetscObjectDereference>((PetscObject
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObject.html#PetscObject>)pmat);

          set size, type, etc of mat and pmat



In my case I want to construct preconditioner from P which will be
assembled differently from A.

So I only need to do
KSPSetOperators(ksp, A, P);
after A & P are created.

or do I need to also do
PCSetOperators(pc, A, P);
as well?

and what are those PetscObjectDereference
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectDereference.html#PetscObjectDereference>
about?

I have tried doing only
KSPSetOperators(ksp, A, P);

and I saw the performance of linear solver changed and I got right answer
but I am not sure is if it was doing the thing I think it was doing.

And is it anyway to know if it is doing what I am asking?

Thanks,

Kan
-- 

*Cheers*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150317/e0e1e56b/attachment.html>


More information about the petsc-users mailing list