Actual source code: viewa.c
  1: #include <petsc/private/viewerimpl.h>
  3: 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};
  5: /*@C
  6:   PetscViewerSetFormat - Sets the format for a `PetscViewer`.
  8:   Logically Collective, No Fortran Support
 10:   This routine is deprecated, you should use `PetscViewerPushFormat()`/`PetscViewerPopFormat()`
 12:   Input Parameters:
 13: + viewer - the `PetscViewer`
 14: - format - the format
 16:   Level: deprecated
 18:   Note:
 19:   See `PetscViewerFormat` for available values
 21: .seealso: [](sec_viewers), `PetscViewerGetFormat()`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`,
 22:           `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen()`, `PetscViewerSocketOpen()`
 23: @*/
 24: PetscErrorCode PetscViewerSetFormat(PetscViewer viewer, PetscViewerFormat format)
 25: {
 26:   PetscFunctionBegin;
 27:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
 30:   viewer->format = format;
 31:   PetscFunctionReturn(PETSC_SUCCESS);
 32: }
 34: /*@
 35:   PetscViewerPushFormat - Sets the format for a `PetscViewer`.
 37:   Logically Collective
 39:   Input Parameters:
 40: + viewer - the `PetscViewer`
 41: - format - the format
 43:   Level: intermediate
 45:   Note:
 46:   See `PetscViewerFormat` for available values
 48: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerFormat`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`,
 49:           `PetscViewerSetFormat()`, `PetscViewerPopFormat()`
 50: @*/
 51: PetscErrorCode PetscViewerPushFormat(PetscViewer viewer, PetscViewerFormat format)
 52: {
 53:   PetscFunctionBegin;
 56:   PetscCheck(viewer->iformat <= PETSCVIEWERFORMATPUSHESMAX - 1, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Too many PetscViewerPushFormat(), perhaps you forgot PetscViewerPopFormat()?");
 58:   viewer->formats[viewer->iformat++] = viewer->format;
 59:   viewer->format                     = format;
 60:   PetscFunctionReturn(PETSC_SUCCESS);
 61: }
 63: /*@
 64:   PetscViewerPopFormat - Resets the format for a `PetscViewer` to the value it had before the previous call to `PetscViewerPushFormat()`
 66:   Logically Collective
 68:   Input Parameter:
 69: . viewer - the `PetscViewer`
 71:   Level: intermediate
 73: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerFormat`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`,
 74:           `PetscViewerSetFormat()`, `PetscViewerPushFormat()`
 75: @*/
 76: PetscErrorCode PetscViewerPopFormat(PetscViewer viewer)
 77: {
 78:   PetscFunctionBegin;
 80:   if (viewer->iformat <= 0) PetscFunctionReturn(PETSC_SUCCESS);
 82:   viewer->format = viewer->formats[--viewer->iformat];
 83:   PetscFunctionReturn(PETSC_SUCCESS);
 84: }
 86: /*@
 87:   PetscViewerGetFormat - Gets the current format for `PetscViewer`.
 89:   Not Collective
 91:   Input Parameter:
 92: . viewer - the `PetscViewer`
 94:   Output Parameter:
 95: . format - the format
 97:   Level: intermediate
 99:   Note:
100:   See `PetscViewerFormat` for available values
102: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`,
103:           `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen()`, `PetscViewerSocketOpen()`
104: @*/
105: PetscErrorCode PetscViewerGetFormat(PetscViewer viewer, PetscViewerFormat *format)
106: {
107:   PetscFunctionBegin;
108:   *format = viewer->format;
109:   PetscFunctionReturn(PETSC_SUCCESS);
110: }