<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Jun 7, 2014 at 1:40 AM, LikunTan <span dir="ltr"><<a href="mailto:tlk0812@hotmail.com" target="_blank">tlk0812@hotmail.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 dir="ltr">Hello,<div><br></div><div>I defined the partition of Vector, which is not stored contiguously. Here is a part of my code. The total number of nodes is NODE*DOF. Before executing this following code, I defined LEN and an array NODENP[] to store the number of nodes and the list of nodes in each processor. I accessed the element using aM[node*DOF+j] and aM[i*DOF+j], but none of them gave me the correct answer. Your help is well appreciated.</div>
</div></div></blockquote><div><br></div><div>We cannot know what you mean by "the correct answer". Vec is just a 1D array of memory. You decide on the organization inside.</div><div><br></div><div> Matt</div><div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr"><div>**************************************************************</div><div>VecCreate(PETSC_COMM_WORLD, &M);</div>
<div>VecSetSizes(M, LEN*DOF, NODE*DOF); </div><div><br></div><div>VecGetArray(M, &aM); </div><div><br></div><div><div>for(int i=0; i<LEN; i++)</div><div>{</div></div><div> node=NODENP[i];</div><div> for(int j=0; j<DOF; j++)</div>
<div> {</div><div> aM[node*DOF+j] or <span style="font-size:12pt">aM[i*DOF+j] ?</span><span style="font-size:12pt"> </span><span style="font-size:12pt"> //accessing the elements of M</span></div><div> </div>
<div> }</div><div>}</div><div>VecRestoreArray(M, &aM); </div><div>*********************************************************</div> </div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>