Actual source code: viewa.c

petsc-master 2020-12-02
Report Typos and Errors

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

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

 51:    Logically Collective on PetscViewer

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

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

 59:    Level: intermediate

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

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

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

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

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

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

110:    Logically Collective on PetscViewer

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

116:    Level: intermediate

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

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

142: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
143:           PetscViewerSetFormat(), PetscViewerPopFormat()
144: @*/
145: PetscErrorCode  PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format)
146: {
150:   if (viewer->iformat > PETSCVIEWERFORMATPUSHESMAX-1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many PetscViewerPushFormat(), perhaps you forgot PetscViewerPopFormat()?");

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: {
174:   if (viewer->iformat <= 0) return(0);

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

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

183:    Not collective

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

188:    Output Parameter:
189: -  format - the format

191:    Level: intermediate

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

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

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

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