[petsc-users] Row Orderings of Mat and Vec

Hui Zhang mike.hui.zhang at hotmail.com
Wed Feb 1 05:02:19 CST 2012


On Jan 31, 2012, at 1:23 PM, Jed Brown wrote:

> On Tue, Jan 31, 2012 at 04:11, Hui Zhang <mike.hui.zhang at hotmail.com> wrote:
> Suppose using MatCreate() and MatSetSizes() we obtain a Mat A, and then
> using VecCreate() and VecSetSizes() with the same rows' arguments as A
> we obtain a Vec b.  Let A_i (b_i) consists of the rows owned by processor i.
> 
> Can I believe that under the ordering of petsc, the following equality holds,
> A= [A_0
>    A_1
>    ...
>    A_N],
> b= [b_0
>    b_1
>    ...
>    b_N],
> i.e. A_i, b_i with smaller i--the processor number goes first?
> 
> Matrices and vectors always have contiguous row partitions, yes.
>  
> 
> My question comes from assembly of linear system.  Suppose under my application
> ordering(AO) the system is Ax=b.  I can get an AO from A using
> 
>      MatGetOwnershipRanges(A,&Istart,&Iend);
>      AOCreateBasic( -, -,app_ind, Istart..Iend, &ao_1);
> 
> and assemble A.  Under the petsc ordering, A becomes P_1*A mathematically,
> 
> I don't think I follow. This AO does not transform A in any way. You can use the AO to translate application indices to PETSc indices to give to MatSetValues().
> 
> In most cases, I would recommend redistributing the mesh according to the partition and then using local indices (e.g. MatSetValuesLocal()) during assembly. You might use AO for that setup step, but it usually doesn't make sense to use _during_ assembly.

thanks, do you mean that it is faster to use LocaltoGlobalMapping & SetValuesLocal
than to use AO & SetValues globally? Is there a big difference in performance?


>  
> with
> P_1 the permutation corresponding to ao_1.  In a similar way, we have that b
> becomes P_2 b under the petsc ordering.  I want to make sure P_1 and P_2 are
> the same so arises my question.
> 
> Thanks a lot!
> Hui
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120201/44f8a999/attachment.htm>


More information about the petsc-users mailing list