Actual source code: viewa.c


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

  4: const char *const PetscViewerFormats[] = {"DEFAULT", "ASCII_MATLAB", "ASCII_MATHEMATICA", "ASCII_IMPL", "ASCII_INFO", "ASCII_INFO_DETAIL", "ASCII_COMMON", "ASCII_SYMMODU", "ASCII_INDEX", "ASCII_DENSE", "ASCII_MATRIXMARKET", "ASCII_VTK", "ASCII_VTK_CELL", "ASCII_VTK_COORDS", "ASCII_PCICE", "ASCII_PYTHON", "ASCII_FACTOR_INFO", "ASCII_LATEX", "ASCII_XML", "ASCII_FLAMEGRAPH", "ASCII_GLVIS", "ASCII_CSV", "DRAW_BASIC", "DRAW_LG", "DRAW_LG_XRANGE", "DRAW_CONTOUR", "DRAW_PORTS", "VTK_VTS", "VTK_VTR", "VTK_VTU", "BINARY_MATLAB", "NATIVE", "HDF5_PETSC", "HDF5_VIZ", "HDF5_XDMF", "HDF5_MAT", "NOFORMAT", "LOAD_BALANCE", "FAILED", "ALL", "PetscViewerFormat", "PETSC_VIEWER_", NULL};

  6: /*@C
  7:    PetscViewerSetFormat - Sets the format for a `PetscViewer`.

  9:    Logically Collective on viewer

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

 13:    Input Parameters:
 14: +  viewer - the `PetscViewer`
 15: -  format - the format

 17:    Level: intermediate

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

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

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

 50:     Note:
 51:     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

 53: .seealso: `PetscViewerGetFormat()`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`,
 54:           `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen()`, `PetscViewerSocketOpen()`
 55: @*/
 56: PetscErrorCode PetscViewerSetFormat(PetscViewer viewer, PetscViewerFormat format)
 57: {
 58:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
 61:   viewer->format = format;
 62:   return 0;
 63: }

 65: /*@C
 66:    PetscViewerPushFormat - Sets the format for a `PetscViewer`.

 68:    Logically Collective on viewer

 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
 95: -    `PETSC_VIEWER_ASCII_XML` - saves the data in XML format, needed for `PetscLogView()` when viewing with `PetscLogNestedBegin()`

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

100: .seealso: `PetscViewer`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`,
101:           `PetscViewerSetFormat()`, `PetscViewerPopFormat()`
102: @*/
103: PetscErrorCode PetscViewerPushFormat(PetscViewer viewer, PetscViewerFormat format)
104: {

109:   viewer->formats[viewer->iformat++] = viewer->format;
110:   viewer->format                     = format;
111:   return 0;
112: }

114: /*@C
115:    PetscViewerPopFormat - Resets the format for a `PetscViewer`.

117:    Logically Collective on viewer

119:    Input Parameters:
120: .  viewer - the `PetscViewer`

122:    Level: intermediate

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

132:   viewer->format = viewer->formats[--viewer->iformat];
133:   return 0;
134: }

136: /*@C
137:    PetscViewerGetFormat - Gets the current format for `PetscViewer`.

139:    Not collective

141:    Input Parameter:
142: .  viewer - the `PetscViewer`

144:    Output Parameter:
145: .  format - the format

147:    Level: intermediate

149:    Notes:
150:    Available formats include
151: +    `PETSC_VIEWER_DEFAULT` - default format
152: .    `PETSC_VIEWER_ASCII_MATLAB` - MATLAB format
153: .    `PETSC_VIEWER_ASCII_DENSE` - print matrix as dense
154: .    `PETSC_VIEWER_ASCII_IMPL` - implementation-specific format
155:       (which is in many cases the same as the default)
156: .    `PETSC_VIEWER_ASCII_INFO` - basic information about object
157: .    `PETSC_VIEWER_ASCII_INFO_DETAIL` - more detailed info
158:        about object
159: .    `PETSC_VIEWER_ASCII_COMMON` - identical output format for
160:        all objects of a particular type
161: .    `PETSC_VIEWER_ASCII_INDEX` - (for vectors) prints the vector
162:        element number next to each vector entry
163: .    `PETSC_VIEWER_ASCII_SYMMODU` - print parallel vectors without
164:        indicating the processor ranges
165: .    `PETSC_VIEWER_ASCII_VTK` - outputs the object to a VTK file (deprecated since v3.14)
166: .    `PETSC_VIEWER_NATIVE` - store the object to the binary
167:        file in its native format (for example, dense
168:        matrices are stored as dense), DMDA vectors are dumped directly to the
169:        file instead of being first put in the natural ordering
170: .    `PETSC_VIEWER_DRAW_BASIC` - views the vector with a simple 1d plot
171: .    `PETSC_VIEWER_DRAW_LG` - views the vector with a line graph
172: -    `PETSC_VIEWER_DRAW_CONTOUR` - views the vector with a contour plot

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

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

180: .seealso: `PetscViewer`, `PetscViewerSetFormat()`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`,
181:           `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen()`, `PetscViewerSocketOpen()`
182: @*/
183: PetscErrorCode PetscViewerGetFormat(PetscViewer viewer, PetscViewerFormat *format)
184: {
185:   *format = viewer->format;
186:   return 0;
187: }