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