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