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