Actual source code: viewa.c

petsc-master 2017-02-23
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:   "DRAW_BASIC",
 25:   "DRAW_LG",
 26:   "DRAW_CONTOUR",
 27:   "DRAW_PORTS",
 28:   "VTK_VTS",
 29:   "VTK_VTR",
 30:   "VTK_VTU",
 31:   "BINARY_MATLAB",
 32:   "NATIVE",
 33:   "HDF5_VIZ",
 34:   "NOFORMAT",
 35:   "PetscViewerFormat",
 36:   "PETSC_VIEWER_",
 37:   0
 38: };

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

 43:    Logically Collective on PetscViewer

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

 47:    Input Parameters:
 48: +  viewer - the PetscViewer
 49: -  format - the format

 51:    Level: intermediate

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

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

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

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

 86:    Concepts: PetscViewer^setting format

 88: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), PetscViewerType,
 89:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
 90: @*/
 91: PetscErrorCode  PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
 92: {
 94:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
 97:   viewer->format = format;
 98:   return(0);
 99: }

101: /*@C
102:    PetscViewerPushFormat - Sets the format for file PetscViewers.

104:    Logically Collective on PetscViewer

106:    Input Parameters:
107: +  viewer - the PetscViewer
108: -  format - the format

110:    Level: intermediate

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

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

135:    Concepts: PetscViewer^setting format

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

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

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

177: PetscErrorCode  PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
178: {
180:   *format =  viewer->format;
181:   return(0);
182: }