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