Discussion:
[petsc-users] Global matrix from global sub-matrices
Bikash Kanungo
2015-05-05 20:34:04 UTC
Permalink
Hi,

I have four global matrices: A (mxm), B (mxn), C (nxm) and D (nxn). All of
these are of type MATMPIAIJ (sparse parallel matrix) created using number
of global rows and columns. I want to construct an (m+n)x(m+n) global
matrix called M which would have A, B, C and D as its sub-matrices in
clockwise fashion starting from A at the upper-left. What can be the best
way to construct M from A, B, C and D sub-matrices?

Thanks,
Bikash
--
Bikash S. Kanungo
PhD Student
Computational Materials Physics Group
Mechanical Engineering
University of Michigan
Jed Brown
2015-05-05 20:38:58 UTC
Permalink
Post by Bikash Kanungo
Hi,
I have four global matrices: A (mxm), B (mxn), C (nxm) and D (nxn). All of
these are of type MATMPIAIJ (sparse parallel matrix) created using number
of global rows and columns. I want to construct an (m+n)x(m+n) global
matrix called M which would have A, B, C and D as its sub-matrices in
clockwise fashion starting from A at the upper-left. What can be the best
way to construct M from A, B, C and D sub-matrices?
You can build it with MatNest, but that format is constraining so unless
you understand the tradeoffs for different preconditioning techniques
applied to your specific problem, you should instead allocate the big
matrix, use MatGetLocalSubMatrix() to get references to the logical
blocks, and call your functions that assemble each of A,B,C,D. See
src/snes/examples/tutorials/ex28.c for an example of this organization.
Xujun Zhao
2015-05-05 20:40:07 UTC
Permalink
Hi Bikash,

I think you can use nested matrix. See MatCreateNest and the example
src/snes/examples/tutorials/ex70.c.html
<http://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex70.c.html>

Xujun
Post by Bikash Kanungo
Hi,
I have four global matrices: A (mxm), B (mxn), C (nxm) and D (nxn). All of
these are of type MATMPIAIJ (sparse parallel matrix) created using number
of global rows and columns. I want to construct an (m+n)x(m+n) global
matrix called M which would have A, B, C and D as its sub-matrices in
clockwise fashion starting from A at the upper-left. What can be the best
way to construct M from A, B, C and D sub-matrices?
Thanks,
Bikash
--
Bikash S. Kanungo
PhD Student
Computational Materials Physics Group
Mechanical Engineering
University of Michigan
Matthew Knepley
2015-05-05 20:40:46 UTC
Permalink
Post by Bikash Kanungo
Hi,
I have four global matrices: A (mxm), B (mxn), C (nxm) and D (nxn). All of
these are of type MATMPIAIJ (sparse parallel matrix) created using number
of global rows and columns. I want to construct an (m+n)x(m+n) global
matrix called M which would have A, B, C and D as its sub-matrices in
clockwise fashion starting from A at the upper-left. What can be the best
way to construct M from A, B, C and D sub-matrices?
There are at least two ways:

1) Use
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetLocalSubMatrix.html
to get a view
into the matrix for each submatrix A, B, C, D

2) Use
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateNest.html

Thanks,

Matt
Post by Bikash Kanungo
Thanks,
Bikash
--
Bikash S. Kanungo
PhD Student
Computational Materials Physics Group
Mechanical Engineering
University of Michigan
--
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
Bikash Kanungo
2015-05-05 21:45:48 UTC
Permalink
Thank you guys for the prompt replies.

I have never used DMs so far in my research. On a cursory glance
MatCreateNest seems to be simpler. But I would like to dig into
MatGelLocalSubmatrix to see if it provides any advantage.

Regards,
Bikash
Post by Bikash Kanungo
Hi,
I have four global matrices: A (mxm), B (mxn), C (nxm) and D (nxn). All of
these are of type MATMPIAIJ (sparse parallel matrix) created using number
of global rows and columns. I want to construct an (m+n)x(m+n) global
matrix called M which would have A, B, C and D as its sub-matrices in
clockwise fashion starting from A at the upper-left. What can be the best
way to construct M from A, B, C and D sub-matrices?
There are at least two ways:

1) Use
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetLocalSubMatrix.html
to get a view
into the matrix for each submatrix A, B, C, D

2) Use
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateNest.html

Thanks,

Matt
Post by Bikash Kanungo
Thanks,
Bikash
--
Bikash S. Kanungo
PhD Student
Computational Materials Physics Group
Mechanical Engineering
University of Michigan
--
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
Continue reading on narkive:
Loading...