[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Scattering DA Vectors
- To: petsc-users@xxxxxxxxxxx
- Subject: Scattering DA Vectors
- From: Victor Sofonea <sofonea@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 24 Jan 2007 08:11:39 +0200 (EET)
- In-reply-to: <Pine.OSX.4.64.0611022025010.726@barry-smiths-computer.local>
- References: <005401c6fe58$b1d0b4e0$3364a8c0@dmrc6700512> <a9f269830611020507w7c1397bfqf6507fd7e915345@mail.gmail.com> <005a01c6fe85$5a336160$3364a8c0@dmrc6700512> <a9f269830611020556s5b0ca36fxa5071c4304522966@mail.gmail.com> <006601c6fe8a$7cb73040$3364a8c0@dmrc6700512> <a9f269830611020627l44cf788ar30b5d4f2695c53bf@mail.gmail.com> <001701c6fee5$fede5f70$3364a8c0@dmrc6700512> <Pine.OSX.4.64.0611021922290.726@barry-smiths-computer.local> <002801c6fee9$c5bfbc30$3364a8c0@dmrc6700512> <Pine.OSX.4.64.0611022025010.726@barry-smiths-computer.local>
- Reply-to: petsc-users@xxxxxxxxxxx
- Sender: owner-petsc-users@xxxxxxxxxxx
Hi,
I'm using two-dimensional DAs in my code to create global and local
vectors
DA da;
Vec nloc, lnloc, zero_nloc;
PetscInt imax = 102, jmax=3;
DACreate2d(PETSC_COMM_WORLD, DA_YPERIODIC, DA_STENCIL_BOX,
imax,jmax,PETSC_DECIDE,PETSC_DECIDE,
1,1,PETSC_NULL,PETSC_NULL,&da);
ierr = DACreateLocalVector(da,&lnloc); CHKERRQ(ierr);
ierr = DACreateGlobalVector(da,&nloc); CHKERRQ(ierr);
and at some moment I need copy all values of the global vector nloc
on the zeroth processor. For this purpose, I tried to create a scatter
context and use VecScatterBegin...End:
ierr = VecScatterCreateToZero(nloc,&zero_ctx,&zero_nloc);CHKERRQ(ierr);
ierr = VecScatterBegin(nloc,zero_nloc,INSERT_VALUES,SCATTER_FORWARD,zero_ctx);
CHKERRQ(ierr);
ierr = VecScatterEnd(nloc,zero_nloc,INSERT_VALUES,SCATTER_FORWARD,zero_ctx);
CHKERRQ(ierr);
This scatter procedure does not work for global vectors created using
DACreateGlobalVector(...) since (on processor 0, when using 2
processors, but I plan to use more processors in the future):
PetscReal **aznloc
ierr = DAVecGetArray(da,zero_nloc,&aznloc); CHKERRQ(ierr);
gives the error
+++++++++++++ BEGIN ERROR MESSAGE
[0]PETSC ERROR: --------------------- Error Message
------------------------------------
[0]PETSC ERROR: Arguments are incompatible!
[0]PETSC ERROR: Vector local size 306 is not compatible with DA local
sizes 153 260
!
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 2.3.2, Patch 7, Fri Dec 1 11:22:44
CST 2006 HG revision: 4fc87ad4c9d9855d212e1fa6135ed04b299cdc92
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: ./dachannel on a freebsd named
smoluchowski.acad-tim.tm.edu.ro by sofonea Wed Jan 24 08:08:34 2007
[0]PETSC ERROR: Libraries linked from
/usr/local/petsc-2.3.2-p7-mpi//lib/freebsd
[0]PETSC ERROR: Configure run at Tue Jan 2 18:08:24 2007
[0]PETSC ERROR: Configure options --with-deb[1]PETSC ERROR:
--------------------- Error Message ------------------------------------
[1]PETSC ERROR: Arguments are incompatible!
[1]PETSC ERROR: Vector local size 0 is not compatible with DA local sizes
153 260
!
[1]PETSC ERROR:
------------------------------------------------------------------------
[1]PETSC ERROR: Petsc Release Version 2.3.2, Patch 7, Fri Dec 1 11:22:44
CST 2006 HG revision: 4fc87ad4c9d9855d212e1fa6135ed04b299cdc92
[1]PETSC ERROR: See docs/changes/index.html for recent updates.
[1]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[1]PETSC ERROR: See docs/index.html for manual pages.
[1]PETSC ERROR:
------------------------------------------------------------------------
[1]PETSC ERROR: ./dachannel on a freebsd named
smoluchowski.acad-tim.tm.edu.ro by sofonea Wed Jan 24 08:08:34 2007
[1]PETSC ERROR: Libraries linked from
/usr/local/petsc-2.3.2-p7-mpi//lib/freebsd
[1]PETSC ERROR: Configure run at Tue Jan 2 18:08:24 2007
[1]PETSC ERROR: Configure options --with-debugging=0ugging=0
--download-f-blas-lapack=ifneeded --download-mpich=ifneeded
--with-shared=0
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: DAVecGetArray() line 50 in src/dm/da/src/dagetarray.c
[0]PETSC ERROR: User provided function() line 343 in dainout.c
[0]PETSC ERROR: User provided function() line 1130 in damain.c
--download-f-blas-lapack=ifneeded --download-mpich=ifneeded
--with-shared=0
[1]PETSC ERROR:
------------------------------------------------------------------------
[1]PETSC ERROR: DAVecGetArray() line 50 in src/dm/da/src/dagetarray.c
[1]PETSC ERROR: User provided function() line 343 in dainout.c
[1]PETSC ERROR: User provided function() line 1130 in damain.c
++++++++++++ END ERROR MESSAGE
I tried also
PetscReal *aznloc
ierr = VecGetArray(zero_nloc,&aznloc); CHKERRQ(ierr);
Although this works, I need the natural ordering for further processing
the elements of aznloc, as follows:
PetscReal nn[imax];
for(i=0; i<imax; i++)
{
nn[i] = 0.00
for(i=0; j<imax; i++)
{
nn[i] += aznloc[j][i];
}
}
In other words, I need aznloc to be a two-dimensional array to preserve
the same idex ranges 0...imax and 0...jmax used for the global vector
nloc).
Do you have a solution ?
Thank you,
Victor Sofonea