<div style="white-space:pre-wrap">Looks like you want the contents of your mat shell, specifically the op Ax, to define the action of the preconditioner.<br><br>You need to either create a PCShell (rather than a MatShell), and define the operation called by PCApply(), or keep you current shell but change "preonly" to "mat". <br><br><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCMAT.html#PCMAT">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCMAT.html#PCMAT</a><br><br>Thanks <br> Dave</div><br><div class="gmail_quote"><div dir="ltr">On Mon, 14 Nov 2016 at 06:36, Safin, Artur <<a href="mailto:aks084000@utdallas.edu">aks084000@utdallas.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="gmail_msg">
<div id="m_8572052850160361036divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg">
<div id="m_8572052850160361036divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg">
<p class="gmail_msg">Hello,</p>
<p class="gmail_msg"><br class="gmail_msg">
</p>
<p class="gmail_msg">What is the proper way to set up a shell preconditioner within a fielsplit? I have tried it on my own, but do not get the proper behavior. The relevant portion looks like this:</p>
<p class="gmail_msg"><br class="gmail_msg">
</p>
<p class="gmail_msg">__________________________________________________________________</p>
<p class="gmail_msg"></p>
<div class="gmail_msg">// Global System</div>
<div class="gmail_msg">KSPSetOperators(ksp, A, A);</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
// Skipped code..
<p class="gmail_msg"></p>
<p class="gmail_msg"><br class="gmail_msg">
</p>
<p class="gmail_msg"><br class="gmail_msg">
</p>
<p class="gmail_msg">// Shell Preconditioner for the pressure sub-block</p>
<p class="gmail_msg">KSP *subksp;</p>
<p class="gmail_msg"></p>
<div class="gmail_msg">PCFieldSplitGetSubKSP(pc, NULL, &subksp);</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg"><span style="font-size:12pt" class="gmail_msg">Mat pressureA;</span><br class="gmail_msg">
</div>
<div class="gmail_msg">KSPSetType(subksp[0], "preonly");</div>
<div class="gmail_msg"><span style="font-size:12pt" class="gmail_msg">MatCreateShell(MPI_COMM_WORLD, <span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg">
n_local_P_dofs</span>,</span><span style="font-size:12pt" class="gmail_msg"> n_local_P_dofs, , </span><span style="font-size:12pt" class="gmail_msg">PETSC_DETERMINE, <span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg">PETSC_DETERMINE</span></span>, &pressureA);</span></div>
<div class="gmail_msg"><span style="font-size:12pt" class="gmail_msg">MatShellSetOperation(pressureA, MATOP_MULT, </span><span style="font-size:12pt" class="gmail_msg">(void(*)(void)) PressureBlock);</span></div>
<div class="gmail_msg">KSPSetOperators(subksp[0], pressureA, pressureA);</div>
<div id="m_8572052850160361036divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg">
<br class="gmail_msg">
</div>
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg">
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg">// Skipped code..</p>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
</span></div>
<div id="m_8572052850160361036divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg">
<p class="gmail_msg"></p>
<p class="gmail_msg">KSPSetUp(ksp);<br class="gmail_msg">
</p>
<p class="gmail_msg">KSPSolve(ksp, b, x);<br class="gmail_msg">
</p>
<p class="gmail_msg"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg">__________________________________________________________________</span><br class="gmail_msg">
</p>
<p class="gmail_msg"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg"><br class="gmail_msg">
</span></p>
<p class="gmail_msg"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg">The fieldsplit component works fine; the solver however does not go into the custom function PressureBlock(), so I am curious as to what the correct approach is.</span></p>
<p class="gmail_msg"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg"><br class="gmail_msg">
</span></p>
<p class="gmail_msg"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg">Best,</span></p>
<p class="gmail_msg"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg"><br class="gmail_msg">
</span></p>
<p class="gmail_msg"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px" class="gmail_msg">Artur</span></p>
</div>
</div>
</div>
</blockquote></div>