[petsc-users] Use of KSPSetOperators
Barry Smith
bsmith at mcs.anl.gov
Tue Mar 17 16:46:54 CDT 2015
> On Mar 17, 2015, at 4:26 PM, Chung-Kan Huang <ckhuangf at gmail.com> wrote:
>
> Hi,
>
> I am a little confused about the statement in KSPSateOperators.
>
>
> KSP/PCGetOperators
> (ksp/pc,&mat,&pmat); is equivalent to
>
> set size, type, etc of mat and pmat
>
>
> MatCreate
> (comm,&mat);
>
> MatCreate
> (comm,&pmat);
>
> KSP/PCSetOperators
> (ksp/pc,mat,pmat);
>
> PetscObjectDereference((PetscObject
> )mat);
>
> PetscObjectDereference((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 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.
This is what you should be doing so it is fine. You can ignore all that other stuff.
Barry
>
> And is it anyway to know if it is doing what I am asking?
>
> Thanks,
>
> Kan
> --
> Cheers
>
More information about the petsc-users
mailing list