Actual source code: view.c
1: #define PETSC_DLL
3: #include "src/sys/src/viewer/viewerimpl.h" /*I "petsc.h" I*/
5: PetscCookie PETSC_VIEWER_COOKIE = 0;
9: /*@C
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 PETSC_DLLEXPORT PetscViewerDestroy(PetscViewer viewer)
23: {
28: if (--viewer->refct > 0) return(0);
30: PetscObjectDepublish(viewer);
32: if (viewer->ops->destroy) {
33: (*viewer->ops->destroy)(viewer);
34: }
35: PetscHeaderDestroy(viewer);
36: return(0);
37: }
41: /*@C
42: PetscViewerGetType - Returns the type of a PetscViewer.
44: Not Collective
46: Input Parameter:
47: . viewer - the PetscViewer
49: Output Parameter:
50: . type - PetscViewer type (see below)
52: Available Types Include:
53: . PETSC_VIEWER_SOCKET - Socket PetscViewer
54: . PETSC_VIEWER_ASCII - ASCII PetscViewer
55: . PETSC_VIEWER_BINARY - binary file PetscViewer
56: . PETSC_VIEWER_STRING - string PetscViewer
57: . PETSC_VIEWER_DRAW - drawing PetscViewer
59: Level: intermediate
61: Note:
62: See include/petscviewer.h for a complete list of PetscViewers.
64: PetscViewerType is actually a string
66: .seealso: PetscViewerCreate(), PetscViewerSetType()
68: @*/
69: PetscErrorCode PETSC_DLLEXPORT PetscViewerGetType(PetscViewer viewer,PetscViewerType *type)
70: {
73: *type = (PetscViewerType) viewer->type_name;
74: return(0);
75: }
79: /*@C
80: PetscViewerSetOptionsPrefix - Sets the prefix used for searching for all
81: PetscViewer options in the database.
83: Collective on PetscViewer
85: Input Parameter:
86: + viewer - the PetscViewer context
87: - prefix - the prefix to prepend to all option names
89: Notes:
90: A hyphen (-) must NOT be given at the beginning of the prefix name.
91: The first character of all runtime options is AUTOMATICALLY the hyphen.
93: Level: advanced
95: .keywords: PetscViewer, set, options, prefix, database
97: .seealso: PetscViewerSetFromOptions()
98: @*/
99: PetscErrorCode PETSC_DLLEXPORT PetscViewerSetOptionsPrefix(PetscViewer viewer,const char prefix[])
100: {
105: PetscObjectSetOptionsPrefix((PetscObject)viewer,prefix);
106: return(0);
107: }
111: /*@C
112: PetscViewerAppendOptionsPrefix - Appends to the prefix used for searching for all
113: PetscViewer options in the database.
115: Collective on PetscViewer
117: Input Parameters:
118: + viewer - the PetscViewer context
119: - prefix - the prefix to prepend to all option names
121: Notes:
122: A hyphen (-) must NOT be given at the beginning of the prefix name.
123: The first character of all runtime options is AUTOMATICALLY the hyphen.
125: Level: advanced
127: .keywords: PetscViewer, append, options, prefix, database
129: .seealso: PetscViewerGetOptionsPrefix()
130: @*/
131: PetscErrorCode PETSC_DLLEXPORT PetscViewerAppendOptionsPrefix(PetscViewer viewer,const char prefix[])
132: {
134:
137: PetscObjectAppendOptionsPrefix((PetscObject)viewer,prefix);
138: return(0);
139: }
143: /*@C
144: PetscViewerGetOptionsPrefix - Sets the prefix used for searching for all
145: PetscViewer options in the database.
147: Not Collective
149: Input Parameter:
150: . viewer - the PetscViewer context
152: Output Parameter:
153: . prefix - pointer to the prefix string used
155: Notes: On the fortran side, the user should pass in a string 'prefix' of
156: sufficient length to hold the prefix.
158: Level: advanced
160: .keywords: PetscViewer, get, options, prefix, database
162: .seealso: PetscViewerAppendOptionsPrefix()
163: @*/
164: PetscErrorCode PETSC_DLLEXPORT PetscViewerGetOptionsPrefix(PetscViewer viewer,const char *prefix[])
165: {
170: PetscObjectGetOptionsPrefix((PetscObject)viewer,prefix);
171: return(0);
172: }
176: /*@
177: PetscViewerSetUp - Sets up the internal viewer data structures for the later use.
179: Collective on PetscViewer
181: Input Parameters:
182: . viewer - the PetscViewer context
184: Notes:
185: For basic use of the PetscViewer classes the user need not explicitly call
186: PetscViewerSetUp(), since these actions will happen automatically.
188: Level: advanced
190: .keywords: PetscViewer, setup
192: .seealso: PetscViewerCreate(), PetscViewerDestroy()
193: @*/
194: PetscErrorCode PETSC_DLLEXPORT PetscViewerSetUp(PetscViewer viewer)
195: {
198: return(0);
199: }
203: /*@C
204: PetscViewerView - Visualizes a viewer object.
206: Collective on PetscViewer
208: Input Parameters:
209: + v - the viewer
210: - viewer - visualization context
212: Notes:
213: The available visualization contexts include
214: + PETSC_VIEWER_STDOUT_SELF - standard output (default)
215: . PETSC_VIEWER_STDOUT_WORLD - synchronized standard
216: output where only the first processor opens
217: the file. All other processors send their
218: data to the first processor to print.
219: - PETSC_VIEWER_DRAW_WORLD - graphical display of nonzero structure
221: Level: beginner
223: .seealso: PetscViewerSetFormat(), PetscViewerASCIIOpen(), PetscViewerDrawOpen(),
224: PetscViewerSocketOpen(), PetscViewerBinaryOpen(), PetscViewerLoad()
225: @*/
226: PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerView(PetscViewer v,PetscViewer viewer)
227: {
228: PetscErrorCode ierr;
229: PetscTruth iascii;
230: const char *cstr;
231: PetscViewerFormat format;
236: if (!viewer) viewer = PETSC_VIEWER_STDOUT_(v->comm);
240: PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&iascii);
241: if (iascii) {
242: PetscViewerGetFormat(viewer,&format);
243: if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
244: if (v->prefix) {
245: PetscViewerASCIIPrintf(viewer,"PetscViewer Object:(%s)\n",v->prefix);
246: } else {
247: PetscViewerASCIIPrintf(viewer,"PetscViewer Object:\n");
248: }
249: PetscViewerASCIIPushTab(viewer);
250: PetscViewerGetType(v,&cstr);
251: PetscViewerASCIIPrintf(viewer,"type=%s\n",cstr);
252: }
253: }
254: if (!iascii) {
255: SETERRQ1(PETSC_ERR_SUP,"Viewer type %s not supported",((PetscObject)viewer)->type_name);
256: } else {
257: PetscViewerGetFormat(viewer,&format);
258: if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
259: PetscViewerASCIIPopTab(viewer);
260: }
261: }
262: return(0);
263: }