<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. </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>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> &appctx.da);CHKERRQ(ierr);</div><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><br></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:
'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 <jedbrown@mcs.anl.gov><br> <b><span style="font-weight: bold;">To:</span></b> khalid ashraf <khalid_eee@yahoo.com>; PETSc users list <petsc-users@mcs.anl.gov> <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"><<a rel="nofollow" ymailto="mailto:khalid_eee@yahoo.com" target="_blank" href="mailto:khalid_eee@yahoo.com">khalid_eee@yahoo.com</a>></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 </div><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>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>