<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 26 August 2016 at 14:34, Dave May <span dir="ltr"><<a href="mailto:dave.mayhem23@gmail.com" target="_blank">dave.mayhem23@gmail.com</a>></span> wrote:<br><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"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On 26 August 2016 at 14:14, Steven Dargaville <span dir="ltr"><<a href="mailto:dargaville.steven@gmail.com" target="_blank">dargaville.steven@gmail.com</a>></span> wrote:<br><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"><div><div>Hi all<br><br></div>I'm just wondering if there is any plans in the future for MatGetDiagonalBlock to support shell matrices by registering a user-implemented MATOP? MatGetDiagonal supports MATOP, but the block version of this does not. <br><br></div>I found a previous query on the user list which touched on this and mentioned that it would be easy to add:<br><div><div><div><br><a href="http://lists.mcs.anl.gov/pipermail/petsc-users/2011-May/008700.html" target="_blank">http://lists.mcs.anl.gov/piper<wbr>mail/petsc-users/2011-May/0087<wbr>00.html</a><br><br></div><div>I have implemented a matrix-free multigrid algorithm using shell operations in PETSc, and it would be very convenient to be able to provide a local shell Mat so I could apply local GMRES (or other matvec-based solvers) as a local block smoother. <br></div></div></div></div></blockquote><div><br></div></span><div>It looks like the thing you need to do is use PetscObjectComposeFunction() and not MatShellSetOperation()<br><br><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectComposeFunction.html#PetscObjectComposeFunction" target="_blank">http://www.mcs.anl.gov/petsc/p<wbr>etsc-current/docs/manualpages/<wbr>Sys/PetscObjectComposeFunction<wbr>.html#PetscObjectComposeFuncti<wbr>on</a><br><br></div><div>with your MatShell object. <br><br>That is, instead of calling MatShellSetOperation(), call<br></div><div>ierr = PetscObjectComposeFunction(mys<wbr>hell,"<font color="#666666">MatGetDiagonalBlock_C"</font>, MatGetDiagonalBlock_MyShell);C<wbr>HKERRQ(ierr);</div></div></div></div></blockquote><div><br></div><div>Oops - I forgot the cast, the above should be<br><br>ierr = PetscObjectComposeFunction((PetscObject)mys<wbr>hell,"<font color="#666666">MatGetDiagonalBlock_C"</font>, MatGetDiagonalBlock_MyShell);C<wbr>HKERRQ(ierr);<br></div><div> </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"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>where MatGetDiagonalBlock_MyShell is a function pointer to your method to get the diagonal block. <br><br>Important detail is that you don't change the string "MatGetDiagonalBlock_C". The method MatGetDiagonalBlock() does a function pointer query using this string. See<br><a href="http://www.mcs.anl.gov/petsc/petsc-current/src/mat/interface/matrix.c.html#MatGetDiagonalBlock" target="_blank">http://www.mcs.anl.gov/petsc/<wbr>petsc-current/src/mat/<wbr>interface/matrix.c.html#<wbr>MatGetDiagonalBlock</a><br><br><br></div><div>Thanks <br></div><div>Dave<br></div><div><br><br><br></div><div><br></div><div> </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"><div><div><div><br></div><div>Thanks!<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>Steven<br></div><div><br><br></div></font></span></div></div></div>
</blockquote></div><br></div></div>
</blockquote></div><br></div></div>