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  PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
 53: {
 55:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
 57:   CHKMEMQ;
 58:   viewer->format     = format;
 59:   CHKMEMQ;
 60:   return(0);
 61: }

 65: /*@C
 66:    PetscViewerPushFormat - Sets the format for file PetscViewers.

 68:    Collective on PetscViewer

 70:    Input Parameters:
 71: +  viewer - the PetscViewer
 72: -  format - the format

 74:    Level: intermediate

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

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

100:    Concepts: PetscViewer^setting format

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

111:   viewer->formats[viewer->iformat++]  = viewer->format;
112:   viewer->format                      = format;

114:   return(0);
115: }

119: /*@C
120:    PetscViewerPopFormat - Resets the format for file PetscViewers.

122:    Collective on PetscViewer

124:    Input Parameters:
125: .  viewer - the PetscViewer

127:    Level: intermediate

129:    Concepts: PetscViewer^setting format

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

140:   viewer->format = viewer->formats[--viewer->iformat];
141:   return(0);
142: }

146: PetscErrorCode  PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
147: {
149:   *format =  viewer->format;
150:   return(0);
151: }