about ghosted vectors and there local representation

Thomas Geenen geenen at gmail.com
Tue Jun 20 05:31:50 CDT 2006


Dear Petsc users,

I think that I do not use the ghosted vector concept in the right way.

I create a vector with 
ierr = VecCreateGhost(PETSC_COMM_WORLD, nc, 
                            		 PETSC_DECIDE, nghosts, ghosts, &x);
The entries in ghost contain the global vector positions that I want to have 
available locally.
 
I have a local representation so i apply (after having constructed the mapping 
of course)
ierr = VecSetLocalToGlobalMapping(x,ltog);
I now insert the values 
ierr = VecSetValuesLocal(x, nc, indx, x_values, INSERT_VALUES);
VecAssemblyBegin(x);
VecAssemblyEnd(x);
I am now under the assumption that petsc divided the vector entries among 
processes according to his global representation of the vector.

I solve my system of equations 
KSPSolve(ksp,b,x);
afterwards i do
ierr = KSPGetSolution(ksp, &x);
ierr = VecGhostUpdateBegin(x,INSERT_VALUES,SCATTER_FORWARD);
ierr = VecGhostUpdateEnd(x,INSERT_VALUES,SCATTER_FORWARD);
ierr = VecGhostGetLocalForm(x, &lx);

I now expect the vector to be in the local form. That means that the positions 
that I created as ghost points are filled with the solution corresponding to 
the global solution. I expect that they are inserted in the position in my 
local vector corresponding to there corresponding global position.

apparently this is not what happens. 

a small example
2 cpu's 
each cpu contains 3 vector entries however there is an overlap of 1
on cpu 1 the vector contains points (1, 2, 3) 
on cpu 2 the vector contains points (3, 4, 5)  

I make position 1 on cpu 2 a ghost points with nghost=1 ghosts(3)
after solving and restoring I expect vector lx to contain the solution as (3, 
4, 5) 


I hope I have explained my misunderstanding of the underlying concept clear 
enough

thanks for your help
Thomas Geenen




More information about the petsc-users mailing list