1 2 #include <petsc/private/viewerimpl.h> /*I "petscsys.h" I*/ 3 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}; 5 6 /*@C 7 PetscViewerSetFormat - Sets the format for a `PetscViewer`. 8 9 Logically Collective 10 11 This routine is deprecated, you should use `PetscViewerPushFormat()`/`PetscViewerPopFormat()` 12 13 Input Parameters: 14 + viewer - the `PetscViewer` 15 - format - the format 16 17 Level: deprecated 18 19 Note: 20 See `PetscViewerFormat` for available values 21 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; 29 PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 1); 30 PetscValidLogicalCollectiveEnum(viewer, format, 2); 31 viewer->format = format; 32 PetscFunctionReturn(PETSC_SUCCESS); 33 } 34 35 /*@C 36 PetscViewerPushFormat - Sets the format for a `PetscViewer`. 37 38 Logically Collective 39 40 Input Parameters: 41 + viewer - the `PetscViewer` 42 - format - the format 43 44 Level: intermediate 45 46 Note: 47 See `PetscViewerFormat` for available values 48 49 .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerFormat`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, 50 `PetscViewerSetFormat()`, `PetscViewerPopFormat()` 51 @*/ 52 PetscErrorCode PetscViewerPushFormat(PetscViewer viewer, PetscViewerFormat format) 53 { 54 PetscFunctionBegin; 55 PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 1); 56 PetscValidLogicalCollectiveEnum(viewer, format, 2); 57 PetscCheck(viewer->iformat <= PETSCVIEWERFORMATPUSHESMAX - 1, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Too many PetscViewerPushFormat(), perhaps you forgot PetscViewerPopFormat()?"); 58 59 viewer->formats[viewer->iformat++] = viewer->format; 60 viewer->format = format; 61 PetscFunctionReturn(PETSC_SUCCESS); 62 } 63 64 /*@C 65 PetscViewerPopFormat - Resets the format for a `PetscViewer` to the value it had before the previous call to `PetscViewerPushFormat()` 66 67 Logically Collective 68 69 Input Parameters: 70 . viewer - the `PetscViewer` 71 72 Level: intermediate 73 74 .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerFormat`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, 75 `PetscViewerSetFormat()`, `PetscViewerPushFormat()` 76 @*/ 77 PetscErrorCode PetscViewerPopFormat(PetscViewer viewer) 78 { 79 PetscFunctionBegin; 80 PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 1); 81 if (viewer->iformat <= 0) PetscFunctionReturn(PETSC_SUCCESS); 82 83 viewer->format = viewer->formats[--viewer->iformat]; 84 PetscFunctionReturn(PETSC_SUCCESS); 85 } 86 87 /*@C 88 PetscViewerGetFormat - Gets the current format for `PetscViewer`. 89 90 Not collective 91 92 Input Parameter: 93 . viewer - the `PetscViewer` 94 95 Output Parameter: 96 . format - the format 97 98 Level: intermediate 99 100 Note: 101 See `PetscViewerFormat` for available values 102 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 } 112