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