[petsc-dev] SNESSetKSP and SNESDestroy

Pierre Jolivet pierre.jolivet at enseeiht.fr
Thu May 30 05:07:54 CDT 2019


Hello,
I’m doing a continuation loop with something like:
KSP ksp;
KSPSetUp(ksp);
while(cond) {
	SNES snes;
	SNESCreate(&snes);
	SNESSetKSP(snes, &ksp);
	SNESSolve(snes);
	SNESDestroy(&snes);
}

For the first iteration, everything is OK.
After that, it looks like SNESDestroy is messing up with my outer-defined KSP(*), i.e., for the code to work I need to comment out the SNESDestroy.
Is this the expected behavior? (if not, I’ll provide a MWE)
How to fix this properly, without having leaks by not destroying the inner-defined SNESes?

Thanks in advance,
Pierre

(*) to the outer-defined KSP is attached a PCFIELDSPLIT, first SNESSolve, everything OK:
PC Object: 1 MPI processes
  type: fieldsplit
    FieldSplit with MULTIPLICATIVE composition: total splits = 2

Second SNESSolve:
[0]PETSC ERROR: PCFieldSplitSetDefaults() Unhandled case, must have at least two fields, not 1


More information about the petsc-dev mailing list