<div class="gmail_quote">On Thu, Nov 25, 2010 at 10:51, khalid ashraf <span dir="ltr"><<a href="mailto:khalid_eee@yahoo.com">khalid_eee@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div>Sorry for the spam. Just to illustrate the problem. The following code produces the </div><div>following output when run on 4 processors.</div><div><br></div><div>Code:</div><div>ierr=DAGetCorners(appctx->da,&xs,&ys,&zs,&xm,&ym,&zm);CHKERRQ(ierr);</div>
<div> for (k=zs; k<zs+zm; k++) {</div><div> for (j=ys; j<ys+ym; j++) {</div><div> for (i=xs; i<xs+xm; i++) {</div><div> {</div><div> Vec_A[k][j][i] = (PetscReal)(k*my*mx+j*mx+i);</div><div> }}}</div><div>
<br></div><div>Output: </div><div>Vec_A (mx=16 X my=16 X mz=4):</div></div></blockquote><div><br></div><div>You have not shown how you produce this output.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>0 <span style="white-space:pre-wrap">        </span>1 <span style="white-space:pre-wrap">
        </span>2 <span style="white-space:pre-wrap">        </span>3<span style="white-space:pre-wrap">        </span>4<span style="white-space:pre-wrap">        </span>5<span style="white-space:pre-wrap">        </span>6<span style="white-space:pre-wrap">        </span>7</div>
<div>16<span style="white-space:pre-wrap">        </span>17<span style="white-space:pre-wrap">        </span>18<span style="white-space:pre-wrap">        </span>19<span style="white-space:pre-wrap">        </span>20<span style="white-space:pre-wrap">        </span>21<span style="white-space:pre-wrap">        </span>22<span style="white-space:pre-wrap">        </span>23</div>
<div>32<span style="white-space:pre-wrap">        </span>33<span style="white-space:pre-wrap">        </span>34<span style="white-space:pre-wrap">        </span>35<span style="white-space:pre-wrap">        </span>36<span style="white-space:pre-wrap">        </span>37<span style="white-space:pre-wrap">        </span>38<span style="white-space:pre-wrap">        </span>39</div>
<div>48<span style="white-space:pre-wrap">        </span>49<span style="white-space:pre-wrap">        </span>and so on</div><div><br></div><div>I don't understand why does the array value jump to 16 after 7. Meaning</div><div>why is the 8th element of the vector is 16. Thanks.</div>
</blockquote></div><br><div>You are seeing the "PETSc ordering" instead of the "Natural ordering", see Figure 9 of the Users Manual</div><div><br></div><div><a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manual.pdf#page=50">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manual.pdf#page=50</a></div>
<div><br></div><div>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.</div><div><br></div><div>Jed</div>