Actual source code: viewa.c


  2: #include <petsc/private/viewerimpl.h>

  4: const char *const PetscViewerFormats[] = {"DEFAULT", "ASCII_MATLAB", "ASCII_MATHEMATICA", "ASCII_IMPL", "ASCII_INFO", "ASCII_INFO_DETAIL", "ASCII_COMMON", "ASCII_SYMMODU", "ASCII_INDEX", "ASCII_DENSE", "ASCII_MATRIXMARKET", "ASCII_VTK", "ASCII_VTK_CELL", "ASCII_VTK_COORDS", "ASCII_PCICE", "ASCII_PYTHON", "ASCII_FACTOR_INFO", "ASCII_LATEX", "ASCII_XML", "ASCII_FLAMEGRAPH", "ASCII_GLVIS", "ASCII_CSV", "DRAW_BASIC", "DRAW_LG", "DRAW_LG_XRANGE", "DRAW_CONTOUR", "DRAW_PORTS", "VTK_VTS", "VTK_VTR", "VTK_VTU", "BINARY_MATLAB", "NATIVE", "HDF5_PETSC", "HDF5_VIZ", "HDF5_XDMF", "HDF5_MAT", "NOFORMAT", "LOAD_BALANCE", "FAILED", "ALL", "PetscViewerFormat", "PETSC_VIEWER_", NULL};

  6: /*@C
  7:    PetscViewerSetFormat - Sets the format for a `PetscViewer`.

  9:    Logically Collective

 11:    This routine is deprecated, you should use `PetscViewerPushFormat()`/`PetscViewerPopFormat()`

 13:    Input Parameters:
 14: +  viewer - the `PetscViewer`
 15: -  format - the format

 17:    Level: deprecated

 19:    Note:
 20:    See `PetscViewerFormat` for available values

 22: .seealso: [](sec_viewers), `PetscViewerGetFormat()`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`,
 23:           `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen()`, `PetscViewerSocketOpen()`
 24: @*/
 25: PetscErrorCode PetscViewerSetFormat(PetscViewer viewer, PetscViewerFormat format)
 26: {
 27:   PetscFunctionBegin;
 28:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
 31:   viewer->format = format;
 32:   PetscFunctionReturn(PETSC_SUCCESS);
 33: }

 35: /*@C
 36:    PetscViewerPushFormat - Sets the format for a `PetscViewer`.

 38:    Logically Collective

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

 44:    Level: intermediate

 46:    Note:
 47:    See `PetscViewerFormat` for available values

 49: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerFormat`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`,
 50:           `PetscViewerSetFormat()`, `PetscViewerPopFormat()`
 51: @*/
 52: PetscErrorCode PetscViewerPushFormat(PetscViewer viewer, PetscViewerFormat format)
 53: {
 54:   PetscFunctionBegin;
 57:   PetscCheck(viewer->iformat <= PETSCVIEWERFORMATPUSHESMAX - 1, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Too many PetscViewerPushFormat(), perhaps you forgot PetscViewerPopFormat()?");

 59:   viewer->formats[viewer->iformat++] = viewer->format;
 60:   viewer->format                     = format;
 61:   PetscFunctionReturn(PETSC_SUCCESS);
 62: }

 64: /*@C
 65:    PetscViewerPopFormat - Resets the format for a `PetscViewer` to the value it had before the previous call to `PetscViewerPushFormat()`

 67:    Logically Collective

 69:    Input Parameter:
 70: .  viewer - the `PetscViewer`

 72:    Level: intermediate

 74: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerFormat`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`,
 75:           `PetscViewerSetFormat()`, `PetscViewerPushFormat()`
 76: @*/
 77: PetscErrorCode PetscViewerPopFormat(PetscViewer viewer)
 78: {
 79:   PetscFunctionBegin;
 81:   if (viewer->iformat <= 0) PetscFunctionReturn(PETSC_SUCCESS);

 83:   viewer->format = viewer->formats[--viewer->iformat];
 84:   PetscFunctionReturn(PETSC_SUCCESS);
 85: }

 87: /*@C
 88:    PetscViewerGetFormat - Gets the current format for `PetscViewer`.

 90:    Not Collective

 92:    Input Parameter:
 93: .  viewer - the `PetscViewer`

 95:    Output Parameter:
 96: .  format - the format

 98:    Level: intermediate

100:    Note:
101:    See `PetscViewerFormat` for available values

103: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`,
104:           `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen()`, `PetscViewerSocketOpen()`
105: @*/
106: PetscErrorCode PetscViewerGetFormat(PetscViewer viewer, PetscViewerFormat *format)
107: {
108:   PetscFunctionBegin;
109:   *format = viewer->format;
110:   PetscFunctionReturn(PETSC_SUCCESS);
111: }