[petsc-users] MatGetSubmatrices from block matrix MPIBAIJ

shu guo greatgs2008 at gmail.com
Tue Oct 23 10:19:36 CDT 2012


Hi Jed,

I am solving a electromagnetic problem. Each node has 4 degree of
freedom, phi A1 A2 A3.

The row in this blocked matrix is generated as

               node1         |      node 2                 |         node 3
                                 |                                |
phi1 A1_1 A1_2 A1_3 | phi2 A2_1 A2_2 A2_3| phi3 A3_1 A3_2 A3_3

And I permute it as

phi matrix      ||                A matrix
phi1 phi2 phi3 || A1_1 A1_2 A1_3 A2_1 A2_2 A2_3 A3_1 A3_2 A3_3

I permuted it just want to sort each variables together.

> Just build an index set that has every part of the block. If you need
> arbitrary scalar subsets, use MPIAIJ (can use MatConvert).

If I want the submatrix from original matrix, can you be more specific
that how the index set looks like? And is it possible for me to merely
get the submatrix of the ist DOF of each element? Thank you.

Shu








On Tue, Oct 23, 2012 at 11:04 AM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> 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).


More information about the petsc-users mailing list