:orphan:
# VecSetValuesLocal
Inserts or adds values into certain locations of a vector, using a local ordering of the nodes. 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecSetValuesLocal(Vec x, PetscInt ni, const PetscInt ix[], const PetscScalar y[], InsertMode iora)
```
Not Collective


## Input Parameters

- ***x -*** vector to insert in
- ***ni -*** number of elements to add
- ***ix -*** indices where to add
- ***y -*** array of values
- ***iora -*** either `INSERT_VALUES` replaces existing entries with new values, `ADD_VALUES` adds values to any existing entries





## Notes
`VecSetValuesLocal()` sets x[ix[i]] = y[i], for i=0,...,ni-1.

Calls to `VecSetValues()` with the `INSERT_VALUES` and `ADD_VALUES`
options cannot be mixed without intervening calls to the assembly
routines.

These values may be cached, so `VecAssemblyBegin()` and `VecAssemblyEnd()`
MUST be called after all calls to `VecSetValuesLocal()` have been completed.

`VecSetValuesLocal()` uses 0-based indices in Fortran as well as in C.


## See Also
 [](ch_vectors), `Vec`, `VecAssemblyBegin()`, `VecAssemblyEnd()`, `VecSetValues()`, `VecSetLocalToGlobalMapping()`,
`VecSetValuesBlockedLocal()`

## Level
intermediate

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex35.cxx.html">src/ksp/ksp/tutorials/ex35.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex36.cxx.html">src/ksp/ksp/tutorials/ex36.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion2.c.html">src/tao/unconstrained/tutorials/eptorsion2.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion2f.F90.html">src/tao/unconstrained/tutorials/eptorsion2f.F90</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex2.c.html">src/ts/tutorials/ex2.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex21.c.html">src/ts/tutorials/ex21.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex3.c.html">src/ts/tutorials/ex3.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex4.c.html">src/ts/tutorials/ex4.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex5.c.html">src/ts/tutorials/ex5.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex6.c.html">src/ts/tutorials/ex6.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex8.c.html">src/vec/vec/tutorials/ex8.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](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
