petsc-3.7.1 2016-05-15
Report Typos and Errors

# VecGhostGetLocalForm

Obtains the local ghosted representation of a parallel vector (obtained with VecCreateGhost(), VecCreateGhostWithArray() or VecCreateSeq()). Returns NULL if the Vec is not ghosted.

### Synopsis

    #include "petscvec.h"
    PetscErrorCode  VecGhostGetLocalForm(Vec g,Vec *l)

Logically Collective Many br

### Input Parameter

g -the global vector Many br

### Output Parameter

l -the local (ghosted) representation, NULL if g is not ghosted Many br

### Notes

This routine does not actually update the ghost values, but rather it Many brreturns a sequential vector that includes the locations for the ghost Many brvalues and their current values. The returned vector and the original Many brvector passed in share the same array that contains the actual vector data. Many br

To update the ghost values from the locations on the other processes one must call Many brVecGhostUpdateBegin() and VecGhostUpdateEnd() before accessing the ghost values. Thus normal Many brusage is Many br

        VecGhostUpdateBegin(x,INSERT_VALUES,SCATTER_FORWARD);

        VecGhostUpdateEnd(x,INSERT_VALUES,SCATTER_FORWARD);

        VecGhostGetLocalForm(x,&xlocal);

        VecGetArray(xlocal,&xvalues);

           // access the non-ghost values in locations xvalues[0:n-1] and ghost values in locations xvalues[n:n+nghost];

        VecRestoreArray(xlocal,&xvalues);

        VecGhostRestoreLocalForm(x,&xlocal);

One should call VecGhostRestoreLocalForm() or VecDestroy() once one is Many brfinished using the object. Many br

Many br

### See Also

VecCreateGhost(), VecGhostRestoreLocalForm(), VecCreateGhostWithArray()

Level:advanced
Location:src/vec/vec/impls/mpi/commonmpvec.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/vec/vec/examples/tutorials/ex9.c.html
src/vec/vec/examples/tutorials/ex9f.F.html
src/vec/vec/examples/tutorials/ex14f.F.html