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;
9: /*@C
10: PetscViewerInitializePackage - This function initializes everything in the main PetscViewer package.
12: Input Parameter:
13: path - The dynamic library path, or PETSC_NULL
15: Level: developer
17: .keywords: Petsc, initialize, package
18: .seealso: PetscInitialize()
19: @*/
20: PetscErrorCode PetscViewerInitializePackage(const char path[])
21: {
22: static PetscTruth initialized = PETSC_FALSE;
23: char logList[256];
24: char *className;
25: PetscTruth opt;
26: PetscErrorCode ierr;
29: if (initialized) return(0);
30: initialized = PETSC_TRUE;
31: /* Register Classes */
32: PetscCookieRegister("Viewer",&PETSC_VIEWER_COOKIE);
34: /* Register Constructors */
35: PetscViewerRegisterAll(path);
37: /* Process info exclusions */
38: PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);
39: if (opt) {
40: PetscStrstr(logList, "viewer", &className);
41: if (className) {
42: PetscInfoDeactivateClass(0);
43: }
44: }
45: /* Process summary exclusions */
46: PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
47: if (opt) {
48: PetscStrstr(logList, "viewer", &className);
49: if (className) {
50: PetscLogEventDeactivateClass(0);
51: }
52: }
53: #if defined(PETSC_HAVE_MATHEMATICA)
54: PetscViewerMathematicaInitializePackage(PETSC_NULL);
55: #endif
56: return(0);
57: }
61: /*@
62: PetscViewerDestroy - Destroys a PetscViewer.
64: Collective on PetscViewer
66: Input Parameters:
67: . viewer - the PetscViewer to be destroyed.
69: Level: beginner
71: .seealso: PetscViewerSocketOpen(), PetscViewerASCIIOpen(), PetscViewerCreate(), PetscViewerDrawOpen()
73: @*/
74: PetscErrorCode PetscViewerDestroy(PetscViewer viewer)
75: {
80: PetscViewerFlush(viewer);
81: if (--((PetscObject)viewer)->refct > 0) return(0);
83: PetscObjectDepublish(viewer);
85: if (viewer->ops->destroy) {
86: (*viewer->ops->destroy)(viewer);
87: }
88: PetscHeaderDestroy(viewer);
89: return(0);
90: }
94: /*@C
95: PetscViewerGetType - Returns the type of a PetscViewer.
97: Not Collective
99: Input Parameter:
100: . viewer - the PetscViewer
102: Output Parameter:
103: . type - PetscViewer type (see below)
105: Available Types Include:
106: . PETSC_VIEWER_SOCKET - Socket PetscViewer
107: . PETSC_VIEWER_ASCII - ASCII PetscViewer
108: . PETSC_VIEWER_BINARY - binary file PetscViewer
109: . PETSC_VIEWER_STRING - string PetscViewer
110: . PETSC_VIEWER_DRAW - drawing PetscViewer
112: Level: intermediate
114: Note:
115: See include/petscviewer.h for a complete list of PetscViewers.
117: PetscViewerType is actually a string
119: .seealso: PetscViewerCreate(), PetscViewerSetType()
121: @*/
122: PetscErrorCode PetscViewerGetType(PetscViewer viewer,const PetscViewerType *type)
123: {
127: *type = ((PetscObject)viewer)->type_name;
128: return(0);
129: }
133: /*@C
134: PetscViewerSetOptionsPrefix - Sets the prefix used for searching for all
135: PetscViewer options in the database.
137: Collective on PetscViewer
139: Input Parameter:
140: + viewer - the PetscViewer context
141: - prefix - the prefix to prepend to all option names
143: Notes:
144: A hyphen (-) must NOT be given at the beginning of the prefix name.
145: The first character of all runtime options is AUTOMATICALLY the hyphen.
147: Level: advanced
149: .keywords: PetscViewer, set, options, prefix, database
151: .seealso: PetscViewerSetFromOptions()
152: @*/
153: PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer viewer,const char prefix[])
154: {
159: PetscObjectSetOptionsPrefix((PetscObject)viewer,prefix);
160: return(0);
161: }
165: /*@C
166: PetscViewerAppendOptionsPrefix - Appends to the prefix used for searching for all
167: PetscViewer options in the database.
169: Collective on PetscViewer
171: Input Parameters:
172: + viewer - the PetscViewer context
173: - prefix - the prefix to prepend to all option names
175: Notes:
176: A hyphen (-) must NOT be given at the beginning of the prefix name.
177: The first character of all runtime options is AUTOMATICALLY the hyphen.
179: Level: advanced
181: .keywords: PetscViewer, append, options, prefix, database
183: .seealso: PetscViewerGetOptionsPrefix()
184: @*/
185: PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer viewer,const char prefix[])
186: {
188:
191: PetscObjectAppendOptionsPrefix((PetscObject)viewer,prefix);
192: return(0);
193: }
197: /*@C
198: PetscViewerGetOptionsPrefix - Sets the prefix used for searching for all
199: PetscViewer options in the database.
201: Not Collective
203: Input Parameter:
204: . viewer - the PetscViewer context
206: Output Parameter:
207: . prefix - pointer to the prefix string used
209: Notes: On the fortran side, the user should pass in a string 'prefix' of
210: sufficient length to hold the prefix.
212: Level: advanced
214: .keywords: PetscViewer, get, options, prefix, database
216: .seealso: PetscViewerAppendOptionsPrefix()
217: @*/
218: PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer viewer,const char *prefix[])
219: {
224: PetscObjectGetOptionsPrefix((PetscObject)viewer,prefix);
225: return(0);
226: }
230: /*@
231: PetscViewerSetUp - Sets up the internal viewer data structures for the later use.
233: Collective on PetscViewer
235: Input Parameters:
236: . viewer - the PetscViewer context
238: Notes:
239: For basic use of the PetscViewer classes the user need not explicitly call
240: PetscViewerSetUp(), since these actions will happen automatically.
242: Level: advanced
244: .keywords: PetscViewer, setup
246: .seealso: PetscViewerCreate(), PetscViewerDestroy()
247: @*/
248: PetscErrorCode PetscViewerSetUp(PetscViewer viewer)
249: {
252: return(0);
253: }
257: /*@C
258: PetscViewerView - Visualizes a viewer object.
260: Collective on PetscViewer
262: Input Parameters:
263: + v - the viewer
264: - viewer - visualization context
266: Notes:
267: The available visualization contexts include
268: + PETSC_VIEWER_STDOUT_SELF - standard output (default)
269: . PETSC_VIEWER_STDOUT_WORLD - synchronized standard
270: output where only the first processor opens
271: the file. All other processors send their
272: data to the first processor to print.
273: - PETSC_VIEWER_DRAW_WORLD - graphical display of nonzero structure
275: Level: beginner
277: .seealso: PetscViewerSetFormat(), PetscViewerASCIIOpen(), PetscViewerDrawOpen(),
278: PetscViewerSocketOpen(), PetscViewerBinaryOpen(), PetscViewerLoad()
279: @*/
280: PetscErrorCode PetscViewerView(PetscViewer v,PetscViewer viewer)
281: {
282: PetscErrorCode ierr;
283: PetscTruth iascii;
284: const PetscViewerType cstr;
285: PetscViewerFormat format;
290: if (!viewer) {
291: PetscViewerASCIIGetStdout(((PetscObject)v)->comm,&viewer);
292: }
296: PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&iascii);
297: if (iascii) {
298: PetscViewerGetFormat(viewer,&format);
299: if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
300: if (((PetscObject)v)->prefix) {
301: PetscViewerASCIIPrintf(viewer,"PetscViewer Object:(%s)\n",((PetscObject)v)->prefix);
302: } else {
303: PetscViewerASCIIPrintf(viewer,"PetscViewer Object:\n");
304: }
305: PetscViewerASCIIPushTab(viewer);
306: PetscViewerGetType(v,&cstr);
307: PetscViewerASCIIPrintf(viewer,"type=%s\n",cstr);
308: }
309: }
310: if (!iascii) {
311: SETERRQ1(PETSC_ERR_SUP,"Viewer type %s not supported",((PetscObject)viewer)->type_name);
312: } else {
313: PetscViewerGetFormat(viewer,&format);
314: if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
315: PetscViewerASCIIPopTab(viewer);
316: }
317: }
318: return(0);
319: }