The PC type PCCOMPOSITE allows one to form new preconditioners by combining already defined preconditioners and solvers. Combining preconditioners usually requires some experimentation to find a combination of preconditioners that works better than any single method. It is a tricky business and is not recommended until your application code is complete and running and you are trying to improve performance. In many cases using a single preconditioner is better than a combination; an exception is the multigrid/multilevel preconditioners (solvers) that are always combinations of some sort, see Section Multigrid Preconditioners .
Let B1 and B2 represent the application of two
preconditioners of type type1 and type2. The preconditioner
B = B1 + B2 can be obtained with
ierr = PCSetType(pc,PCCOMPOSITE); ierr = PCCompositeAddPC(pc,type1); ierr = PCCompositeAddPC(pc,type2);Any number of preconditioners may added in this way.
This way of combining preconditioners is called additive, since
the actions of the preconditioners are added together. This is the
default behavior. An alternative can be set with the option
ierr = PCCompositeSetType(PC pc,PCCompositeType PC_COMPOSITE_MULTIPLICATIVE);In this form the new residual is updated after the application of each preconditioner and the next preconditioner applied to the next residual. For example, with two composed preconditioners: B1 and B2; y = B x is obtained from
Loosely, this corresponds to a Gauss-Siedel iteration, while additive corresponds to a Jacobi like.
Under most circumstances the multiplicative form requires one-half the number of iterations as the additive form; but the multiplicative form does require the application of A inside the preconditioner.
In the multiplicative version, the calculation of the residual inside the
preconditioner can be done in two ways: using the original linear system matrix
or using the matrix used to build the preconditioners B1, B2, etc.
By default it uses the ``preconditioner matrix'', to use the true matrix use the
option
ierr = PCCompositeSetUseTrue(PC pc);The individual preconditioners can be accessed (in order to set options) via
ierr = PCCompositeGetPC(PC pc,int count,PC *subpc);For example, to set the first sub preconditioners to use ILU(1)
PC subpc; ierr = PCCompositeGetPC(pc,0,&subpc); ierr = PCILUSetFill(subpc,1);
These various options can also be set via the options database. For example, -pc_type composite -pc_composite_pcs jacobi,ilu causes the composite preconditioner to be used with two preconditioners: Jacobi and ILU. The option -pc_composite_type multiplicative initiates the multiplicative version of the algorithm, while -pc_composite_type additive the additive version. Using the true preconditioner is obtained with the option -pc_composite_true. One sets options for the subpreconditioners with the extra prefix -sub_N_ where N is the number of the subpreconditioner. For example, -sub_0_pc_ilu_fill 0.
PETSc also allows a preconditioner to be a complete linear solver. This is
achieved with the PCSLES type.
ierr = PCSetType(PC pc,PCSLES PCSLES); ierr = PCSLESGetSLES(pc,&sles); /* set any SLES/KSP/PC options */From the command line one can use 5 iterations of bi-CG-stab with ILU(0) preconditioning as the preconditioner with -pc_type sles -sub_pc_type ilu -sub_ksp_max_it 5 -sub_ksp_type bcgs.
By default the inner SLES preconditioner uses the outter ``preconditioner matrix'',
as the matrix to be solved in the linear system, to use the true matrix use the
option
ierr = PCSLESSetUseTrue(PC pc);at the command line with -pc_sles_true.
Naturally one can use a SLES preconditioner inside a composite preconditioner. For example, -pc_type composite -pc_composite_pcs ilu,sles -sub_1_pc_type jacobi -sub_1_ksp_max_it 10 uses two preconditioners: ILU(0) and 10 iterations of GMRES with Jacobi preconditioning. Though it is not clear whether one would ever wish to do such a thing.