On Mon, Apr 2, 2012 at 3:36 AM, khalid ashraf <span dir="ltr">&lt;<a href="mailto:khalid_eee@yahoo.com">khalid_eee@yahoo.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="font-size:12pt;font-family:arial,helvetica,sans-serif"><div><span>Hi Jed,</span></div><div><span><br></span></div><div><span>I am using petsc/3.1 and the include file &quot;petscdmda.h&quot; is not working. I am using the &quot;petscda.h&quot;</span></div>
<div><span>and DACreate3D. </span></div><div><span><div>unew_localptr[][][] is from a global vector using VecGetArray</div><div>u_localptr[][][] is from a local vector communicated from a global vector.</div><div>I tried </div>
<div>unew_localptr[k][j][i]=u_localptr[k-1][j-1][i-1]<br></div><div>but it gives Segmentation Violation error. </div><div></div></span></div></div></div></blockquote><div><br></div><div>I would guess (because you provide almost no information about what you are doing), that</div>
<div>this is a domain on the edge. If you truly mean to have a periodic domain, you must set that in the</div><div>creation call. Then the local vector will also ghost regions outside the domain boundary.</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 style="font-size:12pt;font-family:arial,helvetica,sans-serif"><div><span><div>I also tried unew_localptr[k][j][i]=u_localptr[k][j+1][i+1] which works but </div>
<div>unew_localptr[k][j][i]=u_localptr[k+1][j+1][i+1] or unew_localptr[k][j][i]=u_localptr[k][j-1][i-1]</div><div>does not work. I am running the program on4
 processors.<br></div><div><br></div><div>Thanks.</div><div><br></div><div><br></div><div>  ierr = DACreate3d(PETSC_COMM_WORLD,DA_YPERIODIC,DA_STENCIL_BOX,appctx.l,appctx.m,appctx.n,</div><div>                    PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,1,1,PETSC_NULL,PETSC_NULL,PETSC_NULL,</div>
<div>                    &amp;appctx.da);CHKERRQ(ierr);</div><div><div class="im"><div> for (k=zs; k&lt;zs+zm; k++) {</div><div>  for (j=ys; j&lt;ys+ym; j++) {</div><div>  for (i=xs; i&lt;xs+xm; i++) {</div><div><br></div>
</div><div>  if(i!=0 || j!=0 || k!=0|| i!=mx-1 || j!=my-1 || k!=mz-1)</div><div><br></div></div></span></div><div>  unew_localptr[k][j][i]=u_localptr[k+1][j+1][i+1];<br></div><div>}}}</div>  <div style="font-size:12pt;font-family:arial,helvetica,sans-serif">
 <div style="font-size:12pt;font-family:&#39;times new roman&#39;,&#39;new york&#39;,times,serif"> <div dir="ltr"> <font face="Arial"> <hr size="1"><div class="hm HOEnZb">  <b><span style="font-weight:bold">From:</span></b> Jed Brown &lt;<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>&gt;<br>
 <b><span style="font-weight:bold">To:</span></b> khalid ashraf &lt;<a href="mailto:khalid_eee@yahoo.com" target="_blank">khalid_eee@yahoo.com</a>&gt;; PETSc users list &lt;<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>&gt; <br>
 <b><span style="font-weight:bold">Sent:</span></b> Sunday, April 1, 2012 10:07 PM<br> <b><span style="font-weight:bold">Subject:</span></b> Re: [petsc-users] transfer vector data diagonally on DA<br> </div></font><div class="hm HOEnZb">
 </div></div><div><div class="h5"> <br>
<div><div>On Sun, Apr 1, 2012 at 22:01, khalid ashraf <span dir="ltr">&lt;<a rel="nofollow" href="mailto:khalid_eee@yahoo.com" target="_blank">khalid_eee@yahoo.com</a>&gt;</span> wrote:<br><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>I want to transfer vector data diagonally in the DA grid like </div><div><div> for (k=zs; k&lt;zs+zm; k++) {</div><div>  for (j=ys; j&lt;ys+ym; j++) {</div><div>  for (i=xs; i&lt;xs+xm; i++) {</div><div>if(i!=mx-1 || j!=my-1 || k!=mz-1){</div>

</div><div>u_new[k+1][j+1][i+1]=u[k][j][i];}</div><div>}}}</div><div><br></div><div>Could you please suggest the best way to do it minimizing interprocessor assignments.</div></blockquote></div><br><div>Both are on the same DMDA?</div>

<div><br></div><div>Communicate U to Ulocal (DMGlobalToLocalBegin/End) using a BOX stencil with width at least 1, get the global array u_new[][][] from UGlobalNew and the local arrays u[][][] from Ulocal, then assign u_new[k][j][i] = u[k-1][j-1][i-1].</div>

</div><br><br> </div></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<br>