[petsc-users] Shell preconditioner within a fieldsplit

Barry Smith bsmith at mcs.anl.gov
Mon Nov 14 00:02:18 CST 2016


   From the manual page for PCFieldSplitGetSubKSP()

   You must call KSPSetUp() before calling PCFieldSplitGetSubKSP().

   Please try this and let us know if it still doesn't call your PressureBlock().

    PETSc developers: we should figure out how to have it generate a very useful error message if the PCFieldSplitGetSubKSP() is called prematurely, currently it sets 

  ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFieldSplitGetSubKSP_C",PCFieldSplitGetSubKSP_FieldSplit);CHKERRQ(ierr);

  in PCCreate_FieldSplit() which is premature and will lead to errors. Presumably we should not set this composition until the setup is called?


   Barry



> On Nov 13, 2016, at 11:36 PM, Safin, Artur <aks084000 at utdallas.edu> wrote:
> 
> Hello,
> 
> What is the proper way to set up a shell preconditioner within a fielsplit? I have tried it on my own, but do not get the proper behavior. The relevant portion looks like this:
> 
> __________________________________________________________________
> // Global System
> KSPSetOperators(ksp, A, A);
> 
> // Skipped code..
> 
> 
> // Shell Preconditioner for the pressure sub-block
> KSP *subksp;
> PCFieldSplitGetSubKSP(pc, NULL, &subksp);
> 
> Mat pressureA;
> KSPSetType(subksp[0], "preonly");
> MatCreateShell(MPI_COMM_WORLD, n_local_P_dofs, n_local_P_dofs, , PETSC_DETERMINE, PETSC_DETERMINE, &pressureA);
> MatShellSetOperation(pressureA, MATOP_MULT, (void(*)(void)) PressureBlock);
> KSPSetOperators(subksp[0], pressureA, pressureA);
> 
> // Skipped code..
> 
> 
> KSPSetUp(ksp);
> KSPSolve(ksp, b, x);
> __________________________________________________________________
> 
> The fieldsplit component works fine; the solver however does not go into the custom function PressureBlock(), so I am curious as to what the correct approach is.
> 
> Best,
> 
> Artur



More information about the petsc-users mailing list