15c6c1daeSBarry Smith 2af0996ceSBarry Smith #include <petsc/private/viewerimpl.h> /*I "petscsys.h" I*/ 35c6c1daeSBarry Smith 45c6c1daeSBarry Smith const char *const PetscViewerFormats[] = { 55c6c1daeSBarry Smith "DEFAULT", 65c6c1daeSBarry Smith "ASCII_MATLAB", 75c6c1daeSBarry Smith "ASCII_MATHEMATICA", 85c6c1daeSBarry Smith "ASCII_IMPL", 95c6c1daeSBarry Smith "ASCII_INFO", 105c6c1daeSBarry Smith "ASCII_INFO_DETAIL", 115c6c1daeSBarry Smith "ASCII_COMMON", 125c6c1daeSBarry Smith "ASCII_SYMMODU", 135c6c1daeSBarry Smith "ASCII_INDEX", 145c6c1daeSBarry Smith "ASCII_DENSE", 155c6c1daeSBarry Smith "ASCII_MATRIXMARKET", 165c6c1daeSBarry Smith "ASCII_VTK", 175c6c1daeSBarry Smith "ASCII_VTK_CELL", 185c6c1daeSBarry Smith "ASCII_VTK_COORDS", 195c6c1daeSBarry Smith "ASCII_PCICE", 205c6c1daeSBarry Smith "ASCII_PYTHON", 215c6c1daeSBarry Smith "ASCII_FACTOR_INFO", 222e61fd76SBarry Smith "ASCII_LATEX", 23bb1d7374SBarry Smith "ASCII_XML", 248135c375SStefano Zampini "ASCII_GLVIS", 2538144912Sdeepblu2718 "ASCII_CSV", 265c6c1daeSBarry Smith "DRAW_BASIC", 275c6c1daeSBarry Smith "DRAW_LG", 28bb046f40SHong Zhang "DRAW_LG_XRANGE", 295c6c1daeSBarry Smith "DRAW_CONTOUR", 305c6c1daeSBarry Smith "DRAW_PORTS", 315c6c1daeSBarry Smith "VTK_VTS", 323a062f41SBarry Smith "VTK_VTR", 332e61fd76SBarry Smith "VTK_VTU", 34a261c58fSBarry Smith "BINARY_MATLAB", 355c6c1daeSBarry Smith "NATIVE", 368aa4816bSVaclav Hapla "HDF5_PETSC", 37898f909eSMatthew G. Knepley "HDF5_VIZ", 388aa4816bSVaclav Hapla "HDF5_XDMF", 39cbb4c999SVaclav Hapla "HDF5_MAT", 402e61fd76SBarry Smith "NOFORMAT", 41ef5fdb51SBarry Smith "LOAD_BALANCE", 42eafd5ff0SAlex Lindsay "FAILED", 432e61fd76SBarry Smith "PetscViewerFormat", 442e61fd76SBarry Smith "PETSC_VIEWER_", 4502c9f0b5SLisandro Dalcin NULL 465c6c1daeSBarry Smith }; 475c6c1daeSBarry Smith 485c6c1daeSBarry Smith /*@C 495c6c1daeSBarry Smith PetscViewerSetFormat - Sets the format for PetscViewers. 505c6c1daeSBarry Smith 515c6c1daeSBarry Smith Logically Collective on PetscViewer 525c6c1daeSBarry Smith 536a9046bcSBarry Smith This routine is deprecated, you should use PetscViewerPushFormat()/PetscViewerPopFormat() 546a9046bcSBarry Smith 555c6c1daeSBarry Smith Input Parameters: 565c6c1daeSBarry Smith + viewer - the PetscViewer 575c6c1daeSBarry Smith - format - the format 585c6c1daeSBarry Smith 595c6c1daeSBarry Smith Level: intermediate 605c6c1daeSBarry Smith 615c6c1daeSBarry Smith Notes: 625c6c1daeSBarry Smith Available formats include 635c6c1daeSBarry Smith + PETSC_VIEWER_DEFAULT - default format 645c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_MATLAB - MATLAB format 655c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_DENSE - print matrix as dense 665c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_IMPL - implementation-specific format 675c6c1daeSBarry Smith (which is in many cases the same as the default) 685c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_INFO - basic information about object 695c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info 705c6c1daeSBarry Smith about object 715c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_COMMON - identical output format for 725c6c1daeSBarry Smith all objects of a particular type 735c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector 745c6c1daeSBarry Smith element number next to each vector entry 755c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without 765c6c1daeSBarry Smith indicating the processor ranges 778ec8862eSJed Brown . PETSC_VIEWER_ASCII_VTK - outputs the object to a VTK file (deprecated since v3.14) 785c6c1daeSBarry Smith . PETSC_VIEWER_NATIVE - store the object to the binary 795c6c1daeSBarry Smith file in its native format (for example, dense 805c6c1daeSBarry Smith matrices are stored as dense), DMDA vectors are dumped directly to the 815c6c1daeSBarry Smith file instead of being first put in the natural ordering 825c6c1daeSBarry Smith . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot 835c6c1daeSBarry Smith . PETSC_VIEWER_DRAW_LG - views the vector with a line graph 845c6c1daeSBarry Smith - PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot 855c6c1daeSBarry Smith 865c6c1daeSBarry Smith These formats are most often used for viewing matrices and vectors. 875c6c1daeSBarry Smith 885c6c1daeSBarry Smith If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer 895c6c1daeSBarry Smith where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior 905c6c1daeSBarry Smith for that viewer to be used. 915c6c1daeSBarry Smith 92f55353a2SBarry Smith 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 93f55353a2SBarry Smith 94*569e28a7SMatthew G. Knepley .seealso: PetscViewerGetFormat(), PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), PetscViewerType, 955c6c1daeSBarry Smith PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen() 965c6c1daeSBarry Smith @*/ 975c6c1daeSBarry Smith PetscErrorCode PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format) 985c6c1daeSBarry Smith { 995c6c1daeSBarry Smith PetscFunctionBegin; 1005c6c1daeSBarry Smith if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF; 1015c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 1025c6c1daeSBarry Smith PetscValidLogicalCollectiveEnum(viewer,format,2); 1035c6c1daeSBarry Smith viewer->format = format; 1045c6c1daeSBarry Smith PetscFunctionReturn(0); 1055c6c1daeSBarry Smith } 1065c6c1daeSBarry Smith 1075c6c1daeSBarry Smith /*@C 1085c6c1daeSBarry Smith PetscViewerPushFormat - Sets the format for file PetscViewers. 1095c6c1daeSBarry Smith 1105c6c1daeSBarry Smith Logically Collective on PetscViewer 1115c6c1daeSBarry Smith 1125c6c1daeSBarry Smith Input Parameters: 1135c6c1daeSBarry Smith + viewer - the PetscViewer 1145c6c1daeSBarry Smith - format - the format 1155c6c1daeSBarry Smith 1165c6c1daeSBarry Smith Level: intermediate 1175c6c1daeSBarry Smith 1185c6c1daeSBarry Smith Notes: 1195c6c1daeSBarry Smith Available formats include 1205c6c1daeSBarry Smith + PETSC_VIEWER_DEFAULT - default format 1215c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_MATLAB - MATLAB format 1225c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_IMPL - implementation-specific format 1235c6c1daeSBarry Smith (which is in many cases the same as the default) 1245c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_INFO - basic information about object 1255c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info 1265c6c1daeSBarry Smith about object 1275c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_COMMON - identical output format for 1285c6c1daeSBarry Smith all objects of a particular type 1295c6c1daeSBarry Smith . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector 1305c6c1daeSBarry Smith element number next to each vector entry 1315c6c1daeSBarry Smith . PETSC_VIEWER_NATIVE - store the object to the binary 1325c6c1daeSBarry Smith file in its native format (for example, dense 1335c6c1daeSBarry Smith matrices are stored as dense), for DMDA vectors displays vectors in DMDA ordering, not natural 1345c6c1daeSBarry Smith . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot 1355c6c1daeSBarry Smith . PETSC_VIEWER_DRAW_LG - views the vector with a line graph 136fe866b2dSBarry Smith . PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot 137fe866b2dSBarry Smith - PETSC_VIEWER_ASCII_XML - saves the data in XML format, needed for PetscLogView() when viewing with PetscLogNestedBegin() 1385c6c1daeSBarry Smith 1395c6c1daeSBarry Smith These formats are most often used for viewing matrices and vectors. 1405c6c1daeSBarry Smith Currently, the object name is used only in the MATLAB format. 1415c6c1daeSBarry Smith 1425c6c1daeSBarry Smith .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), 1435c6c1daeSBarry Smith PetscViewerSetFormat(), PetscViewerPopFormat() 1445c6c1daeSBarry Smith @*/ 1455c6c1daeSBarry Smith PetscErrorCode PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format) 1465c6c1daeSBarry Smith { 1475c6c1daeSBarry Smith PetscFunctionBegin; 1485c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 1495c6c1daeSBarry Smith PetscValidLogicalCollectiveEnum(viewer,format,2); 150a2628df9SBarry Smith if (viewer->iformat > PETSCVIEWERFORMATPUSHESMAX-1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many PetscViewerPushFormat(), perhaps you forgot PetscViewerPopFormat()?"); 1515c6c1daeSBarry Smith 1525c6c1daeSBarry Smith viewer->formats[viewer->iformat++] = viewer->format; 1535c6c1daeSBarry Smith viewer->format = format; 1545c6c1daeSBarry Smith PetscFunctionReturn(0); 1555c6c1daeSBarry Smith } 1565c6c1daeSBarry Smith 1575c6c1daeSBarry Smith /*@C 1585c6c1daeSBarry Smith PetscViewerPopFormat - Resets the format for file PetscViewers. 1595c6c1daeSBarry Smith 1605c6c1daeSBarry Smith Logically Collective on PetscViewer 1615c6c1daeSBarry Smith 1625c6c1daeSBarry Smith Input Parameters: 1635c6c1daeSBarry Smith . viewer - the PetscViewer 1645c6c1daeSBarry Smith 1655c6c1daeSBarry Smith Level: intermediate 1665c6c1daeSBarry Smith 1675c6c1daeSBarry Smith .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), 1685c6c1daeSBarry Smith PetscViewerSetFormat(), PetscViewerPushFormat() 1695c6c1daeSBarry Smith @*/ 1705c6c1daeSBarry Smith PetscErrorCode PetscViewerPopFormat(PetscViewer viewer) 1715c6c1daeSBarry Smith { 1725c6c1daeSBarry Smith PetscFunctionBegin; 1735c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 1745c6c1daeSBarry Smith if (viewer->iformat <= 0) PetscFunctionReturn(0); 1755c6c1daeSBarry Smith 1765c6c1daeSBarry Smith viewer->format = viewer->formats[--viewer->iformat]; 1775c6c1daeSBarry Smith PetscFunctionReturn(0); 1785c6c1daeSBarry Smith } 1795c6c1daeSBarry Smith 180*569e28a7SMatthew G. Knepley /*@C 181*569e28a7SMatthew G. Knepley PetscViewerGetFormat - Gets the format for PetscViewers. 182*569e28a7SMatthew G. Knepley 183*569e28a7SMatthew G. Knepley Not collective 184*569e28a7SMatthew G. Knepley 185*569e28a7SMatthew G. Knepley Input Parameter: 186*569e28a7SMatthew G. Knepley . viewer - the PetscViewer 187*569e28a7SMatthew G. Knepley 188*569e28a7SMatthew G. Knepley Output Parameter: 189*569e28a7SMatthew G. Knepley - format - the format 190*569e28a7SMatthew G. Knepley 191*569e28a7SMatthew G. Knepley Level: intermediate 192*569e28a7SMatthew G. Knepley 193*569e28a7SMatthew G. Knepley Notes: 194*569e28a7SMatthew G. Knepley Available formats include 195*569e28a7SMatthew G. Knepley + PETSC_VIEWER_DEFAULT - default format 196*569e28a7SMatthew G. Knepley . PETSC_VIEWER_ASCII_MATLAB - MATLAB format 197*569e28a7SMatthew G. Knepley . PETSC_VIEWER_ASCII_DENSE - print matrix as dense 198*569e28a7SMatthew G. Knepley . PETSC_VIEWER_ASCII_IMPL - implementation-specific format 199*569e28a7SMatthew G. Knepley (which is in many cases the same as the default) 200*569e28a7SMatthew G. Knepley . PETSC_VIEWER_ASCII_INFO - basic information about object 201*569e28a7SMatthew G. Knepley . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info 202*569e28a7SMatthew G. Knepley about object 203*569e28a7SMatthew G. Knepley . PETSC_VIEWER_ASCII_COMMON - identical output format for 204*569e28a7SMatthew G. Knepley all objects of a particular type 205*569e28a7SMatthew G. Knepley . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector 206*569e28a7SMatthew G. Knepley element number next to each vector entry 207*569e28a7SMatthew G. Knepley . PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without 208*569e28a7SMatthew G. Knepley indicating the processor ranges 209*569e28a7SMatthew G. Knepley . PETSC_VIEWER_ASCII_VTK - outputs the object to a VTK file (deprecated since v3.14) 210*569e28a7SMatthew G. Knepley . PETSC_VIEWER_NATIVE - store the object to the binary 211*569e28a7SMatthew G. Knepley file in its native format (for example, dense 212*569e28a7SMatthew G. Knepley matrices are stored as dense), DMDA vectors are dumped directly to the 213*569e28a7SMatthew G. Knepley file instead of being first put in the natural ordering 214*569e28a7SMatthew G. Knepley . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot 215*569e28a7SMatthew G. Knepley . PETSC_VIEWER_DRAW_LG - views the vector with a line graph 216*569e28a7SMatthew G. Knepley - PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot 217*569e28a7SMatthew G. Knepley 218*569e28a7SMatthew G. Knepley These formats are most often used for viewing matrices and vectors. 219*569e28a7SMatthew G. Knepley 220*569e28a7SMatthew G. Knepley If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer 221*569e28a7SMatthew G. Knepley where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior 222*569e28a7SMatthew G. Knepley for that viewer to be used. 223*569e28a7SMatthew G. Knepley 224*569e28a7SMatthew G. Knepley .seealso: PetscViewerSetFormat(), PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), PetscViewerType, 225*569e28a7SMatthew G. Knepley PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen() 226*569e28a7SMatthew G. Knepley @*/ 2275c6c1daeSBarry Smith PetscErrorCode PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format) 2285c6c1daeSBarry Smith { 2295c6c1daeSBarry Smith PetscFunctionBegin; 2305c6c1daeSBarry Smith *format = viewer->format; 2315c6c1daeSBarry Smith PetscFunctionReturn(0); 2325c6c1daeSBarry Smith } 233