VecGetArray#

Returns a pointer to a contiguous array that contains this MPI processes’s portion of the vector data

Synopsis#

#include "petscvec.h"   
PetscErrorCode VecGetArray(Vec x, PetscScalar **a)

Logically Collective

Input Parameter#

  • x - the vector

Output Parameter#

  • a - location to put pointer to the array

Notes#

For the standard PETSc vectors, VecGetArray() returns a pointer to the local data array and does not use any copies. If the underlying vector data is not stored in a contiguous array this routine will copy the data to a contiguous array and return a pointer to that. You MUST call VecRestoreArray() when you no longer need access to the array.

Fortran Notes#

VecGetArray() Fortran binding is deprecated (since PETSc 3.19), use VecGetArrayF90()

See Also#

Vectors and Parallel Data, Vec, VecRestoreArray(), VecGetArrayRead(), VecGetArrays(), VecGetArrayF90(), VecGetArrayReadF90(), VecPlaceArray(), VecGetArray2d(), VecGetArrayPair(), VecRestoreArrayPair(), VecGetArrayWrite(), VecRestoreArrayWrite()

Level#

beginner

Location#

src/vec/vec/interface/rvector.c

Examples#

src/tao/complementarity/tutorials/blackscholes.c
src/tao/bound/tutorials/plate2.c
src/tao/complementarity/tutorials/minsurf1.c
src/tao/unconstrained/tutorials/rosenbrock1f.F90
src/tao/unconstrained/tutorials/rosenbrock1.c
src/tao/leastsquares/tutorials/cs1.c
src/tao/leastsquares/tutorials/chwirut1.c
src/tao/leastsquares/tutorials/chwirut2.c
src/tao/unconstrained/tutorials/rosenbrock2.c
src/tao/bound/tutorials/jbearing2.c

Implementations#

VecGetArray_Nest() in src/vec/vec/impls/nest/vecnest.c
VecGetArray_SeqKokkos() in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx
VecGetArray_SeqViennaCL() in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx


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