<div dir="ltr">Hi Barry:<div><br></div><div>That explains and makes sense.</div><div><br></div><div>Suppose I have associated a Mat object with KSP, by KSPSetOperators in the beginning of a Newton-Raphson iteration, say.</div><div><br></div><div>Then in the following iteration steps, the entries in the Mat are updated. I only need to directly call KSPSolve without doing KSPSetOperators, since in KSPSolve the state of the Mat object is automatically detected and the PC will be reconstructed if necessary, correct?</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 21, 2020 at 6:28 PM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><br></div> Alex,<div><br></div><div> See my long email. The thing with nested preconditioners (like yours) is they have multiple PCSetUps(), possibly outer ones and inner ones. Each of these PC independently triggers a rebuild based on its own state, hence the inner PCSetUps will be triggered when you change the inner matrices (even when you don't call MatAssemblyBegin/End() on the MatNest. </div><div><br></div><div> In your case since the preconditioner seems to depend only on the two sub matrices the fact that PCSetUp() is not called on the MatNest is harmless, since that setup wouldn't do anything anyways. </div><div><br></div><div> For Schur complement based PCFieldsplits however the result maybe be wrong unless you call MatAssemblyBegin/End on the nest matrix since the outer setup actually does something</div><div><br></div><div> Barry</div><div><br><div><br><blockquote type="cite"><div>On Jul 21, 2020, at 8:16 PM, Alex Fleeter <<a href="mailto:luis.saturday@gmail.com" target="_blank">luis.saturday@gmail.com</a>> wrote:</div><br><div><div dir="ltr">If I call MatAssembly for individual sub-matrices, <div> MatAssemblyBegin(subA[ii], MAT_FINAL_ASSEMBLY);<br> MatAssemblyEnd(subA[ii], MAT_FINAL_ASSEMBLY);<br></div><div><br></div><div>then call KSPSetOperators, the PC setup is not called.</div><div><br></div><div>I have to call the assembly for the whole nest matrix </div><div> MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);<br> MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);<br></div><div>to trigger the setup of PC. </div><div><br></div><div>I found some comments in <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/nest/matnest.c" style="font-family:"Times New Roman";font-size:inherit;text-align:-webkit-center" target="_blank">matnest.c</a>, line 474-478: "<span style="color:rgb(178,34,34)">Note: split assembly will fail if the same block appears more than once (even indirectly through a nested</span></div><pre width="80"><a name="m_-5507306791521207123_line475">475: </a><font color="#B22222"> * sub-block). This could be fixed by adding a flag to <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/Mat.html#Mat" target="_blank">Mat</a> so that there was a way to check if a <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/Mat.html#Mat" target="_blank">Mat</a> was</font>
<a name="m_-5507306791521207123_line476">476: </a><font color="#B22222"> * already performing an assembly, but the result would by more complicated and appears to offer less</font>
<a name="m_-5507306791521207123_line477">477: </a><font color="#B22222"> * potential for diagnostics and correctness checking. Split assembly should be fixed once there is an</font>
<a name="m_-5507306791521207123_line478">478: </a><font color="#B22222"> * interface for libraries to make asynchronous progress in "user-defined non-blocking collectives"."</font></pre><pre width="80"><font color="#B22222">I guess the comment suggests calling matassembly for the big nest matrix after having setted values for individual sub-matrices, instead of calling matassembly for individual submatrices.</font></pre><pre width="80"><font color="#B22222"><br></font></pre><pre width="80"><font color="#B22222">Can you confirm that?</font></pre><pre width="80"><font color="#B22222"><br></font></pre></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 21, 2020 at 4:35 PM Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">KSPSetOperator tells the KSP that the PC should be resetup.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 21, 2020 at 3:45 PM Alex Fleeter <<a href="mailto:luis.saturday@gmail.com" target="_blank">luis.saturday@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi:<div><br></div><div>I want to ask under what circumstance will trigger a call for pc setup. </div><div><br></div><div>I call KSPSolve to solve with the same Mat object with different entry values each time. I can see that the pc setup is only called at the beginning of the first solve. </div><div><br></div><div>I tried to read the implementation, but quickly get lost...</div></div>
</blockquote></div>
</blockquote></div>
</div></blockquote></div><br></div></div></blockquote></div>