<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">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/<wbr>008700.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><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/<wbr>petsc-current/docs/<wbr>manualpages/Sys/<wbr>PetscObjectComposeFunction.<wbr>html#<wbr>PetscObjectComposeFunction</a><br><br></div><div>with your MatShell object. <br><br>That is, instead of calling MatShellSetOperation(), call<br></div><div>ierr = PetscObjectComposeFunction(<wbr>myshell,"<font color="#666666">MatGetDiagonalBlock_<wbr>C"</font>, MatGetDiagonalBlock_MyShell);<wbr>CHKERRQ(ierr);</div><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">http://www.mcs.anl.gov/petsc/petsc-current/src/mat/interface/matrix.c.html#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>