[petsc-users] save a vector value of multiple DOF to a file
Li, Zhisong (lizs)
lizs at mail.uc.edu
Wed May 5 13:17:52 CDT 2010
Hi,
I temporarily remove all the file opening/writing operations and found that it's probably "DAVecGetArray()" that's causing the trouble when run on 2 processors. It looks okay when in serial processing.
I don't use VecView() at all, as X-display doesn't function well for parallel processing.
I also tried to add these lines to first map the global vector xx to a newly created global vector x , before I scatter x to y:
DACreateNaturalVector(da, &x);
DAGlobalToNaturalBegin(da, xx,INSERT_VALUES, x);
DAGlobalToNaturalEnd(da, xx,INSERT_VALUES, x);
But this doesn't help.
The error message:
[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 4284 4437
!
[1]PETSC ERROR: ------------------------------------------------------------------------
[1]PETSC ERROR: Petsc Release Version 3.1.0, Patch 1, Thu Apr 8 14:16:50 CDT 2010
[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: ./ex7 on a linux-gnu named custard by verhoff Wed May 5 14:13:17 2010
[1]PETSC ERROR: Libraries linked from /home/verhoff/petsc/linux-gnu-c-debug/lib
[1]PETSC ERROR: Configure run at Tue Apr 27 11:40:02 2010
[1]PETSC ERROR: Configure options --download-c-blas-lapack=1 --with-cc=gcc --download-mpich=1
[1]PETSC ERROR: ------------------------------------------------------------------------
[1]PETSC ERROR: DAVecGetArray() line 53 in src/dm/da/src/dagetarray.c
[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 4284 4437
!
[1]PETSC ERROR: ------------------------------------------------------------------------
[1]PETSC ERROR: Petsc Release Version 3.1.0, Patch 1, Thu Apr 8 14:16:50 CDT 2010
[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: ./ex7 on a linux-gnu named custard by verhoff Wed May 5 14:13:17 2010
[1]PETSC ERROR: Libraries linked from /home/verhoff/petsc/linux-gnu-c-debug/lib
[1]PETSC ERROR: Configure run at Tue Apr 27 11:40:02 2010
[1]PETSC ERROR: Configure options --download-c-blas-lapack=1 --with-cc=gcc --download-mpich=1
[1]PETSC ERROR: ------------------------------------------------------------------------
[1]PETSC ERROR: DAVecRestoreArray() line 108 in src/dm/da/src/dagetarray.c
[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Arguments are incompatible!
[0]PETSC ERROR: Vector local size 8721 is not compatible with DA local sizes 4437 4590
!
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 1, Thu Apr 8 14:16:50 CDT 2010
[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: ./ex7 on a linux-gnu named custard by verhoff Wed May 5 14:13:17 2010
[0]PETSC ERROR: Libraries linked from /home/verhoff/petsc/linux-gnu-c-debug/lib
[0]PETSC ERROR: Configure run at Tue Apr 27 11:40:02 2010
[0]PETSC ERROR: Configure options --download-c-blas-lapack=1 --with-cc=gcc --download-mpich=1
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: DAVecGetArray() line 53 in src/dm/da/src/dagetarray.c
[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Arguments are incompatible!
[0]PETSC ERROR: Vector local size 8721 is not compatible with DA local sizes 4437 4590
!
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 1, Thu Apr 8 14:16:50 CDT 2010
[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: ./ex7 on a linux-gnu named custard by verhoff Wed May 5 14:13:17 2010
[0]PETSC ERROR: Libraries linked from /home/verhoff/petsc/linux-gnu-c-debug/lib
[0]PETSC ERROR: Configure run at Tue Apr 27 11:40:02 2010
[0]PETSC ERROR: Configure options --download-c-blas-lapack=1 --with-cc=gcc --download-mpich=1
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: DAVecRestoreArray() line 108 in src/dm/da/src/dagetarray.c
Thanks,
Regards,
Zhisong Li
> Hi,
>
> I want to setup a function in the main function to save the data to a file.
> For example suppose the vector x in ts/tutorials/ex7 consists of 3 DOF as
>
> typedef struct {
> PetscScalar u, v, p;
> } Field;
>
> I first followed the advised method to collect all values from a parallel
> vector into a vector on the 0th processor:
>
> VecScatterCreateToZero(x, &scatter, &y);
> VecScatterBegin(scatter,x,y,INSERT_VALUES,SCATTER_FORWARD);
> VecScatterEnd(scatter,x,y,INSERT_VALUES,SCATTER_FORWARD);
> VecScatterDestroy(scatter);
>
> and then use
> Field **z;
> DAVecGetArray(da, y, &z);
>
> and
> PetscViewerASCIIOpen(comm,"./result.txt",&viewer);
> PetscViewerASCIIPrintf(viewer, "%G ", &z[j][i].u );
>
> to finish. But I always either meet error for the line "DAVecGetArray(da,
> y, &z);" or save a file of all extremely small values(e.g. 8.652e-317),
> which is obviously wrong. So what is the correct way to do this? Where can I
> find a similar example to follow?
>
What error? This is correct way to do it, if you do not just use VecView().
Matt
> I also wonder if "DAGetGlobalVector( )" will do an equal job to collect
> parallel values?
>
>
> Thank you.
>
>
> Best Regards,
>
>
> Zhisong Li
More information about the petsc-users
mailing list