[petsc-users] extract Mat data

gouarin loic.gouarin at math.u-psud.fr
Thu Mar 31 10:10:57 CDT 2011


Thanks for the reply.

On 31/03/2011 16:48, Hong Zhang wrote:
> Loic,
>
>> I want to do the same for MATMPI. This is what I do:
>>
>> MatGetLocalMat(A,MAT_INITIAL_MATRIX,&Aloc);
>> MatGetRowIJ(Aloc, 1, PETSC_FALSE, PETSC_FALSE,&(Acsr.n),&(Acsr.ia),
>> &(Acsr.ja),&done);
>> MatGetArray(Aloc,&(Acsr.a));
>>
>> Now, I need to know on what process the non local points are.
> Each process get its own local submatrix. See
> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIAIJ.html
> on data structure of MPIAIJ format. Applying your statements above to
> the example listed on the page (a 8x8 matrix), Proc0 will get
> Aloc=A(0:2,:), ..., Porc2 gets Aloc=A(6:7,:).
>> Is there a petsc function that gives this partition ?
> MatGetOwnershipRange()
I use this function to know the local points index. In the same way, 
with this function I know the non local index.

But this function doesn't give the process. I give you an example. I 
have this matrix:

1 0 | 0 1
1 2 | 1 0
-----------
0 0 | 1 0
0 2 | 0 1

I want this kind of format

for proc 0
a = {1,1,1,2,1}
ia = {0,2,5}
ja = {0,3,0,1,2}
rank = {0,0,1,1}

for proc 1
a = {1,2,1}
ia = {0,1,3}
ja = {0,2,1}
rank = {1,1,0}

rank give me the process for each non zero column. Local rows should 
have numbers 1,...N and offdiagonal entries with j>N.

I suppose that I have no information about the structure of MPIAIJ.

Loic



More information about the petsc-users mailing list