<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Barry, Dave,</p>
<p><br>
</p>
<p>Turns out both your suggestions were necessary to get the preconditioner working properly.</p>
<br>
Thank you for the help!
<div><br>
</div>
<div>Artur<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Dave May <dave.mayhem23@gmail.com><br>
<b>Sent:</b> Monday, November 14, 2016 1:20 AM<br>
<b>To:</b> Safin, Artur; petsc-users@mcs.anl.gov<br>
<b>Subject:</b> Re: [petsc-users] Shell preconditioner within a fieldsplit</font>
<div> </div>
</div>
<div>
<div style="white-space:pre-wrap">Damn - the last part of my email is wrong. You want to set the PCType to "mat". KSPType preonly is fine</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Mon, 14 Nov 2016 at 07:04, Dave May <<a href="mailto:dave.mayhem23@gmail.com" title="mailto:dave.mayhem23@gmail.com
Ctrl+Click or tap to follow the link">dave.mayhem23@gmail.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div class="gmail_msg" 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 class="gmail_msg">
<br class="gmail_msg">
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 class="gmail_msg">
<br class="gmail_msg">
<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCMAT.html#PCMAT" class="gmail_msg" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCMAT.html#PCMAT</a><br class="gmail_msg">
<br class="gmail_msg">
Thanks <br class="gmail_msg">
</div>
<div class="gmail_msg" style="white-space:pre-wrap">Dave</div>
<br class="gmail_msg">
<div class="gmail_quote gmail_msg">
<div dir="ltr" class="gmail_msg">On Mon, 14 Nov 2016 at 06:36, Safin, Artur <<a href="mailto:aks084000@utdallas.edu" class="gmail_msg" target="_blank">aks084000@utdallas.edu</a>> wrote:<br class="gmail_msg">
</div>
<blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr" class="gmail_msg">
<div id="m_-2644774550910493444m_8572052850160361036divtagdefaultwrapper" class="gmail_msg" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<div id="m_-2644774550910493444m_8572052850160361036divtagdefaultwrapper" class="gmail_msg" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<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 class="gmail_msg" style="font-size:12pt">Mat pressureA;</span><br class="gmail_msg">
</div>
<div class="gmail_msg">KSPSetType(subksp[0], "preonly");</div>
<div class="gmail_msg"><span class="gmail_msg" style="font-size:12pt">MatCreateShell(MPI_COMM_WORLD,
<span class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">
n_local_P_dofs</span>,</span><span class="gmail_msg" style="font-size:12pt"> n_local_P_dofs, , </span><span class="gmail_msg" style="font-size:12pt">PETSC_DETERMINE, <span class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">PETSC_DETERMINE</span></span>, &pressureA);</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-size:12pt">MatShellSetOperation(pressureA, MATOP_MULT, </span><span class="gmail_msg" style="font-size:12pt">(void(*)(void)) PressureBlock);</span></div>
<div class="gmail_msg">KSPSetOperators(subksp[0], pressureA, pressureA);</div>
<div id="m_-2644774550910493444m_8572052850160361036divtagdefaultwrapper" class="gmail_msg" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<br class="gmail_msg">
</div>
<span class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">
<p class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">
// 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_-2644774550910493444m_8572052850160361036divtagdefaultwrapper" class="gmail_msg" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<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 class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">__________________________________________________________________</span><br class="gmail_msg">
</p>
<p class="gmail_msg"><span class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><br class="gmail_msg">
</span></p>
<p class="gmail_msg"><span class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">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 class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><br class="gmail_msg">
</span></p>
<p class="gmail_msg"><span class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">Best,</span></p>
<p class="gmail_msg"><span class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><br class="gmail_msg">
</span></p>
<p class="gmail_msg"><span class="gmail_msg" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">Artur</span></p>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</body>
</html>