1 2 #include <petsc/private/viewerimpl.h> /*I "petscsys.h" I*/ 3 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 "ASCII_XML", 24 "ASCII_FLAMEGRAPH", 25 "ASCII_GLVIS", 26 "ASCII_CSV", 27 "DRAW_BASIC", 28 "DRAW_LG", 29 "DRAW_LG_XRANGE", 30 "DRAW_CONTOUR", 31 "DRAW_PORTS", 32 "VTK_VTS", 33 "VTK_VTR", 34 "VTK_VTU", 35 "BINARY_MATLAB", 36 "NATIVE", 37 "HDF5_PETSC", 38 "HDF5_VIZ", 39 "HDF5_XDMF", 40 "HDF5_MAT", 41 "NOFORMAT", 42 "LOAD_BALANCE", 43 "FAILED", 44 "ALL", 45 "PetscViewerFormat", 46 "PETSC_VIEWER_", 47 NULL 48 }; 49 50 /*@C 51 PetscViewerSetFormat - Sets the format for PetscViewers. 52 53 Logically Collective on PetscViewer 54 55 This routine is deprecated, you should use PetscViewerPushFormat()/PetscViewerPopFormat() 56 57 Input Parameters: 58 + viewer - the PetscViewer 59 - format - the format 60 61 Level: intermediate 62 63 Notes: 64 Available formats include 65 + PETSC_VIEWER_DEFAULT - default format 66 . PETSC_VIEWER_ASCII_MATLAB - MATLAB format 67 . PETSC_VIEWER_ASCII_DENSE - print matrix as dense 68 . PETSC_VIEWER_ASCII_IMPL - implementation-specific format 69 (which is in many cases the same as the default) 70 . PETSC_VIEWER_ASCII_INFO - basic information about object 71 . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info 72 about object 73 . PETSC_VIEWER_ASCII_COMMON - identical output format for 74 all objects of a particular type 75 . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector 76 element number next to each vector entry 77 . PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without 78 indicating the processor ranges 79 . PETSC_VIEWER_ASCII_VTK - outputs the object to a VTK file (deprecated since v3.14) 80 . PETSC_VIEWER_NATIVE - store the object to the binary 81 file in its native format (for example, dense 82 matrices are stored as dense), DMDA vectors are dumped directly to the 83 file instead of being first put in the natural ordering 84 . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot 85 . PETSC_VIEWER_DRAW_LG - views the vector with a line graph 86 - PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot 87 88 These formats are most often used for viewing matrices and vectors. 89 90 If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer 91 where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior 92 for that viewer to be used. 93 94 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 95 96 .seealso: `PetscViewerGetFormat()`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`, 97 `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen(),PetscViewerSocketOpen()` 98 @*/ 99 PetscErrorCode PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format) 100 { 101 PetscFunctionBegin; 102 if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF; 103 PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 104 PetscValidLogicalCollectiveEnum(viewer,format,2); 105 viewer->format = format; 106 PetscFunctionReturn(0); 107 } 108 109 /*@C 110 PetscViewerPushFormat - Sets the format for file PetscViewers. 111 112 Logically Collective on PetscViewer 113 114 Input Parameters: 115 + viewer - the PetscViewer 116 - format - the format 117 118 Level: intermediate 119 120 Notes: 121 Available formats include 122 + PETSC_VIEWER_DEFAULT - default format 123 . PETSC_VIEWER_ASCII_MATLAB - MATLAB format 124 . PETSC_VIEWER_ASCII_IMPL - implementation-specific format 125 (which is in many cases the same as the default) 126 . PETSC_VIEWER_ASCII_INFO - basic information about object 127 . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info 128 about object 129 . PETSC_VIEWER_ASCII_COMMON - identical output format for 130 all objects of a particular type 131 . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector 132 element number next to each vector entry 133 . PETSC_VIEWER_NATIVE - store the object to the binary 134 file in its native format (for example, dense 135 matrices are stored as dense), for DMDA vectors displays vectors in DMDA ordering, not natural 136 . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot 137 . PETSC_VIEWER_DRAW_LG - views the vector with a line graph 138 . PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot 139 - PETSC_VIEWER_ASCII_XML - saves the data in XML format, needed for PetscLogView() when viewing with PetscLogNestedBegin() 140 141 These formats are most often used for viewing matrices and vectors. 142 Currently, the object name is used only in the MATLAB format. 143 144 .seealso: `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, 145 `PetscViewerSetFormat()`, `PetscViewerPopFormat()` 146 @*/ 147 PetscErrorCode PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format) 148 { 149 PetscFunctionBegin; 150 PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 151 PetscValidLogicalCollectiveEnum(viewer,format,2); 152 PetscCheck(viewer->iformat <= PETSCVIEWERFORMATPUSHESMAX-1,PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many PetscViewerPushFormat(), perhaps you forgot PetscViewerPopFormat()?"); 153 154 viewer->formats[viewer->iformat++] = viewer->format; 155 viewer->format = format; 156 PetscFunctionReturn(0); 157 } 158 159 /*@C 160 PetscViewerPopFormat - Resets the format for file PetscViewers. 161 162 Logically Collective on PetscViewer 163 164 Input Parameters: 165 . viewer - the PetscViewer 166 167 Level: intermediate 168 169 .seealso: `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, 170 `PetscViewerSetFormat()`, `PetscViewerPushFormat()` 171 @*/ 172 PetscErrorCode PetscViewerPopFormat(PetscViewer viewer) 173 { 174 PetscFunctionBegin; 175 PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 176 if (viewer->iformat <= 0) PetscFunctionReturn(0); 177 178 viewer->format = viewer->formats[--viewer->iformat]; 179 PetscFunctionReturn(0); 180 } 181 182 /*@C 183 PetscViewerGetFormat - Gets the format for PetscViewers. 184 185 Not collective 186 187 Input Parameter: 188 . viewer - the PetscViewer 189 190 Output Parameter: 191 . format - the format 192 193 Level: intermediate 194 195 Notes: 196 Available formats include 197 + PETSC_VIEWER_DEFAULT - default format 198 . PETSC_VIEWER_ASCII_MATLAB - MATLAB format 199 . PETSC_VIEWER_ASCII_DENSE - print matrix as dense 200 . PETSC_VIEWER_ASCII_IMPL - implementation-specific format 201 (which is in many cases the same as the default) 202 . PETSC_VIEWER_ASCII_INFO - basic information about object 203 . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info 204 about object 205 . PETSC_VIEWER_ASCII_COMMON - identical output format for 206 all objects of a particular type 207 . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector 208 element number next to each vector entry 209 . PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without 210 indicating the processor ranges 211 . PETSC_VIEWER_ASCII_VTK - outputs the object to a VTK file (deprecated since v3.14) 212 . PETSC_VIEWER_NATIVE - store the object to the binary 213 file in its native format (for example, dense 214 matrices are stored as dense), DMDA vectors are dumped directly to the 215 file instead of being first put in the natural ordering 216 . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot 217 . PETSC_VIEWER_DRAW_LG - views the vector with a line graph 218 - PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot 219 220 These formats are most often used for viewing matrices and vectors. 221 222 If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer 223 where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior 224 for that viewer to be used. 225 226 .seealso: `PetscViewerSetFormat()`, `PetscViewerASCIIOpen()`, `PetscViewerBinaryOpen()`, `MatView()`, `VecView()`, `PetscViewerType`, 227 `PetscViewerPushFormat()`, `PetscViewerPopFormat()`, `PetscViewerDrawOpen(),PetscViewerSocketOpen()` 228 @*/ 229 PetscErrorCode PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format) 230 { 231 PetscFunctionBegin; 232 *format = viewer->format; 233 PetscFunctionReturn(0); 234 } 235