<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span><div>Thanks Matt. It works now. </div><div><br></div><div>I have another problem. I am writing this program. </div><div> </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><div> if ( i!=(mx-1) || j!=my-1 || k!=mz-1)</div><div>{</div></div></div><div>bodyFx[0]=1;</div><div>bodyFx[1]=-0.3;</div><div>bodyFx[2]=-0.3;</div><div>bodyFx[3]=-0.3;</div><div>row[0]=k*mx*my+j*mx+i;</div><div>row[1]=k*mx*my+j*mx+i+1;</div><div>row[2]=k*mx*my+(j+1)*mx+i;</div><div>row[3]=(k+1)*mx*my+j*mx+i;</div><div>VecSetValues(fx_test,4,row,bodyFx,ADD_VALUES);</div></span></div><div>}</div><div><div>VecAssemblyBegin(fx_test);</div><div>VecAssemblyEnd(fx_test);</div><div><br></div><div>Output: Print
fx_test</div><div><br></div></div><div> Here fx_test is a global vector. This program gives correct output on 1 proc. but on 4 processors,</div><div>the program runs but the outputs are wrong.</div><div><br></div><div>I also tried</div><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><div> if ( i!=(mx-1) || j!=my-1 || k!=mz-1)</div><div>{</div></div></div><div>bodyFx[0]=1;</div><div>bodyFx[1]=-0.3;</div><div>bodyFx[2]=-0.3;</div><div>bodyFx[3]=-0.3;</div><div><div> fx1_localptr[k][j][i+1]+=bodyFx[4];</div><div> fx1_localptr[k][j+1][i]+=bodyFx[3];</div><div> fx1_localptr[k+1][j][i]+=bodyFx[1];</div><div> fx1_localptr[k][j][i]+=bodyFx[0];</div><div>}</div><div>Here, fx1_localptr is an array from a local vector that is communicated from the global vector fx_test.</div><div>In this case as well, I get similar
errors. <br></div><div><div><br></div><div>Thanks.</div><div>Khalid</div><div><br></div><div>Some final numbers of the vector with 8*8*6 grid, 4 proc,
</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>1.0000000000000009e-01</div><div>1.0000000000000009e-01</div><div>1.0000000000000009e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>0.0000000000000000e+00</div><div>4.0000000000000002e-01</div><div>1.0000000000000009e-01</div><div>1.0000000000000009e-01</div><div>1.0000000000000009e-01</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div>1.0000000000000009e-01</div><div>1.0000000000000009e-01</div><div>1.0000000000000009e-01</div><div>-2.9999999999999999e-01</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div><br></div><div><br></div><div>Some final numbers
of the vector with 8*8*6 grid, 1 proc,
<br></div><div><div>0.0000000000000000e+00</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>0.0000000000000000e+00</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>0.0000000000000000e+00</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>-2.9999999999999999e-01</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div>
<div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div>0.0000000000000000e+00</div><div><br></div><div> </div></div><div><br></div></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> Matthew Knepley <knepley@gmail.com><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> Monday, April 2, 2012 5:41 AM<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="yiv1317228556">On Mon, Apr 2, 2012 at 3:36 AM, 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><div class="yiv1317228556gmail_quote"><blockquote class="yiv1317228556gmail_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 "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></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="yiv1317228556gmail_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> &appctx.da);CHKERRQ(ierr);</div><div><div class="yiv1317228556im"><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><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;"> <div dir="ltr"> <font face="Arial"> <hr size="1"><div class="yiv1317228556hm yiv1317228556HOEnZb"> <b><span style="font-weight:bold;">From:</span></b> Jed Brown <<a rel="nofollow" ymailto="mailto:jedbrown@mcs.anl.gov" target="_blank" href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>><br>
<b><span style="font-weight:bold;">To:</span></b> khalid ashraf <<a rel="nofollow" ymailto="mailto:khalid_eee@yahoo.com" target="_blank" href="mailto:khalid_eee@yahoo.com">khalid_eee@yahoo.com</a>>; PETSc users list <<a rel="nofollow" ymailto="mailto:petsc-users@mcs.anl.gov" target="_blank" href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> <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="yiv1317228556hm yiv1317228556HOEnZb">
</div></div><div><div class="yiv1317228556h5"> <br>
<div><div>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 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> </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>
</div><br><br> </div> </div> </div></body></html>