#include "petscvec.h" PetscErrorCode VecView(Vec vec,PetscViewer viewer)Collective on Vec
vec | - the vector | |
viewer | - an optional visualization context |
PETSC_VIEWER_STDOUT_SELF | - for sequential vectors | |
PETSC_VIEWER_STDOUT_WORLD | - for parallel vectors created on PETSC_COMM_WORLD | |
PETSC_VIEWER_STDOUT_(comm) | - for parallel vectors created on MPI communicator comm |
You can change the format the vector is printed using the option PetscViewerPushFormat().
The user can open alternative viewers with
PetscViewerASCIIOpen() | - Outputs vector to a specified file | |
PetscViewerBinaryOpen() | - Outputs vector in binary to a specified file; corresponding input uses VecLoad() | |
PetscViewerDrawOpen() | - Outputs vector to an X window display | |
PetscViewerSocketOpen() | - Outputs vector to Socket viewer | |
PetscViewerHDF5Open() | - Outputs vector to HDF5 file viewer |
The user can call PetscViewerPushFormat() to specify the output format of ASCII printed objects (when using PETSC_VIEWER_STDOUT_SELF, PETSC_VIEWER_STDOUT_WORLD and PetscViewerASCIIOpen). Available formats include
PETSC_VIEWER_DEFAULT | - default, prints vector contents | |
PETSC_VIEWER_ASCII_MATLAB | - prints vector contents in MATLAB format | |
PETSC_VIEWER_ASCII_INDEX | - prints vector contents, including indices of vector elements | |
PETSC_VIEWER_ASCII_COMMON | - prints vector contents, using a format common among all vector types |
In the debugger you can do "call VecView(v,0)" to display the vector. (The same holds for any PETSc object viewer).
If the blocksize of the vector is greater than one then you must provide a unique prefix to the vector with PetscObjectSetOptionsPrefix((PetscObject)vec,"uniqueprefix"); BEFORE calling VecView() on the vector to be stored and then set that same unique prefix on the vector that you pass to VecLoad(). The blocksize information is stored in an ASCII file with the same name as the binary file plus a ".info" appended to the filename. If you copy the binary file, make sure you copy the associated .info file with it.
See the manual page for VecLoad() on the exact format the binary viewer stores the values in the file.
If the block size of the vector is greater than 1 then it is used as the first dimension in the HDF5 array. If the function PetscViewerHDF5SetBaseDimension2()is called then even if the block size is one it will be used as the first dimension in the HDF5 array (that is the HDF5 array will always be two dimensional) See also PetscViewerHDF5SetTimestep() which adds an additional complication to reading and writing Vecs with the HDF5 viewer.