[petsc-users] Accessing Vector's ghost values

Jed Brown jedbrown at mcs.anl.gov
Thu Feb 23 15:10:18 CST 2012


On Thu, Feb 23, 2012 at 15:05, Bojan Niceno <bojan.niceno at psi.ch> wrote:

> No, I use global.
>

The local form is just a local vector. It doesn't even know that a global
problem exists. You can't index into it using global indices. (In general,
there is no efficient way to look up information in the local vector
(includes ghost points) using global indices.)


>
>   for(Int i=0; i<n; i++) {
>     Int gi = mesh.nodes[i].global_number;
>     VecGetValues(x, 1, &gi, &unk[i]);
>   }
>
> "n" is defined as the number of cells inside, i.e. without buffers.  "unk"
> is my external array.  If I try to access buffer values, I use:
>
>   for(Int i=0; i<N; i++) {
>     Int gi = mesh.nodes[i].global_number;
>     VecGetValues(x, 1, &gi, &unk[i]);
>   }
>
> But then I end up with tons of warnings, presumably because I am going
> beyond "n".  Vector x was created with VecCreateGhost.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120223/51c75587/attachment.htm>


More information about the petsc-users mailing list