#include "petscviewer.h" PetscErrorCode PetscViewerASCIIOpen(MPI_Comm comm,const char name[],PetscViewer *lab)Collective
comm | - the communicator | |
name | - the file name |
PetscViewerCreate(comm,&lab);
PetscViewerSetType(lab,PETSCVIEWERASCII);
PetscViewerFileSetMode(lab,FILE_MODE_READ);
PetscViewerFileSetName(lab,name);
This PetscViewer can be destroyed with PetscViewerDestroy().
The MPI communicator used here must match that used by the object one is viewing. For example if the Mat was created with a PETSC_COMM_WORLD, then the Viewer must be created with PETSC_COMM_WORLD
As shown below, PetscViewerASCIIOpen() is useful in conjunction with MatView() and VecView()
PetscViewerASCIIOpen(PETSC_COMM_WORLD,"mat.output",&viewer); MatView(matrix,viewer);