Actual source code: viewa.c


  2: #include <petsc/private/viewerimpl.h>

  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:   "ASCII_XML",
 24:   "ASCII_FLAMEGRAPH",
 25:   "ASCII_GLVIS",
 26:   "ASCII_CSV",
 27:   "DRAW_BASIC",
 28:   "DRAW_LG",
 29:   "DRAW_LG_XRANGE",
 30:   "DRAW_CONTOUR",
 31:   "DRAW_PORTS",
 32:   "VTK_VTS",
 33:   "VTK_VTR",
 34:   "VTK_VTU",
 35:   "BINARY_MATLAB",
 36:   "NATIVE",
 37:   "HDF5_PETSC",
 38:   "HDF5_VIZ",
 39:   "HDF5_XDMF",
 40:   "HDF5_MAT",
 41:   "NOFORMAT",
 42:   "LOAD_BALANCE",
 43:   "FAILED",
 44:   "ALL",
 45:   "PetscViewerFormat",
 46:   "PETSC_VIEWER_",
 47:   NULL
 48: };

 50: /*@C
 51:    PetscViewerSetFormat - Sets the format for PetscViewers.

 53:    Logically Collective on PetscViewer

 55:    This routine is deprecated, you should use PetscViewerPushFormat()/PetscViewerPopFormat()

 57:    Input Parameters:
 58: +  viewer - the PetscViewer
 59: -  format - the format

 61:    Level: intermediate

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

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

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

 94:     Note: This supports passing in a NULL for the viewer for use in the debugger, but it should never be called in the code with a NULL viewer

 96: .seealso: PetscViewerGetFormat(), PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), PetscViewerType,
 97:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
 98: @*/
 99: PetscErrorCode  PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
100: {
101:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
104:   viewer->format = format;
105:   return 0;
106: }

108: /*@C
109:    PetscViewerPushFormat - Sets the format for file PetscViewers.

111:    Logically Collective on PetscViewer

113:    Input Parameters:
114: +  viewer - the PetscViewer
115: -  format - the format

117:    Level: intermediate

119:    Notes:
120:    Available formats include
121: +    PETSC_VIEWER_DEFAULT - default format
122: .    PETSC_VIEWER_ASCII_MATLAB - MATLAB format
123: .    PETSC_VIEWER_ASCII_IMPL - implementation-specific format
124:       (which is in many cases the same as the default)
125: .    PETSC_VIEWER_ASCII_INFO - basic information about object
126: .    PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
127:        about object
128: .    PETSC_VIEWER_ASCII_COMMON - identical output format for
129:        all objects of a particular type
130: .    PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
131:        element number next to each vector entry
132: .    PETSC_VIEWER_NATIVE - store the object to the binary
133:        file in its native format (for example, dense
134:        matrices are stored as dense), for DMDA vectors displays vectors in DMDA ordering, not natural
135: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
136: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
137: .    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot
138: -    PETSC_VIEWER_ASCII_XML - saves the data in XML format, needed for PetscLogView() when viewing with PetscLogNestedBegin()

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

143: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
144:           PetscViewerSetFormat(), PetscViewerPopFormat()
145: @*/
146: PetscErrorCode  PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format)
147: {

152:   viewer->formats[viewer->iformat++] = viewer->format;
153:   viewer->format                     = format;
154:   return 0;
155: }

157: /*@C
158:    PetscViewerPopFormat - Resets the format for file PetscViewers.

160:    Logically Collective on PetscViewer

162:    Input Parameters:
163: .  viewer - the PetscViewer

165:    Level: intermediate

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

175:   viewer->format = viewer->formats[--viewer->iformat];
176:   return 0;
177: }

179: /*@C
180:    PetscViewerGetFormat - Gets the format for PetscViewers.

182:    Not collective

184:    Input Parameter:
185: .  viewer - the PetscViewer

187:    Output Parameter:
188: .  format - the format

190:    Level: intermediate

192:    Notes:
193:    Available formats include
194: +    PETSC_VIEWER_DEFAULT - default format
195: .    PETSC_VIEWER_ASCII_MATLAB - MATLAB format
196: .    PETSC_VIEWER_ASCII_DENSE - print matrix as dense
197: .    PETSC_VIEWER_ASCII_IMPL - implementation-specific format
198:       (which is in many cases the same as the default)
199: .    PETSC_VIEWER_ASCII_INFO - basic information about object
200: .    PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
201:        about object
202: .    PETSC_VIEWER_ASCII_COMMON - identical output format for
203:        all objects of a particular type
204: .    PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
205:        element number next to each vector entry
206: .    PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without
207:        indicating the processor ranges
208: .    PETSC_VIEWER_ASCII_VTK - outputs the object to a VTK file (deprecated since v3.14)
209: .    PETSC_VIEWER_NATIVE - store the object to the binary
210:        file in its native format (for example, dense
211:        matrices are stored as dense), DMDA vectors are dumped directly to the
212:        file instead of being first put in the natural ordering
213: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
214: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
215: -    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot

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

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

223: .seealso: PetscViewerSetFormat(), PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), PetscViewerType,
224:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
225: @*/
226: PetscErrorCode PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
227: {
228:   *format =  viewer->format;
229:   return 0;
230: }