Actual source code: viewa.c

  1: #define PETSC_DLL

  3: #include "src/sys/viewer/viewerimpl.h"  /*I "petsc.h" I*/  

  7: /*@C
  8:    PetscViewerSetFormat - Sets the format for PetscViewers.

 10:    Collective on PetscViewer

 12:    Input Parameters:
 13: +  viewer - the PetscViewer
 14: -  format - the format

 16:    Level: intermediate

 18:    Notes:
 19:    Available formats include
 20: +    PETSC_VIEWER_ASCII_DEFAULT - default format
 21: .    PETSC_VIEWER_ASCII_MATLAB - Matlab format
 22: .    PETSC_VIEWER_ASCII_DENSE - print matrix as dense
 23: .    PETSC_VIEWER_ASCII_IMPL - implementation-specific format
 24:       (which is in many cases the same as the default)
 25: .    PETSC_VIEWER_ASCII_INFO - basic information about object
 26: .    PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
 27:        about object
 28: .    PETSC_VIEWER_ASCII_COMMON - identical output format for
 29:        all objects of a particular type
 30: .    PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
 31:        element number next to each vector entry
 32: .    PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without
 33:        indicating the processor ranges
 34: .    PETSC_VIEWER_BINARY_NATIVE - store the object to the binary
 35:       file in its native format (for example, dense
 36:        matrices are stored as dense)
 37: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
 38: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
 39: -    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot

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

 43:    If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer
 44:   where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior
 45:   for that viewer to be used.
 46:  
 47:    Concepts: PetscViewer^setting format

 49: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
 50:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
 51: @*/
 52: PetscErrorCode PETSC_DLLEXPORT PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
 53: {
 56:   viewer->format     = format;
 57:   return(0);
 58: }

 62: /*@C
 63:    PetscViewerPushFormat - Sets the format for file PetscViewers.

 65:    Collective on PetscViewer

 67:    Input Parameters:
 68: +  viewer - the PetscViewer
 69: -  format - the format

 71:    Level: intermediate

 73:    Notes:
 74:    Available formats include
 75: +    PETSC_VIEWER_ASCII_DEFAULT - default format
 76: .    PETSC_VIEWER_ASCII_MATLAB - Matlab format
 77: .    PETSC_VIEWER_ASCII_IMPL - implementation-specific format
 78:       (which is in many cases the same as the default)
 79: .    PETSC_VIEWER_ASCII_INFO - basic information about object
 80: .    PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
 81:        about object
 82: .    PETSC_VIEWER_ASCII_COMMON - identical output format for
 83:        all objects of a particular type
 84: .    PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
 85:        element number next to each vector entry
 86: .    PETSC_VIEWER_BINARY_NATIVE - store the object to the binary
 87:       file in its native format (for example, dense
 88:        matrices are stored as dense)
 89: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
 90: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
 91: .    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot
 92: -    PETSC_VIEWER_NATIVE - for DA vectors displays vectors in DA ordering, not natural

 94:    These formats are most often used for viewing matrices and vectors.
 95:    Currently, the object name is used only in the Matlab format.

 97:    Concepts: PetscViewer^setting format

 99: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
100:           PetscViewerSetFormat(), PetscViewerPopFormat()
101: @*/
102: PetscErrorCode PETSC_DLLEXPORT PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format)
103: {
106:   if (viewer->iformat > 9) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Too many pushes");

108:   viewer->formats[viewer->iformat++]  = viewer->format;
109:   viewer->format                      = format;

111:   return(0);
112: }

116: /*@C
117:    PetscViewerPopFormat - Resets the format for file PetscViewers.

119:    Collective on PetscViewer

121:    Input Parameters:
122: .  viewer - the PetscViewer

124:    Level: intermediate

126:    Concepts: PetscViewer^setting format

128: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
129:           PetscViewerSetFormat(), PetscViewerPushFormat()
130: @*/
131: PetscErrorCode PETSC_DLLEXPORT PetscViewerPopFormat(PetscViewer viewer)
132: {
135:   if (viewer->iformat <= 0) return(0);

137:   viewer->format = viewer->formats[--viewer->iformat];
138:   return(0);
139: }

143: PetscErrorCode PETSC_DLLEXPORT PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
144: {
146:   *format =  viewer->format;
147:   return(0);
148: }