VecCreateFromOptions — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# VecCreateFromOptions

Creates a vector whose type is set from the options database

## Synopsis

    #include "petscvec.h"
    PetscErrorCode VecCreateFromOptions(MPI_Comm comm, const char *prefix, PetscInt bs, PetscInt m, PetscInt n, Vec *vec)

Collective

## Input Parameters

- comm - The communicator for the vector object

- prefix - [optional] prefix for the options database

- bs - the block size (commonly 1)

- m - the local size (or `PETSC_DECIDE`)

- n - the global size (or `PETSC_DETERMINE`)

## Output Parameter

- vec - The vector object

## Options Database Keys

- -vec_type - see `VecType`, for example `seq`, `mpi`, `cuda`, defaults to `mpi`

## See Also

Vectors and Parallel Data, `Vec`, `VecSetType()`, `VecSetSizes()`, `VecCreateMPIWithArray()`, `VecCreateMPI()`, `VecDuplicate()`, `VecDuplicateVecs()`, `VecCreateGhost()`, `VecCreateSeq()`, `VecPlaceArray()`, `VecCreate()`, `VecType`

## Level

beginner

## Location

src/vec/vec/interface/veccreate.c

## Examples

src/vec/vec/tutorials/ex42a.c
src/ksp/ksp/tutorials/ex57f.F90
src/vec/vec/tutorials/ex2f.F90
src/ksp/ksp/tutorials/ex15f.F90
src/ksp/ksp/tutorials/ex52f.F90
src/ksp/ksp/tutorials/ex2f.F90
src/ts/tutorials/ex11.c
src/dm/field/tutorials/ex1.c
src/ksp/ksp/tutorials/ex77.c

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