[petsc-users] Retrieving a SubMatrix from a Matrix in parallel

Arthur Kurlej akurlej at gmail.com
Tue Jun 17 17:03:51 CDT 2014


Hi all,

I wish to extract a parallel AIJ submatrix (B) from another parallel AIJ
matrix (A), in particular, if I have an NxN matrix, I wish to extract the
first N-1 rows and N-1 columns of A.

I can do this perfectly fine when running my code sequentially using
ISCreateStride and MatGetSubMatrix like so:
ISCreateStride(PETSC_COMM_WORLD,N,1,1,&is);
MatGetSubMatrix(A,is,is,MAT_INITIAL_MATRIX,&B);

And it behaves as I would expect, but when running in parallel, the B
matrix increases past it's allocated size of N-1xN-1. I've pasted the
example of a simple example output below:


ORIGINAL SEQUENTIAL MATRIX
row 0: (0, 1)  (1, 2)  (2, 3)  (3, 4)
row 1: (0, 1)  (1, 2)  (2, 3)  (3, 4)
row 2: (0, 1)  (1, 2)  (2, 3)  (3, 4)
row 3: (0, 1)  (1, 2)  (2, 3)  (3, 4)
SEQUENTIAL SUBMATRIX
row 0: (0, 1)  (1, 2)  (2, 3)
row 1: (0, 1)  (1, 2)  (2, 3)
row 2: (0, 1)  (1, 2)  (2, 3)


ORIGINAL PARALLEL MATRIX
row 0: (0, 1)  (1, 2)  (2, 3)  (3, 4)
row 1: (0, 1)  (1, 2)  (2, 3)  (3, 4)
row 2: (0, 1)  (1, 2)  (2, 3)  (3, 4)
row 3: (0, 1)  (1, 2)  (2, 3)  (3, 4)
PARALLEL "SUBMATRIX"
row 0: (3, 1)  (4, 2)  (5, 3)
row 1: (3, 1)  (4, 2)  (5, 3)
row 2: (3, 1)  (4, 2)  (5, 3)
row 3: (3, 1)  (4, 2)  (5, 3)
row 4: (3, 1)  (4, 2)  (5, 3)
row 5: (3, 1)  (4, 2)  (5, 3)


I'm not really sure what is going on with the index set, and I would really
appreciate some help.


Thanks,
Arthur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140617/fac9066d/attachment.html>


More information about the petsc-users mailing list