[petsc-users] Row Orderings of Mat and Vec

Jed Brown jedbrown at mcs.anl.gov
Tue Jan 31 06:23:49 CST 2012


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.


> 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/20120131/b9e676d8/attachment.htm>


More information about the petsc-users mailing list