Date: 2013-07-02T14:38:14+00:00

Actual source code: viewa.c
petsc-3.4.2 2013-07-02

      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_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:   "DRAW_BASIC",
     24:   "DRAW_LG",
     25:   "DRAW_CONTOUR",
     26:   "DRAW_PORTS",
     27:   "VTK_VTS",
     28:   "VTK_VTU",
     29:   "BINARY_MATLAB",
     30:   "NATIVE",
     31:   "NOFORMAT",
     32:   "PetscViewerFormat",
     33:   "PETSC_VIEWER_",
     34:   0
     35: };

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

     42:    Logically Collective on PetscViewer

     44:    Input Parameters:
     45: +  viewer - the PetscViewer
     46: -  format - the format

     48:    Level: intermediate

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

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

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

     81:    Concepts: PetscViewer^setting format

     83: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), PetscViewerType,
     84:           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
     85: @*/
     86: PetscErrorCode  PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
     87: {
     89:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
     92:   viewer->format = format;
     93:   return(0);
     94: }

     98: /*@C
     99:    PetscViewerPushFormat - Sets the format for file PetscViewers.

    101:    Logically Collective on PetscViewer

    103:    Input Parameters:
    104: +  viewer - the PetscViewer
    105: -  format - the format

    107:    Level: intermediate

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

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

    132:    Concepts: PetscViewer^setting format

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

    144:   viewer->formats[viewer->iformat++] = viewer->format;
    145:   viewer->format                     = format;
    146:   return(0);
    147: }

    151: /*@C
    152:    PetscViewerPopFormat - Resets the format for file PetscViewers.

    154:    Logically Collective on PetscViewer

    156:    Input Parameters:
    157: .  viewer - the PetscViewer

    159:    Level: intermediate

    161:    Concepts: PetscViewer^setting format

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

    172:   viewer->format = viewer->formats[--viewer->iformat];
    173:   return(0);
    174: }

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