[petsc-users] Can't retrieve inner KSP from Schur complement

Lucas Clemente Vella lvella at gmail.com
Mon May 29 15:24:03 CDT 2017


I want to set a custom convergence test for the inner KSPs of Schur
complement method, so I am using PCFieldSplitGetSubKSP() to get the inner
KSPs:

    int n_subksp;
    KSP *subksp = NULL;

    PCFieldSplitGetSubKSP(s->pc, &n_subksp, &subksp);
    assert(n_subksp == 2);

But I get a segmentation fault on MatSchurComplementGetKSP(). From file
src/ksp/ksp/utils/schurm.c (line 320):

PetscErrorCode MatSchurComplementGetKSP(Mat S, KSP *ksp)
{
  Mat_SchurComplement *Na;

  PetscFunctionBegin;
  PetscValidHeaderSpecific(S,MAT_CLASSID,1);
  PetscValidPointer(ksp,2);
  Na   = (Mat_SchurComplement*) S->data;
  *ksp = Na->ksp; // <<<<< segfaults on this line, 'Na' is an invalid
pointer...
  PetscFunctionReturn(0);
}

This is the stack trace given by valgrind:

==13559== Invalid read of size 8
==13559==    at 0x56B8780: MatSchurComplementGetKSP (schurm.c:320)
==13559==    by 0x55F5B08: PCFieldSplitGetSubKSP_FieldSplit_Schur(_p_PC*,
int*, _p_KSP***) (fieldsplit.c:1367)
==13559==    by 0x5605187: PCFieldSplitGetSubKSP (fieldsplit.c:1869)
==13559==    by 0x166305: set_singular_convergence_test (solver-petsc.c:293)
### irrelevant calls, from inside my program
==13559==  Address 0x6c0 is not stack'd, malloc'd or (recently) free'd
==13559==

I tried doing this operation both before and after MatAssembly*() calls,
and with both I get the same result. Petsc version is 3.7.5, installed from
Ubuntu repository. Is this a bug? Or I am doing it wrong?

-- 
Lucas Clemente Vella
lvella at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170529/7581fb96/attachment.html>


More information about the petsc-users mailing list