# VecGetLocalVectorRead
Maps the local portion of a vector into a vector.  You must call `VecRestoreLocalVectorRead()` when the local vector is no longer needed. 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecGetLocalVectorRead(Vec v, Vec w)
```
Not collective.


## Input parameter

- ***v -*** The vector for which the local vector is desired.



## Output parameter

- ***w -*** Upon exit this contains the local vector.





## Notes
This function is similar to `VecGetArrayRead()` which maps the local
portion into a raw pointer.  `VecGetLocalVectorRead()` is usually
almost as efficient as `VecGetArrayRead()` but in certain circumstances
`VecGetLocalVectorRead()` can be much more efficient than
`VecGetArrayRead()`.  This is because the construction of a contiguous
array representing the vector data required by `VecGetArrayRead()` can
be an expensive operation for certain vector types.  For example, for
GPU vectors `VecGetArrayRead()` requires that the data between device
and host is synchronized.

Unlike `VecGetLocalVector()`, this routine is not collective and
preserves cached information.


## See Also
 [](chapter_vectors), `Vec`, `VecCreateLocalVector()`, `VecRestoreLocalVectorRead()`, `VecGetLocalVector()`, `VecGetArrayRead()`, `VecGetArray()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/interface/rvector.c.html#VecGetLocalVectorRead">src/vec/vec/interface/rvector.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/nest/vecnest.c.html#VecGetLocalVectorRead_Nest">VecGetLocalVectorRead_Nest in src/vec/vec/impls/nest/vecnest.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqcuda/veccuda2.cu.html#VecGetLocalVectorRead_SeqCUDA">VecGetLocalVectorRead_SeqCUDA in src/vec/vec/impls/seq/seqcuda/veccuda2.cu</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqhip/vechip2.hip.c.html#VecGetLocalVectorRead_SeqHIP">VecGetLocalVectorRead_SeqHIP in src/vec/vec/impls/seq/seqhip/vechip2.hip.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/interface/rvector.c)


[Index of all Vec routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
