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 PetscViewers. 8 9 Logically Collective on PetscViewer 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: intermediate 18 19 Notes: 20 Available formats include 21 + PETSC_VIEWER_DEFAULT - default format 22 . PETSC_VIEWER_ASCII_MATLAB - MATLAB format 23 . PETSC_VIEWER_ASCII_DENSE - print matrix as dense 24 . PETSC_VIEWER_ASCII_IMPL - implementation-specific format 25 (which is in many cases the same as the default) 26 . PETSC_VIEWER_ASCII_INFO - basic information about object 27 . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info 28 about object 29 . PETSC_VIEWER_ASCII_COMMON - identical output format for 30 all objects of a particular type 31 . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector 32 element number next to each vector entry 33 . PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without 34 indicating the processor ranges 35 . PETSC_VIEWER_ASCII_VTK - outputs the object to a VTK file (deprecated since v3.14) 36 . PETSC_VIEWER_NATIVE - store the object to the binary 37 file in its native format (for example, dense 38 matrices are stored as dense), DMDA vectors are dumped directly to the 39 file instead of being first put in the natural ordering 40 . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot 41 . PETSC_VIEWER_DRAW_LG - views the vector with a line graph 42 - PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot 43 44 These formats are most often used for viewing matrices and vectors. 45 46 If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer 47 where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior 48 for that viewer to be used. 49 50 Note: This supports passing in a NULL for the viewer for use in the debugger, but it should never be called in the code with a NULL viewer 51 52 .seealso: `PetscViewerGetFormat()`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`, 53 `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen()`, `PetscViewerSocketOpen()` 54 @*/ 55 PetscErrorCode PetscViewerSetFormat(PetscViewer viewer, PetscViewerFormat format) { 56 PetscFunctionBegin; 57 if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF; 58 PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 1); 59 PetscValidLogicalCollectiveEnum(viewer, format, 2); 60 viewer->format = format; 61 PetscFunctionReturn(0); 62 } 63 64 /*@C 65 PetscViewerPushFormat - Sets the format for file PetscViewers. 66 67 Logically Collective on PetscViewer 68 69 Input Parameters: 70 + viewer - the PetscViewer 71 - format - the format 72 73 Level: intermediate 74 75 Notes: 76 Available formats include 77 + PETSC_VIEWER_DEFAULT - default format 78 . PETSC_VIEWER_ASCII_MATLAB - MATLAB format 79 . PETSC_VIEWER_ASCII_IMPL - implementation-specific format 80 (which is in many cases the same as the default) 81 . PETSC_VIEWER_ASCII_INFO - basic information about object 82 . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info 83 about object 84 . PETSC_VIEWER_ASCII_COMMON - identical output format for 85 all objects of a particular type 86 . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector 87 element number next to each vector entry 88 . PETSC_VIEWER_NATIVE - store the object to the binary 89 file in its native format (for example, dense 90 matrices are stored as dense), for DMDA vectors displays vectors in DMDA ordering, not natural 91 . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot 92 . PETSC_VIEWER_DRAW_LG - views the vector with a line graph 93 . PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot 94 - PETSC_VIEWER_ASCII_XML - saves the data in XML format, needed for PetscLogView() when viewing with PetscLogNestedBegin() 95 96 These formats are most often used for viewing matrices and vectors. 97 Currently, the object name is used only in the MATLAB format. 98 99 .seealso: `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, 100 `PetscViewerSetFormat()`, `PetscViewerPopFormat()` 101 @*/ 102 PetscErrorCode PetscViewerPushFormat(PetscViewer viewer, PetscViewerFormat format) { 103 PetscFunctionBegin; 104 PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 1); 105 PetscValidLogicalCollectiveEnum(viewer, format, 2); 106 PetscCheck(viewer->iformat <= PETSCVIEWERFORMATPUSHESMAX - 1, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Too many PetscViewerPushFormat(), perhaps you forgot PetscViewerPopFormat()?"); 107 108 viewer->formats[viewer->iformat++] = viewer->format; 109 viewer->format = format; 110 PetscFunctionReturn(0); 111 } 112 113 /*@C 114 PetscViewerPopFormat - Resets the format for file PetscViewers. 115 116 Logically Collective on PetscViewer 117 118 Input Parameters: 119 . viewer - the PetscViewer 120 121 Level: intermediate 122 123 .seealso: `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, 124 `PetscViewerSetFormat()`, `PetscViewerPushFormat()` 125 @*/ 126 PetscErrorCode PetscViewerPopFormat(PetscViewer viewer) { 127 PetscFunctionBegin; 128 PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 1); 129 if (viewer->iformat <= 0) PetscFunctionReturn(0); 130 131 viewer->format = viewer->formats[--viewer->iformat]; 132 PetscFunctionReturn(0); 133 } 134 135 /*@C 136 PetscViewerGetFormat - Gets the format for PetscViewers. 137 138 Not collective 139 140 Input Parameter: 141 . viewer - the PetscViewer 142 143 Output Parameter: 144 . format - the format 145 146 Level: intermediate 147 148 Notes: 149 Available formats include 150 + PETSC_VIEWER_DEFAULT - default format 151 . PETSC_VIEWER_ASCII_MATLAB - MATLAB format 152 . PETSC_VIEWER_ASCII_DENSE - print matrix as dense 153 . PETSC_VIEWER_ASCII_IMPL - implementation-specific format 154 (which is in many cases the same as the default) 155 . PETSC_VIEWER_ASCII_INFO - basic information about object 156 . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info 157 about object 158 . PETSC_VIEWER_ASCII_COMMON - identical output format for 159 all objects of a particular type 160 . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector 161 element number next to each vector entry 162 . PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without 163 indicating the processor ranges 164 . PETSC_VIEWER_ASCII_VTK - outputs the object to a VTK file (deprecated since v3.14) 165 . PETSC_VIEWER_NATIVE - store the object to the binary 166 file in its native format (for example, dense 167 matrices are stored as dense), DMDA vectors are dumped directly to the 168 file instead of being first put in the natural ordering 169 . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot 170 . PETSC_VIEWER_DRAW_LG - views the vector with a line graph 171 - PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot 172 173 These formats are most often used for viewing matrices and vectors. 174 175 If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer 176 where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior 177 for that viewer to be used. 178 179 .seealso: `PetscViewerSetFormat()`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`, 180 `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen()`, `PetscViewerSocketOpen()` 181 @*/ 182 PetscErrorCode PetscViewerGetFormat(PetscViewer viewer, PetscViewerFormat *format) { 183 PetscFunctionBegin; 184 *format = viewer->format; 185 PetscFunctionReturn(0); 186 } 187