[petsc-users] using PCFieldSplitGetSubKSP in c++

Matthew Knepley knepley at gmail.com
Thu Mar 8 05:59:05 CST 2012


On Thu, Mar 8, 2012 at 3:17 AM, Klaij, Christiaan <C.Klaij at marin.nl> wrote:

> This may be a dumb question (new to c++), well anyway: I'm trying
> to get the sub KSP associated with the Schur complement S, in
> order to set the null space. This is the code:
>
>  KSP subksp[2];
>

Declare this as KSP *subksp;

   Matt


>  PetscInt n=2;
>  ierr = PCFieldSplitGetSubKSP(pc,&n,&subksp); CHKERRQ(ierr);
>  ierr = KSPSetNullSpace(subksp[1],subnullsp); CHKERRQ(ierr);
>
> It gives the following compiler error:
>
> error: argument of type "KSP (*)[2]" is incompatible with parameter of
> type "KSP **"
>    ierr = PCFieldSplitGetSubKSP(pc,&n,&subksp); CHKERRQ(ierr);
>                                       ^
> So I changed the code to:
>
>  KSP *subksp[2];
>  PetscInt n=2;
>  ierr = PCFieldSplitGetSubKSP(pc,&n,subksp); CHKERRQ(ierr);
>  ierr = KSPSetNullSpace(subksp[1],subnullsp); CHKERRQ(ierr);
>
> Now I get the error:
>
> error: argument of type "KSP *" is incompatible with parameter of type
> "KSP"
>    ierr = KSPSetNullSpace(subksp[1],subnullsp); CHKERRQ(ierr);
>                           ^
>
> What is the proper way to set the null space of the Schur
> complement? I already have the null space of the matrix [A00 A01,
> A10 A11], the null space of A11 - A10 inv(A00) A01 is clearly
> related and could perhaps be deduced somehow?
>
>
> dr. ir. Christiaan Klaij
> CFD Researcher
> Research & Development
> E mailto:C.Klaij at marin.nl
> T +31 317 49 33 44
>
> MARIN
> 2, Haagsteeg, P.O. Box 28, 6700 AA Wageningen, The Netherlands
> T +31 317 49 39 11, F +31 317 49 32 45, I www.marin.nl
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120308/0c1b90b2/attachment.htm>


More information about the petsc-users mailing list