xref: /petsc/src/sys/classes/viewer/interface/viewa.c (revision e6e75211d226c622f451867f53ce5d558649ff4f) !
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    Concepts: PetscViewer^setting format
84 
85 .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(), PetscViewerType,
86           PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
87 @*/
88 PetscErrorCode  PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
89 {
90   PetscFunctionBegin;
91   if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
92   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
93   PetscValidLogicalCollectiveEnum(viewer,format,2);
94   viewer->format = format;
95   PetscFunctionReturn(0);
96 }
97 
98 #undef __FUNCT__
99 #define __FUNCT__ "PetscViewerPushFormat"
100 /*@C
101    PetscViewerPushFormat - Sets the format for file PetscViewers.
102 
103    Logically Collective on PetscViewer
104 
105    Input Parameters:
106 +  viewer - the PetscViewer
107 -  format - the format
108 
109    Level: intermediate
110 
111    Notes:
112    Available formats include
113 +    PETSC_VIEWER_DEFAULT - default format
114 .    PETSC_VIEWER_ASCII_MATLAB - MATLAB format
115 .    PETSC_VIEWER_ASCII_IMPL - implementation-specific format
116       (which is in many cases the same as the default)
117 .    PETSC_VIEWER_ASCII_INFO - basic information about object
118 .    PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
119        about object
120 .    PETSC_VIEWER_ASCII_COMMON - identical output format for
121        all objects of a particular type
122 .    PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
123        element number next to each vector entry
124 .    PETSC_VIEWER_NATIVE - store the object to the binary
125        file in its native format (for example, dense
126        matrices are stored as dense), for DMDA vectors displays vectors in DMDA ordering, not natural
127 .    PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
128 .    PETSC_VIEWER_DRAW_LG - views the vector with a line graph
129 -    PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot
130 
131    These formats are most often used for viewing matrices and vectors.
132    Currently, the object name is used only in the MATLAB format.
133 
134    Concepts: PetscViewer^setting format
135 
136 .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
137           PetscViewerSetFormat(), PetscViewerPopFormat()
138 @*/
139 PetscErrorCode  PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format)
140 {
141   PetscFunctionBegin;
142   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
143   PetscValidLogicalCollectiveEnum(viewer,format,2);
144   if (viewer->iformat > 9) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many pushes");
145 
146   viewer->formats[viewer->iformat++] = viewer->format;
147   viewer->format                     = format;
148   PetscFunctionReturn(0);
149 }
150 
151 #undef __FUNCT__
152 #define __FUNCT__ "PetscViewerPopFormat"
153 /*@C
154    PetscViewerPopFormat - Resets the format for file PetscViewers.
155 
156    Logically Collective on PetscViewer
157 
158    Input Parameters:
159 .  viewer - the PetscViewer
160 
161    Level: intermediate
162 
163    Concepts: PetscViewer^setting format
164 
165 .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
166           PetscViewerSetFormat(), PetscViewerPushFormat()
167 @*/
168 PetscErrorCode  PetscViewerPopFormat(PetscViewer viewer)
169 {
170   PetscFunctionBegin;
171   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
172   if (viewer->iformat <= 0) PetscFunctionReturn(0);
173 
174   viewer->format = viewer->formats[--viewer->iformat];
175   PetscFunctionReturn(0);
176 }
177 
178 #undef __FUNCT__
179 #define __FUNCT__ "PetscViewerGetFormat"
180 PetscErrorCode  PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
181 {
182   PetscFunctionBegin;
183   *format =  viewer->format;
184   PetscFunctionReturn(0);
185 }
186 
187 
188 
189