VecLoadIntoVector

Loads a vector that has been stored in binary (or HDF5) format with VecView().

Synopsis

#include "petscvec.h" 
PetscErrorCode  VecLoadIntoVector(PetscViewer viewer,Vec vec)
Collective on PetscViewer

Input Parameters

viewer - binary file viewer, obtained from PetscViewerBinaryOpen()
vec - vector to contain files values (must be of correct length)

Notes

The input file must contain the full global vector, as written by the routine VecView().

Use VecLoad() to create the vector as the values are read in

If using HDF5, you must assign the Vec the same name as was used in the Vec that was stored in the file using PetscObjectSetName(). Otherwise you will get the error message

    Cannot H5Dopen2() with Vec named NAMEOFOBJECT

Notes for advanced users

Most users should not need to know the details of the binary storage format, since VecLoad() and VecView() completely hide these details. But for anyone who's interested, the standard binary matrix storage format is
     int    VEC_FILE_COOKIE
     int    number of rows
     PetscScalar *values of all nonzeros

In addition, PETSc automatically does the byte swapping for machines that store the bytes reversed, e.g. DEC alpha, freebsd, linux, Windows and the paragon; thus if you write your own binary read/write routines you have to swap the bytes; see PetscBinaryRead() and PetscBinaryWrite() to see how this may be done.

See Also

PetscViewerBinaryOpen(), VecView(), MatLoad(), VecLoad()

Level:intermediate
Location:
src/vec/vec/interface/vector.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/dm/da/examples/tutorials/ex9.c.html
src/ksp/ksp/examples/tutorials/ex10.c.html
src/snes/examples/tutorials/ex29.c.html