Actual source code: viewa.c
1: #define PETSC_DLL
3: #include "../src/sys/viewer/viewerimpl.h" /*I "petsc.h" I*/
7: /*@C
8: PetscViewerSetFormat - Sets the format for PetscViewers.
10: Collective on PetscViewer
12: Input Parameters:
13: + viewer - the PetscViewer
14: - format - the format
16: Level: intermediate
18: Notes:
19: Available formats include
20: + PETSC_VIEWER_DEFAULT - default format
21: . PETSC_VIEWER_ASCII_MATLAB - Matlab format
22: . PETSC_VIEWER_ASCII_DENSE - print matrix as dense
23: . PETSC_VIEWER_ASCII_IMPL - implementation-specific format
24: (which is in many cases the same as the default)
25: . PETSC_VIEWER_ASCII_INFO - basic information about object
26: . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
27: about object
28: . PETSC_VIEWER_ASCII_COMMON - identical output format for
29: all objects of a particular type
30: . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
31: element number next to each vector entry
32: . PETSC_VIEWER_ASCII_SYMMODU - print parallel vectors without
33: indicating the processor ranges
34: . PETSC_VIEWER_NATIVE - store the object to the binary
35: file in its native format (for example, dense
36: matrices are stored as dense), DA vectors are dumped directly to the
37: file instead of being first put in the natural ordering
38: . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
39: . PETSC_VIEWER_DRAW_LG - views the vector with a line graph
40: - PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot
42: These formats are most often used for viewing matrices and vectors.
44: If a format (for example PETSC_VIEWER_DRAW_CONTOUR) was applied to a viewer
45: where it didn't apply (PETSC_VIEWER_STDOUT_WORLD) it cause the default behavior
46: for that viewer to be used.
47:
48: Concepts: PetscViewer^setting format
50: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
51: PetscViewerPushFormat(), PetscViewerPopFormat(), PetscViewerDrawOpen(),PetscViewerSocketOpen()
52: @*/
53: PetscErrorCode PetscViewerSetFormat(PetscViewer viewer,PetscViewerFormat format)
54: {
56: if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF;
58: CHKMEMQ;
59: viewer->format = format;
60: CHKMEMQ;
61: return(0);
62: }
66: /*@C
67: PetscViewerPushFormat - Sets the format for file PetscViewers.
69: Collective on PetscViewer
71: Input Parameters:
72: + viewer - the PetscViewer
73: - format - the format
75: Level: intermediate
77: Notes:
78: Available formats include
79: + PETSC_VIEWER_DEFAULT - default format
80: . PETSC_VIEWER_ASCII_MATLAB - Matlab format
81: . PETSC_VIEWER_ASCII_IMPL - implementation-specific format
82: (which is in many cases the same as the default)
83: . PETSC_VIEWER_ASCII_INFO - basic information about object
84: . PETSC_VIEWER_ASCII_INFO_DETAIL - more detailed info
85: about object
86: . PETSC_VIEWER_ASCII_COMMON - identical output format for
87: all objects of a particular type
88: . PETSC_VIEWER_ASCII_INDEX - (for vectors) prints the vector
89: element number next to each vector entry
90: . PETSC_VIEWER_NATIVE - store the object to the binary
91: file in its native format (for example, dense
92: matrices are stored as dense), for DA vectors displays vectors in DA ordering, not natural
93: . PETSC_VIEWER_DRAW_BASIC - views the vector with a simple 1d plot
94: . PETSC_VIEWER_DRAW_LG - views the vector with a line graph
95: - PETSC_VIEWER_DRAW_CONTOUR - views the vector with a contour plot
97: These formats are most often used for viewing matrices and vectors.
98: Currently, the object name is used only in the Matlab format.
100: Concepts: PetscViewer^setting format
102: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
103: PetscViewerSetFormat(), PetscViewerPopFormat()
104: @*/
105: PetscErrorCode PetscViewerPushFormat(PetscViewer viewer,PetscViewerFormat format)
106: {
109: if (viewer->iformat > 9) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Too many pushes");
111: viewer->formats[viewer->iformat++] = viewer->format;
112: viewer->format = format;
114: return(0);
115: }
119: /*@C
120: PetscViewerPopFormat - Resets the format for file PetscViewers.
122: Collective on PetscViewer
124: Input Parameters:
125: . viewer - the PetscViewer
127: Level: intermediate
129: Concepts: PetscViewer^setting format
131: .seealso: PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), MatView(), VecView(),
132: PetscViewerSetFormat(), PetscViewerPushFormat()
133: @*/
134: PetscErrorCode PetscViewerPopFormat(PetscViewer viewer)
135: {
138: if (viewer->iformat <= 0) return(0);
140: viewer->format = viewer->formats[--viewer->iformat];
141: return(0);
142: }
146: PetscErrorCode PetscViewerGetFormat(PetscViewer viewer,PetscViewerFormat *format)
147: {
149: *format = viewer->format;
150: return(0);
151: }