Actual source code: viewa.c

  2: #include "src/sys/src/viewer/viewerimpl.h"  /*I "petsc.h" I*/  

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

  9:    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_ASCII_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_BINARY_NATIVE - store the object to the binary
 32:       file in its native format (for example, dense
 33:        matrices are stored as dense)
 34: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
 35: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
 36: -    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot

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

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

 46: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
 47:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpenX(),PetscViewerSocketOpen()
 48: @*/
 49: PetscErrorCode PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
 50: {
 53:   viewer->format     = format;
 54:   return(0);
 55: }

 59: /*@C
 60:    PetscViewerPushFormat - Sets the format for file PetscViewers.

 62:    Collective on PetscViewer

 64:    Input Parameters:
 65: +  viewer - the PetscViewer
 66: -  format - the format

 68:    Level: intermediate

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

 91:    These formats are most often used for viewing matrices and vectors.
 92:    Currently, the object name is used only in the Matlab format.

 94:    Concepts: PetscViewer^setting format

 96: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
 97:           PetscViewerSetFormat(), PetscViewerPopFormat()
 98: @*/
 99: PetscErrorCode PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format)
100: {
103:   if (viewer->iformat > 9) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Too many pushes");

105:   viewer->formats[viewer->iformat++]  = viewer->format;
106:   viewer->format                      = format;

108:   return(0);
109: }

113: /*@C
114:    PetscViewerPopFormat - Resets the format for file PetscViewers.

116:    Collective on PetscViewer

118:    Input Parameters:
119: .  viewer - the PetscViewer

121:    Level: intermediate

123:    Concepts: PetscViewer^setting format

125: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
126:           PetscViewerSetFormat(), PetscViewerPushFormat()
127: @*/
128: PetscErrorCode PetscViewerPopFormat(PetscViewer viewer)
129: {
132:   if (viewer->iformat <= 0) return(0);

134:   viewer->format = viewer->formats[--viewer->iformat];
135:   return(0);
136: }

140: PetscErrorCode PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
141: {
143:   *format =  viewer->format;
144:   return(0);
145: }