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