<div dir="ltr">Ok, I'm using MatGetSubMatrix() with the following piece of code<br><br>PetscErrorCode SampleShellPCSetUp(SampleShellPC *shell,Mat pmat,Vec x)<br>{<br> Mat *submat[4];<br> PetscErrorCode ierr;<br>
PetscInt N;<br> IS set1[4],set2[4]; <br> <br><br><br> ierr = VecGetSize(x,&N);CHKERRQ(ierr); <br> ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&set1[0]);CHKERRQ(ierr);<br> ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&set2[0]);CHKERRQ(ierr);<br>
ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&set1[1]);CHKERRQ(ierr);<br> ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&set2[1]);CHKERRQ(ierr);<br> ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&set1[2]);CHKERRQ(ierr);<br>
ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&set2[2]);CHKERRQ(ierr);<br> ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&set1[3]);CHKERRQ(ierr);<br> ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&set2[3]);CHKERRQ(ierr);<br>
ierr = MatGetSubMatrices(pmat,4,set1,set2,MAT_INITIAL_MATRIX,submat);CHKERRQ(ierr);<br><br>but it seems to get only the first of the subblocks,<br><br>am I using the correct syntax for the MatGetSubMatrices function?<br>
<br>Thank you<br><br><div class="gmail_quote">On Fri, Sep 5, 2008 at 2:42 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
You can extract matrix blocks using MatGetSubMatrix().<br>
<br>
Matt<br>
<div><div></div><div class="Wj3C7c"><br>
On Fri, Sep 5, 2008 at 6:50 AM, Michel Cancelliere<br>
<<a href="mailto:fernandez858@gmail.com">fernandez858@gmail.com</a>> wrote:<br>
> Hi All,<br>
><br>
> I am building a shell preconditioner, for implement that I should divide a<br>
> sparse matrix into four blocks of dimension N/2xN/2 (N size of the Matrix),<br>
> I took a look to src/mat/examples/tutorials/ex2 but it is for dense matrix.<br>
> There is a function for do that in Petsc? or another method for efficiently<br>
> implementation?<br>
><br>
> Thank you,<br>
><br>
> Michel Cancelliere<br>
><br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
What most experimenters take for granted before they begin their<br>
experiments is infinitely more interesting than any results to which<br>
their experiments lead.<br>
-- Norbert Wiener<br>
<br>
</font></blockquote></div><br></div>