[petsc-users] Creating PCFieldSplit Preconditioner in source code

Thomas Witkowski thomas.witkowski at tu-dresden.de
Mon Nov 19 07:48:36 CST 2012

Am 19.11.2012 14:45, schrieb Barry Smith:
> On Nov 19, 2012, at 1:29 AM, Thomas Witkowski <thomas.witkowski at tu-dresden.de> wrote:
>> In the implementation of my Navier-Stokes solver, I initialize the PCFieldSplit preconditioner in my source code (thus not on the command line) in the following way:
>>     PCSetType(pc, PCFIELDSPLIT);
>>     PCFieldSplitSetType(pc, PC_COMPOSITE_SCHUR);
>>     PCFieldSplitSetSchurFactType(pc, PC_FIELDSPLIT_SCHUR_FACT_FULL);
>>     ...
>>     KSPSetUp(ksp);
>>     KSP *subKsp;
>>     PetscInt nSubKsp;
>>     PCFieldSplitGetSubKSP(pc, &nSubKsp, &subKsp);
>>     KSP kspVelocity = subKsp[0];
>>     KSP kspSchur = subKsp[1];
>>     ...
>> And then kspVelocity and kspSchur are filled with appropriate options. The point is now, that to get the sub solver objects, I have to run KSPSetUp before. In this case, the sub solver objects are also initialized with some predefined options (block jacobi ILU), which I don't need and what takes some time and memory.
>      These are just little stubs, they don't take but a trivial amount of memory and time to create they are not complete solvers so you shouldn't worry about them.
>     Barry
Just the KSPSetUp takes 4 to 5 seconds, for no computation at all. I 
don't think, this is negligible. It destroys my parallel scaling of 
initializing the solver.
>> Is there any other way to get the sub solver objects before and to initialize than the outer solver correctly with the inner solver I have specified?
>> Thomas

More information about the petsc-users mailing list