[petsc-users] Global DA index using DAGetCorners
Jed Brown
jed at 59A2.org
Thu Nov 25 04:16:04 CST 2010
On Thu, Nov 25, 2010 at 10:51, khalid ashraf <khalid_eee at yahoo.com> wrote:
> Sorry for the spam. Just to illustrate the problem. The following code
> produces the
> following output when run on 4 processors.
>
> Code:
> ierr=DAGetCorners(appctx->da,&xs,&ys,&zs,&xm,&ym,&zm);CHKERRQ(ierr);
> for (k=zs; k<zs+zm; k++) {
> for (j=ys; j<ys+ym; j++) {
> for (i=xs; i<xs+xm; i++) {
> {
> Vec_A[k][j][i] = (PetscReal)(k*my*mx+j*mx+i);
> }}}
>
> Output:
> Vec_A (mx=16 X my=16 X mz=4):
>
You have not shown how you produce this output.
> 0 1 2 3 4 5 6 7
> 16 17 18 19 20 21 22 23
> 32 33 34 35 36 37 38 39
> 48 49 and so on
>
> I don't understand why does the array value jump to 16 after 7. Meaning
> why is the 8th element of the vector is 16. Thanks.
>
You are seeing the "PETSc ordering" instead of the "Natural ordering", see
Figure 9 of the Users Manual
http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manual.pdf#page=50
DAVecGetArray sets up the indexing so you can write your code in terms of
the natural ordering even though the actual data are not stored that way.
Jed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101125/acac7b1a/attachment-0001.htm>
More information about the petsc-users
mailing list