[petsc-users] using PCFieldSplitGetSubKSP in c++

Jed Brown jedbrown at mcs.anl.gov
Tue Mar 13 07:56:26 CDT 2012


On Tue, Mar 13, 2012 at 07:32, Klaij, Christiaan <C.Klaij at marin.nl> wrote:

> Thanks, I get the idea now and changed the code to:
>
>  KSP *subksp;
>   PetscInt n=2;
>  ierr = PCFieldSplitGetSubKSP(pc,&n,&subksp); CHKERRQ(ierr);
>
> which removes the compiler error but gives the following runtime
> error in MatSchurComplementGetKSP():
>
> [0]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [0]PETSC ERROR: Null argument, when expecting valid pointer!
> [0]PETSC ERROR: Null Object: Parameter # 1!
>

You have to have set the matrix and called PCSetUp() for this inner context
to have been created. This is an unfortunate property of nested methods
(with every programming system I know of), it's difficult to bootstrap so
that a certain inner object is configured without setting up more than is
strictly necessary. If it's just the constant null space, then you can do
it on the command line. Note that with petsc-dev, you can use
MatSetNullSpace() and it will be used by the KSP, thus avoiding the need to
drill down into the KSP like this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120313/cf948210/attachment.htm>


More information about the petsc-users mailing list