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