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:   "PetscViewerFormat",
 45:   "PETSC_VIEWER_",
 46:   NULL
 47: };

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

 52:    Logically Collective on PetscViewer

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

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

 60:    Level: intermediate

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

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

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

 93:     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

 95: .seealso: PetscViewerGetFormat(), PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), PetscViewerType,
 96:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
 97: @*/
 98: PetscErrorCode  PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
 99: {
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: {
151:   if (viewer->iformat > PETSCVIEWERFORMATPUSHESMAX-1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many PetscViewerPushFormat(), perhaps you forgot PetscViewerPopFormat()?");

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

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

161:    Logically Collective on PetscViewer

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

166:    Level: intermediate

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

177:   viewer->format = viewer->formats[--viewer->iformat];
178:   return(0);
179: }

181: /*@C
182:    PetscViewerGetFormat - Gets the format for PetscViewers.

184:    Not collective

186:    Input Parameter:
187: .  viewer - the PetscViewer

189:    Output Parameter:
190: -  format - the format

192:    Level: intermediate

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

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

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

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