<div dir="ltr">Okay. The local vector is equal to the local portion of global vector + ghost values. Both of them use the same PETSc ordering.<div><br></div><div>The reason I got confused before is I use VecView(vglobal, PETSC_VIEWER_STDOUT_WORLD) to view the global vector. In the output, it has process[0] 1 2 3 4 process[1] 5 6 7 8 .... They are actually not the values stored in processor 0 and 1. They are different from the values printed through VecGetArray. </div>
<div><br></div><div>Thanks.</div><div><br></div><div>Xiangdong<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 25, 2014 at 12:48 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">Xiangdong <<a href="mailto:epscodes@gmail.com">epscodes@gmail.com</a>> writes:<br>
> For example, if the values on the 4-by-4 grid are [1,2,3,4;  5,6,7,8;<br>
>  9,10,11,12; 13,14,15,16]. If I use 4 processors and set m=2, n=2 (or use<br>
> petsc_decide), then on processor zero, the local portion of the global<br>
> vector is 1,2,3,4<br>
<br>
</div>No, PETSc global ordering is different from natural.  There is a<br>
detailed picture of this in the users manual and in most PETSc<br>
tutorials.  Please read that.<br>
<div class=""><br>
> while the local vector has value 1,2,5,6. On processor one, the local<br>
> portion of the global vector is 5,6,7,8; and the local vector is<br>
> 3,4,7,8. It looks like the global is natural order, while local vector<br>
> is petsc order.<br>
<br>
</div>No.<br>
<div class=""><br>
><br>
><br>
><br>
>><br>
>> > 2) DOF. In each cell, I have two unknowns, say ux and uy. One way is to<br>
>> > store them using one global vector with dof=2. The other way is to create<br>
>> > two global vectors for each ux and uy with dof=1. Is one approach better<br>
>> > than the other?<br>
>><br>
>> The former is better for memory streaming unless your operations<br>
>> traverse the grid using only one at a time (and then, it would be better<br>
>> to rephrase to traverse fewer times, using both values each time).<br>
>><br>
><br>
> Any examples in petsc tutorials demonstrating the case dof>1? I found most<br>
> of them are dof=1. For dof>1, are the values stored in a interleaved<br>
> manner?<br>
<br>
</div>src/snes/examples/tutorials/ex48.c uses dof=2 and MatSetValuesBlockedStencil.<br>
</blockquote></div><br></div></div></div>