Actual source code: viewa.c

  1: /*$Id: viewa.c,v 1.23 2001/04/10 19:34:10 bsmith Exp $*/

  3: #include "src/sys/src/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_BINARY_NATIVE - store the object to the binary
 33:       file in its native format (for example, dense
 34:        matrices are stored as dense)
 35: .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
 36: .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
 37: -    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot

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

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

 47: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
 48:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpenX(),PetscViewerSocketOpen()
 49: @*/
 50: int PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
 51: {
 54:   viewer->format     = format;
 55:   return(0);
 56: }

 60: /*@C
 61:    PetscViewerPushFormat - Sets the format for file PetscViewers.

 63:    Collective on PetscViewer

 65:    Input Parameters:
 66: +  viewer - the PetscViewer
 67: -  format - the format

 69:    Level: intermediate

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

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

 95:    Concepts: PetscViewer^setting format

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

106:   viewer->formats[viewer->iformat++]  = viewer->format;
107:   viewer->format                      = format;

109:   return(0);
110: }

114: /*@C
115:    PetscViewerPopFormat - Resets the format for file PetscViewers.

117:    Collective on PetscViewer

119:    Input Parameters:
120: .  viewer - the PetscViewer

122:    Level: intermediate

124:    Concepts: PetscViewer^setting format

126: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
127:           PetscViewerSetFormat(), PetscViewerPushFormat()
128: @*/
129: int PetscViewerPopFormat(PetscViewer viewer)
130: {
133:   if (viewer->iformat <= 0) return(0);

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

141: int PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
142: {
144:   *format =  viewer->format;
145:   return(0);
146: }