next up previous contents
Next: Matrix conversion Up: Interface to user data Previous: Interface to Petsc data

Vector conversion

  Under the assumption that the user application supplies a vector, declared on each processor as
int local_size; Scalar *vec_values;
then this vector can be made acceptable to the preconditioner by the following call:
Vec b; /* the resulting parallel vector in Petsc format */
MPI_Comm comm; /* the MPI context */
  ierr = VecCreateMPIWithArray
           (comm,local_size,vec_values,&b);
The user needs to specify the local local_size.

Since this operation is essentially a pointer redirection, its cost is negligible.

The vector structure needs to be de-allocated by

    VecDestroy(b);
This does not de-allocate the array of values.



Victor Eijkhout
7/27/1998