VecGetArrayRead#

Get read-only pointer to contiguous array containing this processor’s portion of the vector data.

Synopsis#

#include "petscvec.h"   
PetscErrorCode VecGetArrayRead(Vec x, const PetscScalar *a[])

Not Collective

Input Parameter#

  • x - the vector

Output Parameter#

  • a - the array

Notes#

The array must be returned using a matching call to VecRestoreArrayRead().

Unlike VecGetArray(), preserves cached information like vector norms.

Standard PETSc vectors use contiguous storage so that this routine does not perform a copy. Other vector implementations may require a copy, but such implementations should cache the contiguous representation so that only one copy is performed when this routine is called multiple times in sequence.

For vectors that may also have the array data in GPU memory, for example, VECCUDA, this call ensures the CPU array has the most recent array values by copying the data from the GPU memory if needed.

See Also#

Vectors and Parallel Data, Vec, VecGetArray(), VecRestoreArray(), VecGetArrayPair(), VecRestoreArrayPair(), VecGetArrayAndMemType()

Level#

beginner

Location#

src/vec/vec/interface/rvector.c

Examples#

src/snes/tutorials/ex6.c
src/snes/tutorials/ex1.c
src/mat/tutorials/ex12.c
src/snes/tutorials/ex59.c
src/snes/tutorials/ex13.c
src/snes/tutorials/ex99.c
src/snes/tutorials/ex63.c
src/snes/tutorials/ex7.c
src/snes/tutorials/ex73f90t.F90
src/snes/tutorials/ex70.c


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