[petsc-users] MatGetSubmatrices from block matrix MPIBAIJ

Jed Brown jedbrown at mcs.anl.gov
Tue Oct 23 10:04:11 CDT 2012


On Tue, Oct 23, 2012 at 9:56 AM, shu guo <greatgs2008 at gmail.com> wrote:

> I have figured out how this error happens. When I get a sub-matrix
> from a block matrix, Petsc will compress the IS according to the
> matrix block format. So for example, if the matrix has a block size
> nsbk=4. It will calculate the dimension/nsbk and sort IS accordingly.
>
> The original matrix is like
>
> A1 B1_1 B1_2 B1_3 || A2 B2_1 B2_2 B2_3
>

I don't understand this notation.


>
> so each node has 4 degree of freedom. And the way I permute the matrix
> is sort the matrix like,
>
> A1 A2 || B1_1 B1_2 B1_3 B2_1 B2_2 B2_3
>

*Why* are you permuting the matrix like this? Why not just construct the
index set that addresses the part you want?


>
> So I need the sub-matrix A1 A2. Can you give me a hint how to do it?
>
> Another question is if I do not permute the matrix, so it will hold
> the format of
> A1 B1_1 B1_2 B1_3 || A2 B2_1 B2_2 B2_3
>
> If I want to get sub-matrix A1 A2 from it. I need a blocked IS, right?
> In the manual, I found a statement that saying "For BAIJ matrices the
> index sets must respect the block structure, that is if they request
> one row/column in a block, they must request all rows/columns that are
> in that block. For example, if the block size is 2 you cannot request
> just row 0 and column 0." Does it mean that I cannot merely access A1
> in the first block? If not, how should I do with this structure if I
> want A1 A2 from it?
>

Just build an index set that has every part of the block. If you need
arbitrary scalar subsets, use MPIAIJ (can use MatConvert).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121023/9648ad20/attachment.html>


More information about the petsc-users mailing list