InsertMode — PETSc 3.22.5 documentation

Skip to main content
`Ctrl`+`K`

# InsertMode

How the entries are combined with the current values in the vectors or matrices

## Synopsis

    typedef enum {
      NOT_SET_VALUES,
      INSERT_VALUES,
      ADD_VALUES,
      MAX_VALUES,
      MIN_VALUES,
      INSERT_ALL_VALUES,
      ADD_ALL_VALUES,
      INSERT_BC_VALUES,
      ADD_BC_VALUES
    } InsertMode;

## Values

- `NOT_SET_VALUES` - do not actually use the values

- `INSERT_VALUES` - replace the current values with the provided values, unless the index is marked as constrained by the `PetscSection`

- `ADD_VALUES` - add the values to the current values, unless the index is marked as constrained by the `PetscSection`

- `MAX_VALUES` - use the maximum of each current value and provided value

- `MIN_VALUES` - use the minimum of each current value and provided value

- `INSERT_ALL_VALUES` - insert, even if indices that are not marked as constrained by the `PetscSection`

- `ADD_ALL_VALUES` - add, even if indices that are not marked as constrained by the `PetscSection`

- `INSERT_BC_VALUES` - insert, but ignore indices that are not marked as constrained by the `PetscSection`

- `ADD_BC_VALUES` - add, but ignore indices that are not marked as constrained by the `PetscSection`

## Note

The `PetscSection` that determines the effects of the `InsertMode` values can be obtained by the `Vec` object with `VecGetDM()` and `DMGetLocalSection()`.

Not all options are supported for all operations or PETSc object types.

## See Also

`VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`

## Level

beginner

## Location

include/petscsystypes.h

## Examples

src/snes/tutorials/ex69.c
src/dm/dt/dualspace/impls/lagrange/tutorials/ex2.c
src/snes/tutorials/ex62.c
src/snes/tutorials/ex12.c
src/snes/tutorials/ex76.c
src/snes/tutorials/ex63.c
src/snes/tutorials/ex71.c
src/dm/field/tutorials/ex1.c
src/snes/tutorials/ex77.c
src/snes/tutorials/ex11.c

## Examples

src/snes/tutorials/ex12.c

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages