petsc-3.7.1 2016-05-15
Report Typos and Errors

VecRestoreArray

Restores a vector after VecGetArray() has been called.

Synopsis

#include "petscvec.h"   
PetscErrorCode VecRestoreArray(Vec x,PetscScalar **a)
Logically Collective on Vec Many br

Input Parameters

x - the vector Many br
a - location of pointer to array obtained from VecGetArray() Many br

Many br

Notes

For regular PETSc vectors this routine does not involve any copies. For Many brany special vectors that do not store local vector data in a contiguous Many brarray, this routine will copy the data back into the underlying Many brvector data structure from the array obtained with VecGetArray(). Many br

This routine actually zeros out the a pointer. This is to prevent accidental Many brus of the array after it has been restored. If you pass null for a it will Many brnot zero the array pointer a. Many br

Fortran Note

This routine is used differently from Fortran 77 Many br
   Vec         x
   PetscScalar x_array(1)
   PetscOffset i_x
   PetscErrorCode ierr
      call VecGetArray(x,x_array,i_x,ierr)

  Access first local entry in vector with
     value = x_array(i_x + 1)

     ...... other code
      call VecRestoreArray(x,x_array,i_x,ierr)

See the Fortran chapter of the users manual and Many brpetsc/src/snes/examples/tutorials/ex5f.F for details. Many brFor Fortran 90 see VecRestoreArrayF90() Many br

See Also

VecGetArray(), VecRestoreArrayRead(), VecRestoreArrays(), VecRestoreArrayF90(), VecRestoreArrayReadF90(), VecPlaceArray(), VecRestoreArray2d()

Level:beginner
Location:
src/vec/vec/interface/rvector.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages src/vec/vec/examples/tutorials/ex3.c.html
src/vec/vec/examples/tutorials/ex6.c.html
src/vec/vec/examples/tutorials/ex9.c.html
src/vec/vec/examples/tutorials/ex18.c.html
src/vec/vec/examples/tutorials/ex19.c.html
src/vec/vec/examples/tutorials/ex21.c.html
src/vec/vec/examples/tutorials/ex4f.F.html
src/vec/vec/examples/tutorials/ex4f90.F.html
src/vec/is/sf/examples/tutorials/ex2.c.html
src/mat/examples/tutorials/ex4.c.html