[petsc-users] Assembling a matrix from submatrices
Matthew Knepley
knepley at gmail.com
Mon Apr 22 09:28:34 CDT 2013
On Mon, Apr 22, 2013 at 9:14 AM, Jan Essert <netz at essert.name> wrote:
> 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);
>
MAT_INITIAL_MATRIX creates the matrix. You need MAT_RESUE_MATRIX.
Matt
> 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
>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130422/fc8bf00e/attachment.html>
More information about the petsc-users
mailing list