On Tue, Mar 15, 2011 at 3:46 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@59a2.org">jed@59a2.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div class="im">On Tue, Mar 15, 2011 at 21:39, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>Here is the scenario. I have a FieldSplit solve with 4 splits. For the 4th split, I have<div>a good preconditioner matrix. In the linear case, KSP, I am just doing this:</div><div><br></div><div><div>    err = KSPSetUp(_ksp);</div>


<div>    err = KSPGetPC(_ksp, &pc);</div><div>    err = PCFieldSplitGetSubKSP(pc, &num, &ksps);</div><div><br></div><div>    MatStructure flag;</div><div>    err = KSPGetOperators(ksps[num-1], &A, PETSC_NULL, &flag);</div>


<div>    err = PetscObjectReference((PetscObject) A);</div><div>    err = KSPSetOperators(ksps[num-1], A, _precondMatrix, flag);</div><div>    err = PetscFree(ksps);</div></div></div></blockquote><div><br></div></div><div>
Yuck.</div><div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div></div>which works fine. However, if we embed this in a nonlinear solve, so that I now call</div>


<div><br></div><div><div>    err = SNESGetKSP(_snes, &ksp);</div><div>   <same code></div><div><br></div><div>then the PC matrix for the 4th split is ignored. This happens because SNESSolve_LS()</div><div>calls KSPSetOperators() right before the solve. This causes FS to pull out the same</div>


<div>matrices again and overwrite my special PC matrix.</div></div></div></blockquote><div><br></div></div><div>The preconditioning matrix for this piece should be put into the global preconditioning matrix, perhaps stored as a MatNest. Fieldsplit should take that matrix apart for preconditioning and it'll find the preconditioning matrix for this part. More tricky is dealing with auxiliary operators such as appear in approximate-commutator Schur complement preconditioners. The current method is punting, you PetscObjectCompose the auxiliary matrix.</div>

</div>
</blockquote></div><br>Really? That seems perverse. I have to build some global PC matrix, with pieces I do not even have. How is that going to happen? Is<div>this really how we want to handle it? Also, I really need this to work now. So baring some other idea, I am going to put something in</div>
<div>PETSc that lets me set this operator during the SNES loop.<br><div><br></div><div>   Matt<br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
</div></div>