# VecGetKokkosView
Returns a constant Kokkos View that contains up-to-date data of a vector in the specified memory space. 
## Synopsis
```
template <class MemorySpace>
PetscErrorCode VecGetKokkosView(Vec, Kokkos::View<const PetscScalar *, MemorySpace> *)
```

## Synopsis
```
#include <petscvec_kokkos.hpp>
PetscErrorCode VecGetKokkosView  (Vec v,Kokkos::View<const PetscScalar*,MemorySpace>* kv);
PetscErrorCode VecGetKokkosView  (Vec v,Kokkos::View<PetscScalar*,MemorySpace>* kv);
```

Logically Collective


## Input Parameter

- ***v -*** the vector in type of `VECKOKKOS`



## Output Parameter

- ***kv -*** the Kokkos View with a user-specified template parameter MemorySpace



## Notes
If the vector is not of type `VECKOKKOS`, an error will be raised.

The functions are similar to `VecGetArrayRead()` and `VecGetArray()` respectively. One can read-only or read/write the returned Kokkos View.

Passing in a const View enables read-only access.

One must return the View by a matching `VecRestoreKokkosView()` after finishing using the View. Currently, only two memory
spaces are supported: Kokkos::HostSpace and Kokkos::DefaultExecutionSpace::memory_space.
If needed, a memory copy will be internally called to copy the latest vector data to the specified memory space.




## See Also
 `VecRestoreKokkosView()`, `VecRestoreArray()`, `VecGetKokkosViewWrite()`, `VecGetArrayRead()`, `VecGetArrays()`, `VecGetArrayF90()`, `VecGetArrayReadF90()`, `VecPlaceArray()`, `VecGetArray2d()`,
`VecGetArrayPair()`, `VecRestoreArrayPair()`, `VecGetArrayWrite()`, `VecRestoreArrayWrite()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscvec_kokkos.hpp#VecGetKokkosView">include/petscvec_kokkos.hpp</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscvec_kokkos.hpp)


[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)  
