Actual source code: view.c
1: #define PETSC_DLL
3: #include "src/sys/viewer/viewerimpl.h" /*I "petsc.h" I*/
5: PetscCookie PETSC_VIEWER_COOKIE = 0;
9: /*@
10: PetscViewerDestroy - Destroys a PetscViewer.
12: Collective on PetscViewer
14: Input Parameters:
15: . viewer - the PetscViewer to be destroyed.
17: Level: beginner
19: .seealso: PetscViewerSocketOpen(), PetscViewerASCIIOpen(), PetscViewerCreate(), PetscViewerDrawOpen()
21: @*/
22: PetscErrorCode PetscViewerDestroy(PetscViewer viewer)
23: {
28: PetscViewerFlush(viewer);
29: if (--viewer->refct > 0) return(0);
31: PetscObjectDepublish(viewer);
33: if (viewer->ops->destroy) {
34: (*viewer->ops->destroy)(viewer);
35: }
36: PetscHeaderDestroy(viewer);
37: return(0);
38: }
42: /*@C
43: PetscViewerGetType - Returns the type of a PetscViewer.
45: Not Collective
47: Input Parameter:
48: . viewer - the PetscViewer
50: Output Parameter:
51: . type - PetscViewer type (see below)
53: Available Types Include:
54: . PETSC_VIEWER_SOCKET - Socket PetscViewer
55: . PETSC_VIEWER_ASCII - ASCII PetscViewer
56: . PETSC_VIEWER_BINARY - binary file PetscViewer
57: . PETSC_VIEWER_STRING - string PetscViewer
58: . PETSC_VIEWER_DRAW - drawing PetscViewer
60: Level: intermediate
62: Note:
63: See include/petscviewer.h for a complete list of PetscViewers.
65: PetscViewerType is actually a string
67: .seealso: PetscViewerCreate(), PetscViewerSetType()
69: @*/
70: PetscErrorCode PetscViewerGetType(PetscViewer viewer,PetscViewerType *type)
71: {
74: *type = (PetscViewerType) viewer->type_name;
75: return(0);
76: }
80: /*@C
81: PetscViewerSetOptionsPrefix - Sets the prefix used for searching for all
82: PetscViewer options in the database.
84: Collective on PetscViewer
86: Input Parameter:
87: + viewer - the PetscViewer context
88: - prefix - the prefix to prepend to all option names
90: Notes:
91: A hyphen (-) must NOT be given at the beginning of the prefix name.
92: The first character of all runtime options is AUTOMATICALLY the hyphen.
94: Level: advanced
96: .keywords: PetscViewer, set, options, prefix, database
98: .seealso: PetscViewerSetFromOptions()
99: @*/
100: PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer viewer,const char prefix[])
101: {
106: PetscObjectSetOptionsPrefix((PetscObject)viewer,prefix);
107: return(0);
108: }
112: /*@C
113: PetscViewerAppendOptionsPrefix - Appends to the prefix used for searching for all
114: PetscViewer options in the database.
116: Collective on PetscViewer
118: Input Parameters:
119: + viewer - the PetscViewer context
120: - prefix - the prefix to prepend to all option names
122: Notes:
123: A hyphen (-) must NOT be given at the beginning of the prefix name.
124: The first character of all runtime options is AUTOMATICALLY the hyphen.
126: Level: advanced
128: .keywords: PetscViewer, append, options, prefix, database
130: .seealso: PetscViewerGetOptionsPrefix()
131: @*/
132: PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer viewer,const char prefix[])
133: {
135:
138: PetscObjectAppendOptionsPrefix((PetscObject)viewer,prefix);
139: return(0);
140: }
144: /*@C
145: PetscViewerGetOptionsPrefix - Sets the prefix used for searching for all
146: PetscViewer options in the database.
148: Not Collective
150: Input Parameter:
151: . viewer - the PetscViewer context
153: Output Parameter:
154: . prefix - pointer to the prefix string used
156: Notes: On the fortran side, the user should pass in a string 'prefix' of
157: sufficient length to hold the prefix.
159: Level: advanced
161: .keywords: PetscViewer, get, options, prefix, database
163: .seealso: PetscViewerAppendOptionsPrefix()
164: @*/
165: PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer viewer,const char *prefix[])
166: {
171: PetscObjectGetOptionsPrefix((PetscObject)viewer,prefix);
172: return(0);
173: }
177: /*@
178: PetscViewerSetUp - Sets up the internal viewer data structures for the later use.
180: Collective on PetscViewer
182: Input Parameters:
183: . viewer - the PetscViewer context
185: Notes:
186: For basic use of the PetscViewer classes the user need not explicitly call
187: PetscViewerSetUp(), since these actions will happen automatically.
189: Level: advanced
191: .keywords: PetscViewer, setup
193: .seealso: PetscViewerCreate(), PetscViewerDestroy()
194: @*/
195: PetscErrorCode PetscViewerSetUp(PetscViewer viewer)
196: {
199: return(0);
200: }
204: /*@C
205: PetscViewerView - Visualizes a viewer object.
207: Collective on PetscViewer
209: Input Parameters:
210: + v - the viewer
211: - viewer - visualization context
213: Notes:
214: The available visualization contexts include
215: + PETSC_VIEWER_STDOUT_SELF - standard output (default)
216: . PETSC_VIEWER_STDOUT_WORLD - synchronized standard
217: output where only the first processor opens
218: the file. All other processors send their
219: data to the first processor to print.
220: - PETSC_VIEWER_DRAW_WORLD - graphical display of nonzero structure
222: Level: beginner
224: .seealso: PetscViewerSetFormat(), PetscViewerASCIIOpen(), PetscViewerDrawOpen(),
225: PetscViewerSocketOpen(), PetscViewerBinaryOpen(), PetscViewerLoad()
226: @*/
227: PetscErrorCode PetscViewerView(PetscViewer v,PetscViewer viewer)
228: {
229: PetscErrorCode ierr;
230: PetscTruth iascii;
231: const char *cstr;
232: PetscViewerFormat format;
237: if (!viewer) {
238: PetscViewerASCIIGetStdout(v->comm,&viewer);
239: }
243: PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&iascii);
244: if (iascii) {
245: PetscViewerGetFormat(viewer,&format);
246: if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
247: if (v->prefix) {
248: PetscViewerASCIIPrintf(viewer,"PetscViewer Object:(%s)\n",v->prefix);
249: } else {
250: PetscViewerASCIIPrintf(viewer,"PetscViewer Object:\n");
251: }
252: PetscViewerASCIIPushTab(viewer);
253: PetscViewerGetType(v,&cstr);
254: PetscViewerASCIIPrintf(viewer,"type=%s\n",cstr);
255: }
256: }
257: if (!iascii) {
258: SETERRQ1(PETSC_ERR_SUP,"Viewer type %s not supported",((PetscObject)viewer)->type_name);
259: } else {
260: PetscViewerGetFormat(viewer,&format);
261: if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
262: PetscViewerASCIIPopTab(viewer);
263: }
264: }
265: return(0);
266: }