[petsc-users] Assembling a matrix from submatrices

Jan Essert netz at essert.name
Mon Apr 22 08:14:03 CDT 2013


Dear list,

I would like to construct a large, sparse matrix M out of four submatrices.

(A B)
(C D)

These submatrices are obtained as results of MatMatMult multiplications of
other sparse matrices.
I have tried the following procedure for all four submatrices (here only
for A)

Mat A;
MatGetLocalSubMatrix(M, rows1, cols1, MAT_INITIAL_MATRIX, &A);
MatMatMult(A1, A2, MAT_INITIAL_MATRIX, PETSC_DEFAULT, &A);
MatRestoreLocalSubMatrix(M, rows1, cols1, &A);

These lines use appropriate ISs rows1 and cols1 which contain the first
rows and columns of M that correspond to the submatrix A.

This, however results in an empty matrix M.

What am I doing wrong?
If this is not the right approach, how can I do it better?
Manually copying the values from the results of the multiplications into M
takes forever, unfortunately..

Thanks for your help!
Jan



More information about the petsc-users mailing list