<div dir="ltr">Ok, I&#39;m using MatGetSubMatrix() with the following piece of code<br><br>PetscErrorCode SampleShellPCSetUp(SampleShellPC *shell,Mat pmat,Vec x)<br>{<br>&nbsp; Mat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *submat[4];<br>&nbsp; PetscErrorCode ierr;<br>
&nbsp; PetscInt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; N;<br>&nbsp; IS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set1[4],set2[4]; <br>&nbsp; <br><br><br>&nbsp; ierr = VecGetSize(x,&amp;N);CHKERRQ(ierr); <br>&nbsp; ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&amp;set1[0]);CHKERRQ(ierr);<br>&nbsp; ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&amp;set2[0]);CHKERRQ(ierr);<br>
&nbsp; ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&amp;set1[1]);CHKERRQ(ierr);<br>&nbsp; ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&amp;set2[1]);CHKERRQ(ierr);<br>&nbsp; ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&amp;set1[2]);CHKERRQ(ierr);<br>
&nbsp; ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&amp;set2[2]);CHKERRQ(ierr);<br>&nbsp; ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&amp;set1[3]);CHKERRQ(ierr);<br>&nbsp; ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&amp;set2[3]);CHKERRQ(ierr);<br>
&nbsp; 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">&lt;<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>&gt;</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>
 &nbsp; Matt<br>
<div><div></div><div class="Wj3C7c"><br>
On Fri, Sep 5, 2008 at 6:50 AM, Michel Cancelliere<br>
&lt;<a href="mailto:fernandez858@gmail.com">fernandez858@gmail.com</a>&gt; wrote:<br>
&gt; Hi All,<br>
&gt;<br>
&gt; I am building a shell preconditioner, for implement that I should divide a<br>
&gt; sparse matrix into four blocks of dimension N/2xN/2 (N size of the Matrix),<br>
&gt; I took a look to src/mat/examples/tutorials/ex2 but it is for dense matrix.<br>
&gt; There is a function for do that in Petsc? or another method for efficiently<br>
&gt; implementation?<br>
&gt;<br>
&gt; Thank you,<br>
&gt;<br>
&gt; Michel Cancelliere<br>
&gt;<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>