Actual source code: viewa.c

petsc-dev 2014-04-19
Report Typos and Errors
  2: #include <petsc-private/viewerimpl.h>  /*I "petscsys.h" I*/

  4: const char *const PetscViewerFormats[] = {
  5:   "DEFAULT",
  6:   "ASCII_MATLAB",
  7:   "ASCII_MATHEMATICA",
  8:   "ASCII_IMPL",
  9:   "ASCII_INFO",
 10:   "ASCII_INFO_DETAIL",
 11:   "ASCII_COMMON",
 12:   "ASCII_SYMMODU",
 13:   "ASCII_INDEX",
 14:   "ASCII_DENSE",
 15:   "ASCII_MATRIXMARKET",
 16:   "ASCII_VTK",
 17:   "ASCII_VTK_CELL",
 18:   "ASCII_VTK_COORDS",
 19:   "ASCII_PCICE",
 20:   "ASCII_PYTHON",
 21:   "ASCII_FACTOR_INFO",
 22:   "ASCII_LATEX",
 23:   "DRAW_BASIC",
 24:   "DRAW_LG",
 25:   "DRAW_CONTOUR",
 26:   "DRAW_PORTS",
 27:   "VTK_VTS",
 28:   "VTK_VTR",
 29:   "VTK_VTU",
 30:   "BINARY_MATLAB",
 31:   "NATIVE",
 32:   "NOFORMAT",
 33:   "PetscViewerFormat",
 34:   "PETSC_VIEWER_",
 35:   0
 36: };

 40: /*@C
 41:    PetscViewerSetFormat - Sets the format for PetscViewers.

 43:    Logically Collective on PetscViewer

 45:    Input Parameters:
 46: +  viewer - the PetscViewer
 47: -  format - the format

 49:    Level: intermediate

 51:    Notes:
 52:    Available formats include
 53: +    PETSC_VIEWER_DEFAULT - default format
 54: .    PETSC_VIEWER_ASCII_MATLAB - MATLAB format
 55: .    PETSC_VIEWER_ASCII_DENSE - print matrix as dense
 56: .    PETSC_VIEWER_ASCII_IMPL - implementation-specific format
 57:       (which is in many cases the same as the default)
 58: .    PETSC_VIEWER_ASCII_INFO - basic information about object
 59: .    PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
 60:        about object
 61: .    PETSC_VIEWER_ASCII_COMMON - identical output format for
 62:        all objects of a particular type
 63: .    PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
 64:        element number next to each vector entry
 65: .    PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without
 66:        indicating the processor ranges
 67: .    PETSC_VIEWER_ASCII_VTK - outputs the object to a VTK file
 68: .    PETSC_VIEWER_NATIVE - store the object to the binary
 69:        file in its native format (for example, dense
 70:        matrices are stored as dense), DMDA vectors are dumped directly to the
 71:        file instead of being first put in the natural ordering
 72: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
 73: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
 74: -    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot

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

 78:    If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer
 79:   where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior
 80:   for that viewer to be used.

 82:    Concepts: PetscViewer^setting format

 84: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), PetscViewerType,
 85:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
 86: @*/
 87: PetscErrorCode  PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
 88: {
 90:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
 93:   viewer->format = format;
 94:   return(0);
 95: }

 99: /*@C
100:    PetscViewerPushFormat - Sets the format for file PetscViewers.

102:    Logically Collective on PetscViewer

104:    Input Parameters:
105: +  viewer - the PetscViewer
106: -  format - the format

108:    Level: intermediate

110:    Notes:
111:    Available formats include
112: +    PETSC_VIEWER_DEFAULT - default format
113: .    PETSC_VIEWER_ASCII_MATLAB - MATLAB format
114: .    PETSC_VIEWER_ASCII_IMPL - implementation-specific format
115:       (which is in many cases the same as the default)
116: .    PETSC_VIEWER_ASCII_INFO - basic information about object
117: .    PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
118:        about object
119: .    PETSC_VIEWER_ASCII_COMMON - identical output format for
120:        all objects of a particular type
121: .    PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
122:        element number next to each vector entry
123: .    PETSC_VIEWER_NATIVE - store the object to the binary
124:        file in its native format (for example, dense
125:        matrices are stored as dense), for DMDA vectors displays vectors in DMDA ordering, not natural
126: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
127: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
128: -    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot

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

133:    Concepts: PetscViewer^setting format

135: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
136:           PetscViewerSetFormat(), PetscViewerPopFormat()
137: @*/
138: PetscErrorCode  PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format)
139: {
143:   if (viewer->iformat > 9) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many pushes");

145:   viewer->formats[viewer->iformat++] = viewer->format;
146:   viewer->format                     = format;
147:   return(0);
148: }

152: /*@C
153:    PetscViewerPopFormat - Resets the format for file PetscViewers.

155:    Logically Collective on PetscViewer

157:    Input Parameters:
158: .  viewer - the PetscViewer

160:    Level: intermediate

162:    Concepts: PetscViewer^setting format

164: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
165:           PetscViewerSetFormat(), PetscViewerPushFormat()
166: @*/
167: PetscErrorCode  PetscViewerPopFormat(PetscViewer viewer)
168: {
171:   if (viewer->iformat <= 0) return(0);

173:   viewer->format = viewer->formats[--viewer->iformat];
174:   return(0);
175: }

179: PetscErrorCode  PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
180: {
182:   *format =  viewer->format;
183:   return(0);
184: }