On Mon, Apr 2, 2012 at 3:36 AM, khalid ashraf <[email protected]> wrote:
Hi Jed,
I am using petsc/3.1 and the include file "petscdmda.h" is not working. I am using the "petscda.h" and DACreate3D. unew_localptr[][][] is from a global vector using VecGetArray u_localptr[][][] is from a local vector communicated from a global vector. I tried unew_localptr[k][j][i]=u_localptr[k-1][j-1][i-1] but it gives Segmentation Violation error.
I would guess (because you provide almost no information about what you are doing), that this is a domain on the edge. If you truly mean to have a periodic domain, you must set that in the creation call. Then the local vector will also ghost regions outside the domain boundary. Matt
I also tried unew_localptr[k][j][i]=u_localptr[k][j+1][i+1] which works but 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] does not work. I am running the program on4 processors.
Thanks.
ierr = DACreate3d(PETSC_COMM_WORLD,DA_YPERIODIC,DA_STENCIL_BOX,appctx.l,appctx.m,appctx.n,
PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,1,1,PETSC_NULL,PETSC_NULL,PETSC_NULL, &appctx.da);CHKERRQ(ierr); for (k=zs; k<zs+zm; k++) { for (j=ys; j<ys+ym; j++) { for (i=xs; i<xs+xm; i++) {
if(i!=0 || j!=0 || k!=0|| i!=mx-1 || j!=my-1 || k!=mz-1)
unew_localptr[k][j][i]=u_localptr[k+1][j+1][i+1]; }}} ------------------------------ *From:* Jed Brown <[email protected]> *To:* khalid ashraf <[email protected]>; PETSc users list < [email protected]> *Sent:* Sunday, April 1, 2012 10:07 PM *Subject:* Re: [petsc-users] transfer vector data diagonally on DA
On Sun, Apr 1, 2012 at 22:01, khalid ashraf <[email protected]> wrote:
I want to transfer vector data diagonally in the DA grid like for (k=zs; k<zs+zm; k++) { for (j=ys; j<ys+ym; j++) { for (i=xs; i<xs+xm; i++) { if(i!=mx-1 || j!=my-1 || k!=mz-1){ u_new[k+1][j+1][i+1]=u[k][j][i];} }}}
Could you please suggest the best way to do it minimizing interprocessor assignments.
Both are on the same DMDA?
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].
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener