<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div><span>I am not sure if I understand you correctly. See page 83 of PETSc manual (revision 3.4). B1 and B2 are two preconditioner matrices. The full residual is updated after application of the first preconditioner:</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span>y = B1x</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande',
sans-serif; background-color: transparent; font-style: normal;"><span>w1 = x - Ay</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span>In my case, say A is 200 by 200, but B1 is 100 by 100, so y is 1 by 100. It seems to me we need a prolongation matrix P to make Ay possible, that is, w1 = x - APy. If this is the case, how can I pass P to PETSc?</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div
style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span>Thanks,</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span>Qin</span></div><div><br></div> <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1"> <font size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> Barry Smith <bsmith@mcs.anl.gov><br> <b><span style="font-weight: bold;">To:</span></b> Qin Lu <lu_qin_2000@yahoo.com> <br><b><span
style="font-weight: bold;">Cc:</span></b> petsc-users <petsc-users@mcs.anl.gov> <br> <b><span style="font-weight: bold;">Sent:</span></b> Saturday, June 28, 2014 2:44 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [petsc-users] Combining preconditioners<br> </font> </div> <div class="y_msg_container"><br><br clear="none"> With composite it updates the entire residual. Yes, a portion of the computations just make a zero update but as I said before part of a matrix vector product is generally much cheaper than a full preconditioner.<br clear="none"><br clear="none"> The field split preconditioner has code to update just portions of the residual, but don’t use it until you see that your preconditioner has very good convergence properties.<br clear="none"><br clear="none"> Barry<br clear="none"><div class="qtdSeparateBR"><br><br></div><div class="yqt4965570124" id="yqtfd66865"><br clear="none">On Jun 28, 2014,
at 2:13 PM, Qin Lu <<a shape="rect" ymailto="mailto:lu_qin_2000@yahoo.com" href="mailto:lu_qin_2000@yahoo.com">lu_qin_2000@yahoo.com</a>> wrote:<br clear="none"><br clear="none">> About 1, I don't get it. How does PETSc know what unknowns the first preconditioner solves? i.e., how does PETSc know the first preconditioner solves the unknowns with odd index rather than with even index? This info is necessary for updating the full residual, probably through a restriction (mapping) matrix/vector?<br clear="none">> <br clear="none">> Thanks,<br clear="none">> Qin<br clear="none">> <br clear="none">> From: Barry Smith <<a shape="rect" ymailto="mailto:bsmith@mcs.anl.gov" href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>><br clear="none">> To: Qin Lu <<a shape="rect" ymailto="mailto:lu_qin_2000@yahoo.com" href="mailto:lu_qin_2000@yahoo.com">lu_qin_2000@yahoo.com</a>> <br clear="none">> Cc: petsc-users <<a
shape="rect" ymailto="mailto:petsc-users@mcs.anl.gov" href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> <br clear="none">> Sent: Saturday, June 28, 2014 12:53 PM<br clear="none">> Subject: Re: [petsc-users] Combining preconditioners<br clear="none">> <br clear="none">> <br clear="none">> On Jun 28, 2014, at 12:43 PM, Qin Lu <<a shape="rect" ymailto="mailto:lu_qin_2000@yahoo.com" href="mailto:lu_qin_2000@yahoo.com">lu_qin_2000@yahoo.com</a>> wrote:<br clear="none">> <br clear="none">> > 1. About using PCCOMPOSITE: I didn't state correctly in my first email. Actually, the rank of first preconditioner matrix is, say, half of the rank of the full matrix (the latter is used as the second preconditioner matrix), and the first preconditioner solves half of the unknowns (say, unknowns with odd index), how can I let PETSc know this info, so that the solution of the first preconditioner can be applied to the full
matrix and update the full residual before applying the second preconditioner?<br clear="none">> > <br clear="none">> > In other words, does PCCOMPOSITE require that the ranks of all preconditioner matrices be the same as the full matrix?<br clear="none">> <br clear="none">> No. You don’t have to tell it anything special. <br clear="none">> > <br clear="none">> > 2. If I use PCFIELDSPLIT, does it also need PCCOMPOSITE to define multiple preconditioners?<br clear="none">> <br clear="none">> No field split is a different way of handling multiple preconditioners<br clear="none">> <br clear="none">> Barry<br clear="none">> <br clear="none">> <br clear="none">> <br clear="none">> <br clear="none">> > <br clear="none">> > Thanks a lot,<br clear="none">> > Qin<br clear="none">> > <br clear="none">> > From: Barry Smith <<a shape="rect"
ymailto="mailto:bsmith@mcs.anl.gov" href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>><br clear="none">> > To: Qin Lu <<a shape="rect" ymailto="mailto:lu_qin_2000@yahoo.com" href="mailto:lu_qin_2000@yahoo.com">lu_qin_2000@yahoo.com</a>> <br clear="none">> > Cc: petsc-users <<a shape="rect" ymailto="mailto:petsc-users@mcs.anl.gov" href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> <br clear="none">> > Sent: Friday, June 27, 2014 11:41 PM<br clear="none">> > Subject: Re: [petsc-users] Combining preconditioners<br clear="none">> > <br clear="none">> > <br clear="none">> > On Jun 27, 2014, at 11:22 PM, Qin Lu <<a shape="rect" ymailto="mailto:lu_qin_2000@yahoo.com" href="mailto:lu_qin_2000@yahoo.com">lu_qin_2000@yahoo.com</a>> wrote:<br clear="none">> > <br clear="none">> > > Hello,<br clear="none">> > > <br clear="none">> > > I would like to
combine two preconditioners in PETSc linear solver. The first preconditioner is user defined, the second one is just PETSc ILU, and the residual is updated after application of each preconditioner (the multiplicative form). There are two questions:<br clear="none">> > > <br clear="none">> > > 1. Shall I use PCShellSetApply to set the user defined preconditioner, and then use PCCompositeAddPC to combine the 2 preconditioners?<br clear="none">> > <br clear="none">> > Yes<br clear="none">> > <br clear="none">> > > 2. The user defined preconditioner only applies to part of the components of the unknowns, in other words, the rank of the first preconditioner matrix is less than the rank of the full matrix. How can I let PETSc know how to update the residual after the application of the first preconditioner? Can I define a routine of residual updating for PETSc?<br clear="none">> > <br clear="none">>
> At first just use PCCOMPOSITE and let PETSc compute the residual by doing the usual complete matrix-vector product. Usually the cost of the matrix vector product is much less then a preconditioner so it is not worth optimizing.<br clear="none">> > <br clear="none">> > If the composed preconditioner works very well and the shell PC affects only a small percentage of the components of the problem then you can switch to PCFIELDSPLIT which does support only updating a portion of the residual.<br clear="none">> > <br clear="none">> > Barry<br clear="none">> > <br clear="none">> > <br clear="none">> > > <br clear="none">> > > Many thanks for your help.<br clear="none">> > > <br clear="none">> > > Best Regards,<br clear="none">> > > Qin<br clear="none">> > <br clear="none">> > <br clear="none">> <br clear="none">> <br
clear="none"></div><br><br></div> </div> </div> </div></body></html>