Actual source code: viewa.c

petsc-3.3-p7 2013-05-11
  2: #include <petsc-private/viewerimpl.h>  /*I "petscsys.h" I*/  

  4: const char *const PetscViewerFormats[] = {
  5:   "DEFAULT",
  6:   "ASCII_MATLAB",
  7:   "ASCII_MATHEMATICA",
  8:   "ASCII_MATLAB",
  9:   "ASCII_MATHEMATICA",
 10:   "ASCII_IMPL",
 11:   "ASCII_INFO",
 12:   "ASCII_INFO_DETAIL",
 13:   "ASCII_COMMON",
 14:   "ASCII_SYMMODU",
 15:   "ASCII_INDEX",
 16:   "ASCII_DENSE",
 17:   "ASCII_MATRIXMARKET",
 18:   "ASCII_VTK",
 19:   "ASCII_VTK_CELL",
 20:   "ASCII_VTK_COORDS",
 21:   "ASCII_PCICE",
 22:   "ASCII_PYTHON",
 23:   "ASCII_FACTOR_INFO",
 24:   "DRAW_BASIC",
 25:   "DRAW_LG",
 26:   "DRAW_CONTOUR",
 27:   "DRAW_PORTS",
 28:   "VTK_VTS",
 29:   "NATIVE",
 30:   "NOFORMAT"
 31: };

 35: /*@C
 36:    PetscViewerSetFormat - Sets the format for PetscViewers.

 38:    Logically Collective on PetscViewer

 40:    Input Parameters:
 41: +  viewer - the PetscViewer
 42: -  format - the format

 44:    Level: intermediate

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

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

 73:    If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer
 74:   where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior
 75:   for that viewer to be used.
 76:  
 77:    Concepts: PetscViewer^setting format

 79: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
 80:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
 81: @*/
 82: PetscErrorCode  PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
 83: {
 85:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
 88:   viewer->format     = format;
 89:   return(0);
 90: }

 94: /*@C
 95:    PetscViewerPushFormat - Sets the format for file PetscViewers.

 97:    Logically Collective on PetscViewer

 99:    Input Parameters:
100: +  viewer - the PetscViewer
101: -  format - the format

103:    Level: intermediate

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

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

128:    Concepts: PetscViewer^setting format

130: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
131:           PetscViewerSetFormat(), PetscViewerPopFormat()
132: @*/
133: PetscErrorCode  PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format)
134: {
138:   if (viewer->iformat > 9) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many pushes");

140:   viewer->formats[viewer->iformat++]  = viewer->format;
141:   viewer->format                      = format;

143:   return(0);
144: }

148: /*@C
149:    PetscViewerPopFormat - Resets the format for file PetscViewers.

151:    Logically Collective on PetscViewer

153:    Input Parameters:
154: .  viewer - the PetscViewer

156:    Level: intermediate

158:    Concepts: PetscViewer^setting format

160: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
161:           PetscViewerSetFormat(), PetscViewerPushFormat()
162: @*/
163: PetscErrorCode  PetscViewerPopFormat(PetscViewer viewer)
164: {
167:   if (viewer->iformat <= 0) return(0);

169:   viewer->format = viewer->formats[--viewer->iformat];
170:   return(0);
171: }

175: PetscErrorCode  PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
176: {
178:   *format =  viewer->format;
179:   return(0);
180: }