<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>Hi Jed,</span></div><div><span><br></span></div><div><span>I am using petsc/3.1 and the include file "petscdmda.h" is not working. I am using the "petscda.h"</span></div><div><span>and DACreate3D.&nbsp;</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&nbsp;</div><div>unew_localptr[k][j][i]=u_localptr[k-1][j-1][i-1]<br></div><div>but it gives Segmentation Violation error.&nbsp;</div><div>I also tried&nbsp;unew_localptr[k][j][i]=u_localptr[k][j+1][i+1] which works but&nbsp;</div><div>unew_localptr[k][j][i]=u_localptr[k+1][j+1][i+1] or&nbsp;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>&nbsp;&nbsp;ierr = DACreate3d(PETSC_COMM_WORLD,DA_YPERIODIC,DA_STENCIL_BOX,appctx.l,appctx.m,appctx.n,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,1,1,PETSC_NULL,PETSC_NULL,PETSC_NULL,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp;appctx.da);CHKERRQ(ierr);</div><div><div>&nbsp;for (k=zs; k&lt;zs+zm; k++) {</div><div>&nbsp;&nbsp;for (j=ys; j&lt;ys+ym; j++) {</div><div>&nbsp;&nbsp;for (i=xs; i&lt;xs+xm; i++) {</div><div><br></div><div>&nbsp;&nbsp;if(i!=0 || j!=0 || k!=0|| i!=mx-1 || j!=my-1 || k!=mz-1)</div><div><br></div></div></span></div><div>&nbsp;&nbsp;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:
 'times new roman', 'new york', times, serif; "> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Jed Brown &lt;jedbrown@mcs.anl.gov&gt;<br> <b><span style="font-weight: bold;">To:</span></b> khalid ashraf &lt;khalid_eee@yahoo.com&gt;; PETSc users list &lt;petsc-users@mcs.anl.gov&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> </font> </div> <br>
<div id="yiv1369139060"><div class="yiv1369139060gmail_quote">On Sun, Apr 1, 2012 at 22:01, khalid ashraf <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:khalid_eee@yahoo.com" target="_blank" href="mailto:khalid_eee@yahoo.com">khalid_eee@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="yiv1369139060gmail_quote" 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&nbsp;</div><div><div>&nbsp;for (k=zs; k&lt;zs+zm; k++) {</div><div>&nbsp;&nbsp;for (j=ys; j&lt;ys+ym; j++) {</div><div>&nbsp;&nbsp;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></body></html>