[petsc-users] A global vector reading from the binary file.

Barry Smith bsmith at mcs.anl.gov
Fri Mar 12 10:55:42 CST 2010


    DACreateGlobalVector() gives a vector that is "spread-out" across  
the processors. It is never going to contain the "entire vector" on  
each process.  That is not what it is for. If you want to take  
parallel DA global vector and get each process to have the whole  
vector see http://www.mcs.anl.gov/petsc/petsc-2/documentation/faq.html#mpi-vec-to-seq-vec 
  note in particular you first need to use the DAGlobalToNaturalBegin/ 
End().

    Barry

On Mar 12, 2010, at 9:33 AM, (Rebecca) Xuefei YUAN wrote:

> Dear Barry,
>
> I was trying to read from a binary file and make the vector be  
> global at each processor, but if the following routine applies,
>
> ierr = DACreate2d(PETSC_COMM_WORLD,DA_NONPERIODIC,DA_STENCIL_BOX,  
> (info1.mx-1-parameters->abandonNumber), (info1.my-1-parameters- 
> >abandonNumber), PETSC_DECIDE, PETSC_DECIDE, 4, 1, PETSC_NULL,  
> PETSC_NULL, &da2_4);CHKERRQ(ierr);
> ierr = DACreateGlobalVector(da2_4,&FIELD);CHKERRQ(ierr);
> sprintf(fileName,"solution");
> ierr =  
> PetscViewerBinaryOpen 
> (PETSC_COMM_WORLD,fileName,FILE_MODE_READ,&viewer);CHKERRQ(ierr);
> ierr = VecLoadIntoVector(viewer,FIELD);CHKERRQ(ierr);
> ierr = DAVecGetArray(da2_4,FIELD, &field);CHKERRQ(ierr);
>
> I expect to let field[][] in each processor are the same at each  
> grid point, i.e., for np=2,
>
> at the first processor, field[][] =
>
> 0   1  2  3  4  5
> 6   7  8  9 10 11
> 12 13 14 15 16 17
> 18 19 20 21 22 23
> 24 25 26 27 28 29
>
> and at the second processor, field[][] =
>
> 0   1  2  3  4  5
> 6   7  8  9 10 11
> 12 13 14 15 16 17
> 18 19 20 21 22 23
> 24 25 26 27 28 29
>
>
> However, this routine gives me at the first processor, field[][] =
> (xs=0,x=3,ys=0,y=5)
>
> 0   1  2  3  4  5
> 3   4  5  6  7  8
> 6   7  8  9 10 11
> 9  10 11 12 13 14
> 12 13 14  X  X  X
>
> and at the second processor, field[][] =
> (xs=3,x=3,ys=0,y=5)
>
> X   X  X 15 16 17
> 15 16 17 18 19 20
> 18 19 20 21 22 23
> 21 22 23 24 25 26
> 24 25 26 27 28 29
>
> I know in each subdomain, the values are right, but how could I have  
> this array be exact the same as a 'global' one?
>
> Thanks very much!
>
> Rebecca
>



More information about the petsc-users mailing list