Actual source code: viewa.c

  2: #include <private/viewerimpl.h>  /*I "petscsys.h" I*/  

  6: /*@C
  7:    PetscViewerSetFormat - Sets the format for PetscViewers.

  9:    Logically Collective on PetscViewer

 11:    Input Parameters:
 12: +  viewer - the PetscViewer
 13: -  format - the format

 15:    Level: intermediate

 17:    Notes:
 18:    Available formats include
 19: +    PETSC_VIEWER_DEFAULT - default format
 20: .    PETSC_VIEWER_ASCII_MATLAB - MATLAB format
 21: .    PETSC_VIEWER_ASCII_DENSE - print matrix as dense
 22: .    PETSC_VIEWER_ASCII_IMPL - implementation-specific format
 23:       (which is in many cases the same as the default)
 24: .    PETSC_VIEWER_ASCII_INFO - basic information about object
 25: .    PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
 26:        about object
 27: .    PETSC_VIEWER_ASCII_COMMON - identical output format for
 28:        all objects of a particular type
 29: .    PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
 30:        element number next to each vector entry
 31: .    PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without
 32:        indicating the processor ranges
 33: .    PETSC_VIEWER_ASCII_VTK - outputs the object to a VTK file
 34: .    PETSC_VIEWER_NATIVE - store the object to the binary
 35:        file in its native format (for example, dense
 36:        matrices are stored as dense), DMDA vectors are dumped directly to the
 37:        file instead of being first put in the natural ordering
 38: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
 39: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
 40: -    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot

 42:    These formats are most often used for viewing matrices and vectors.

 44:    If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer
 45:   where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior
 46:   for that viewer to be used.
 47:  
 48:    Concepts: PetscViewer^setting format

 50: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
 51:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
 52: @*/
 53: PetscErrorCode  PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
 54: {
 56:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
 59:   viewer->format     = format;
 60:   return(0);
 61: }

 65: /*@C
 66:    PetscViewerPushFormat - Sets the format for file PetscViewers.

 68:    Logically Collective on PetscViewer

 70:    Input Parameters:
 71: +  viewer - the PetscViewer
 72: -  format - the format

 74:    Level: intermediate

 76:    Notes:
 77:    Available formats include
 78: +    PETSC_VIEWER_DEFAULT - default format
 79: .    PETSC_VIEWER_ASCII_MATLAB - MATLAB format
 80: .    PETSC_VIEWER_ASCII_IMPL - implementation-specific format
 81:       (which is in many cases the same as the default)
 82: .    PETSC_VIEWER_ASCII_INFO - basic information about object
 83: .    PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
 84:        about object
 85: .    PETSC_VIEWER_ASCII_COMMON - identical output format for
 86:        all objects of a particular type
 87: .    PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
 88:        element number next to each vector entry
 89: .    PETSC_VIEWER_NATIVE - store the object to the binary
 90:        file in its native format (for example, dense
 91:        matrices are stored as dense), for DMDA vectors displays vectors in DMDA ordering, not natural
 92: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
 93: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
 94: -    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot

 96:    These formats are most often used for viewing matrices and vectors.
 97:    Currently, the object name is used only in the MATLAB format.

 99:    Concepts: PetscViewer^setting format

101: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
102:           PetscViewerSetFormat(), PetscViewerPopFormat()
103: @*/
104: PetscErrorCode  PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format)
105: {
109:   if (viewer->iformat > 9) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many pushes");

111:   viewer->formats[viewer->iformat++]  = viewer->format;
112:   viewer->format                      = format;

114:   return(0);
115: }

119: /*@C
120:    PetscViewerPopFormat - Resets the format for file PetscViewers.

122:    Logically Collective on PetscViewer

124:    Input Parameters:
125: .  viewer - the PetscViewer

127:    Level: intermediate

129:    Concepts: PetscViewer^setting format

131: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
132:           PetscViewerSetFormat(), PetscViewerPushFormat()
133: @*/
134: PetscErrorCode  PetscViewerPopFormat(PetscViewer viewer)
135: {
138:   if (viewer->iformat <= 0) return(0);

140:   viewer->format = viewer->formats[--viewer->iformat];
141:   return(0);
142: }

146: PetscErrorCode  PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
147: {
149:   *format =  viewer->format;
150:   return(0);
151: }