Actual source code: petscviewer.h
1: /*
2: PetscViewers are objects where other objects can be looked at or stored.
3: */
10: #endif
12: /*S
13: PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc)
14: other PETSc objects
16: Level: beginner
18: Concepts: viewing
20: .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType
21: S*/
22: typedef struct _p_PetscViewer* PetscViewer;
25: }
26: #endif
28: #include petsc.h
32: #endif
37: }
38: #endif
41: /*
42: petsc.h must be included AFTER the definition of PetscViewer for ADIC to
43: process correctly.
44: */
46: /*E
47: PetscViewerType - String with the name of a PETSc PETScViewer
49: Level: beginner
51: .seealso: PetscViewerSetType(), PetscViewer
52: E*/
53: #define PetscViewerType char*
54: #define PETSC_VIEWER_SOCKET "socket"
55: #define PETSC_VIEWER_ASCII "ascii"
56: #define PETSC_VIEWER_BINARY "binary"
57: #define PETSC_VIEWER_STRING "string"
58: #define PETSC_VIEWER_DRAW "draw"
59: #define PETSC_VIEWER_VU "vu"
60: #define PETSC_VIEWER_MATHEMATICA "mathematica"
61: #define PETSC_VIEWER_SILO "silo"
62: #define PETSC_VIEWER_NETCDF "netcdf"
63: #define PETSC_VIEWER_HDF5 "hdf5"
64: #define PETSC_VIEWER_MATLAB "matlab"
67: EXTERN PetscErrorCode PetscViewerRegisterAll(const char *);
68: EXTERN PetscErrorCode PetscViewerRegisterDestroy(void);
69: EXTERN PetscErrorCode PetscViewerInitializePackage(const char[]);
71: EXTERN PetscErrorCode PetscViewerRegister(const char*,const char*,const char*,PetscErrorCode (*)(PetscViewer));
73: /*MC
74: PetscViewerRegisterDynamic - Adds a method to the Krylov subspace solver package.
76: Synopsis:
77: PetscErrorCode PetscViewerRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(PetscViewer))
79: Not Collective
81: Input Parameters:
82: + name_solver - name of a new user-defined solver
83: . path - path (either absolute or relative) the library containing this solver
84: . name_create - name of routine to create method context
85: - routine_create - routine to create method context
87: Level: developer
89: Notes:
90: PetscViewerRegisterDynamic() may be called multiple times to add several user-defined solvers.
92: If dynamic libraries are used, then the fourth input argument (routine_create)
93: is ignored.
95: Sample usage:
96: .vb
97: PetscViewerRegisterDynamic("my_viewer_type",/home/username/my_lib/lib/libO/solaris/mylib.a,
98: "MyViewerCreate",MyViewerCreate);
99: .ve
101: Then, your solver can be chosen with the procedural interface via
102: $ PetscViewerSetType(ksp,"my_viewer_type")
103: or at runtime via the option
104: $ -viewer_type my_viewer_type
106: Concepts: registering^Viewers
108: .seealso: PetscViewerRegisterAll(), PetscViewerRegisterDestroy()
109: M*/
110: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
111: #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0)
112: #else
113: #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d)
114: #endif
116: EXTERN PetscErrorCode PetscViewerCreate(MPI_Comm,PetscViewer*);
117: PetscPolymorphicSubroutine(PetscViewerCreate,(PetscViewer *v),(PETSC_COMM_SELF,v))
118: EXTERN PetscErrorCode PetscViewerSetFromOptions(PetscViewer);
120: EXTERN PetscErrorCode PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*);
121: EXTERN PetscErrorCode PetscViewerBinaryCreate(MPI_Comm,PetscViewer*);
122: EXTERN PetscErrorCode PetscViewerBinaryOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
123: EXTERN PetscErrorCode PetscViewerBinarySetMPIIO(PetscViewer);
124: EXTERN PetscErrorCode PetscViewerBinaryGetMPIIO(PetscViewer,PetscTruth*);
125: #if defined(PETSC_HAVE_MPIIO)
126: EXTERN PetscErrorCode PetscViewerBinaryGetMPIIODescriptor(PetscViewer,MPI_File*);
127: EXTERN PetscErrorCode PetscViewerBinaryGetMPIIOOffset(PetscViewer,MPI_Offset*);
128: EXTERN PetscErrorCode PetscViewerBinaryAddMPIIOOffset(PetscViewer,MPI_Offset);
129: #endif
131: EXTERN PetscErrorCode PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*);
132: EXTERN PetscErrorCode PetscViewerStringOpen(MPI_Comm,char[],PetscInt,PetscViewer*);
133: EXTERN PetscErrorCode PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*);
134: EXTERN PetscErrorCode PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *);
135: EXTERN PetscErrorCode PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *);
136: EXTERN PetscErrorCode PetscViewerMatlabOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
138: EXTERN PetscErrorCode PetscViewerGetType(PetscViewer,const PetscViewerType*);
139: EXTERN PetscErrorCode PetscViewerSetType(PetscViewer,const PetscViewerType);
140: EXTERN PetscErrorCode PetscViewerDestroy(PetscViewer);
141: EXTERN PetscErrorCode PetscViewerGetSingleton(PetscViewer,PetscViewer*);
142: EXTERN PetscErrorCode PetscViewerRestoreSingleton(PetscViewer,PetscViewer*);
143: EXTERN PetscErrorCode PetscViewerGetSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
144: EXTERN PetscErrorCode PetscViewerRestoreSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
146: EXTERN PetscErrorCode PetscViewerSetUp(PetscViewer);
147: EXTERN PetscErrorCode PetscViewerView(PetscViewer,PetscViewer);
149: EXTERN PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer,const char[]);
150: EXTERN PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer,const char[]);
151: EXTERN PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer,const char*[]);
153: /*E
154: PetscViewerFormat - Way a viewer presents the object
156: Level: beginner
158: The values below are also listed in finclude/petscviewer.h. If another values is added below it
159: must also be added there.
161: .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat()
162: E*/
163: typedef enum {
164: PETSC_VIEWER_DEFAULT,
165: PETSC_VIEWER_ASCII_MATLAB,
166: PETSC_VIEWER_ASCII_MATHEMATICA,
167: PETSC_VIEWER_ASCII_IMPL,
168: PETSC_VIEWER_ASCII_INFO,
169: PETSC_VIEWER_ASCII_INFO_DETAIL,
170: PETSC_VIEWER_ASCII_COMMON,
171: PETSC_VIEWER_ASCII_SYMMODU,
172: PETSC_VIEWER_ASCII_INDEX,
173: PETSC_VIEWER_ASCII_DENSE,
174: PETSC_VIEWER_ASCII_MATRIXMARKET,
175: PETSC_VIEWER_ASCII_VTK,
176: PETSC_VIEWER_ASCII_VTK_CELL,
177: PETSC_VIEWER_ASCII_VTK_COORDS,
178: PETSC_VIEWER_ASCII_PCICE,
179: PETSC_VIEWER_ASCII_PYLITH,
180: PETSC_VIEWER_ASCII_PYLITH_LOCAL,
181: PETSC_VIEWER_ASCII_PYTHON,
182: PETSC_VIEWER_ASCII_FACTOR_INFO,
183: PETSC_VIEWER_DRAW_BASIC,
184: PETSC_VIEWER_DRAW_LG,
185: PETSC_VIEWER_DRAW_CONTOUR,
186: PETSC_VIEWER_DRAW_PORTS,
187: PETSC_VIEWER_NATIVE,
188: PETSC_VIEWER_NOFORMAT
189: } PetscViewerFormat;
191: EXTERN PetscErrorCode PetscViewerSetFormat(PetscViewer,PetscViewerFormat);
192: EXTERN PetscErrorCode PetscViewerPushFormat(PetscViewer,PetscViewerFormat);
193: EXTERN PetscErrorCode PetscViewerPopFormat(PetscViewer);
194: EXTERN PetscErrorCode PetscViewerGetFormat(PetscViewer,PetscViewerFormat*);
195: EXTERN PetscErrorCode PetscViewerFlush(PetscViewer);
197: /*S
198: PetscViewerASCIIMonitor - Context for the default KSP, SNES and TS monitors that print
199: ASCII strings of residual norms etc.
202: Level: advanced
204: Concepts: viewing, monitoring
206: .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, KSPMonitorSet(), SNESMonitorSet(), TSMonitorSet(),
207: KSPMonitorDefault(), SNESMonitorDefault()
209: S*/
210: struct _p_PetscViewerASCIIMonitor {
211: PetscViewer viewer;
212: PetscInt tabs;
213: };
214: typedef struct _p_PetscViewerASCIIMonitor* PetscViewerASCIIMonitor;
216: EXTERN PetscErrorCode PetscViewerASCIIMonitorCreate(MPI_Comm,const char *,PetscInt,PetscViewerASCIIMonitor*);
217: EXTERN PetscErrorCode PetscViewerASCIIMonitorDestroy(PetscViewerASCIIMonitor);
218: EXTERN PetscErrorCode PetscViewerASCIIMonitorPrintf(PetscViewerASCIIMonitor,const char[],...);
220: /*
221: Operations explicit to a particular class of viewers
222: */
224: EXTERN PetscErrorCode PetscViewerASCIIGetPointer(PetscViewer,FILE**);
225: EXTERN PetscErrorCode PetscViewerFileGetMode(PetscViewer,PetscFileMode*);
226: EXTERN PetscErrorCode PetscViewerFileSetMode(PetscViewer,PetscFileMode);
227: EXTERN PetscErrorCode PetscViewerASCIIPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
228: EXTERN PetscErrorCode PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
229: EXTERN PetscErrorCode PetscViewerASCIIPushTab(PetscViewer);
230: EXTERN PetscErrorCode PetscViewerASCIIPopTab(PetscViewer);
231: EXTERN PetscErrorCode PetscViewerASCIIUseTabs(PetscViewer,PetscTruth);
232: EXTERN PetscErrorCode PetscViewerASCIISetTab(PetscViewer,PetscInt);
233: EXTERN PetscErrorCode PetscViewerBinaryGetDescriptor(PetscViewer,int*);
234: EXTERN PetscErrorCode PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **);
235: EXTERN PetscErrorCode PetscViewerBinaryRead(PetscViewer,void*,PetscInt,PetscDataType);
236: EXTERN PetscErrorCode PetscViewerBinaryWrite(PetscViewer,void*,PetscInt,PetscDataType,PetscTruth);
237: EXTERN PetscErrorCode PetscViewerStringSPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
238: EXTERN PetscErrorCode PetscViewerStringSetString(PetscViewer,char[],PetscInt);
239: EXTERN PetscErrorCode PetscViewerDrawClear(PetscViewer);
240: EXTERN PetscErrorCode PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int);
241: EXTERN PetscErrorCode PetscViewerSocketSetConnection(PetscViewer,const char[],PetscInt);
242: EXTERN PetscErrorCode PetscViewerBinarySkipInfo(PetscViewer);
243: EXTERN PetscErrorCode PetscViewerBinarySetSkipOptions(PetscViewer,PetscTruth);
244: EXTERN PetscErrorCode PetscViewerBinaryGetSkipOptions(PetscViewer,PetscTruth*);
245: EXTERN PetscErrorCode PetscViewerBinaryReadStringArray(PetscViewer,char***);
246: EXTERN PetscErrorCode PetscViewerBinaryWriteStringArray(PetscViewer,char**);
248: EXTERN PetscErrorCode PetscViewerFileSetName(PetscViewer,const char[]);
249: EXTERN PetscErrorCode PetscViewerFileGetName(PetscViewer,char**);
251: EXTERN PetscErrorCode PetscPLAPACKInitializePackage(MPI_Comm com);
252: EXTERN PetscErrorCode PetscPLAPACKFinalizePackage(void);
254: EXTERN PetscErrorCode PetscViewerVUGetPointer(PetscViewer, FILE**);
255: EXTERN PetscErrorCode PetscViewerVUSetVecSeen(PetscViewer, PetscTruth);
256: EXTERN PetscErrorCode PetscViewerVUGetVecSeen(PetscViewer, PetscTruth *);
257: EXTERN PetscErrorCode PetscViewerVUPrintDeferred(PetscViewer, const char [], ...) PETSC_PRINTF_FORMAT_CHECK(2,3);
258: EXTERN PetscErrorCode PetscViewerVUFlushDeferred(PetscViewer);
260: EXTERN PetscErrorCode PetscViewerMathematicaInitializePackage(const char[]);
261: EXTERN PetscErrorCode PetscViewerMathematicaFinalizePackage(void);
262: EXTERN PetscErrorCode PetscViewerMathematicaGetName(PetscViewer, const char **);
263: EXTERN PetscErrorCode PetscViewerMathematicaSetName(PetscViewer, const char []);
264: EXTERN PetscErrorCode PetscViewerMathematicaClearName(PetscViewer);
265: EXTERN PetscErrorCode PetscViewerMathematicaSkipPackets(PetscViewer, int);
267: EXTERN PetscErrorCode PetscViewerSiloGetName(PetscViewer, char **);
268: EXTERN PetscErrorCode PetscViewerSiloSetName(PetscViewer, const char []);
269: EXTERN PetscErrorCode PetscViewerSiloClearName(PetscViewer);
270: EXTERN PetscErrorCode PetscViewerSiloGetMeshName(PetscViewer, char **);
271: EXTERN PetscErrorCode PetscViewerSiloSetMeshName(PetscViewer, const char []);
272: EXTERN PetscErrorCode PetscViewerSiloClearMeshName(PetscViewer);
274: EXTERN PetscErrorCode PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
275: EXTERN PetscErrorCode PetscViewerNetcdfGetID(PetscViewer, int *);
277: EXTERN PetscErrorCode PetscViewerHDF5WriteSDS(PetscViewer,float *,int,int *,int);
279: EXTERN PetscErrorCode PetscViewerHDF5Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
280: #ifdef PETSC_HAVE_HDF5
281: #include <hdf5.h>
282: EXTERN PetscErrorCode PetscViewerHDF5GetFileId(PetscViewer,hid_t*);
283: #endif
285: /*
286: These are all the default viewers that do not have
287: to be explicitly opened
288: */
289: EXTERN PetscViewer PETSC_VIEWER_STDOUT_(MPI_Comm);
290: EXTERN PetscErrorCode PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*);
291: EXTERN PetscViewer PETSC_VIEWER_STDERR_(MPI_Comm);
292: EXTERN PetscErrorCode PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*);
293: EXTERN PetscViewer PETSC_VIEWER_DRAW_(MPI_Comm);
294: EXTERN PetscViewer PETSC_VIEWER_SOCKET_(MPI_Comm);
295: EXTERN PetscViewer PETSC_VIEWER_BINARY_(MPI_Comm);
296: EXTERN PetscViewer PETSC_VIEWER_MATLAB_(MPI_Comm);
297: EXTERN PetscViewer PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE;
299: #define PETSC_VIEWER_STDERR_SELF PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
300: #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)
302: /*MC
303: PETSC_VIEWER_STDOUT_WORLD - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
305: Level: beginner
306: M*/
307: #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
309: /*MC
310: PETSC_VIEWER_STDOUT_SELF - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
312: Level: beginner
313: M*/
314: #define PETSC_VIEWER_STDOUT_SELF PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
316: /*MC
317: PETSC_VIEWER_DRAW_WORLD - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
319: Level: intermediate
320: M*/
321: #define PETSC_VIEWER_DRAW_WORLD PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
323: /*MC
324: PETSC_VIEWER_DRAW_SELF - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
326: Level: intermediate
327: M*/
328: #define PETSC_VIEWER_DRAW_SELF PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
330: /*MC
331: PETSC_VIEWER_SOCKET_WORLD - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
333: Level: intermediate
334: M*/
335: #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
337: /*MC
338: PETSC_VIEWER_SOCKET_SELF - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
340: Level: intermediate
341: M*/
342: #define PETSC_VIEWER_SOCKET_SELF PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
344: /*MC
345: PETSC_VIEWER_BINARY_WORLD - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
347: Level: intermediate
348: M*/
349: #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
351: /*MC
352: PETSC_VIEWER_BINARY_SELF - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
354: Level: intermediate
355: M*/
356: #define PETSC_VIEWER_BINARY_SELF PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
358: /*MC
359: PETSC_VIEWER_MATLAB_WORLD - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
361: Level: intermediate
362: M*/
363: #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
365: /*MC
366: PETSC_VIEWER_MATLAB_SELF - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
368: Level: intermediate
369: M*/
370: #define PETSC_VIEWER_MATLAB_SELF PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
372: #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE)
374: /*
375: petscViewer writes to Matlab .mat file
376: */
377: EXTERN PetscErrorCode PetscViewerMatlabPutArray(PetscViewer,int,int,PetscScalar*,char*);
378: EXTERN PetscErrorCode PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,char*);
379: EXTERN PetscErrorCode PetscViewerMatlabPutVariable(PetscViewer,const char*,void*);
381: /*S
382: PetscViewers - Abstract collection of PetscViewers
384: Level: intermediate
386: Concepts: viewing
388: .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
389: PetscViewersGetViewer()
390: S*/
391: typedef struct _n_PetscViewers* PetscViewers;
392: EXTERN PetscErrorCode PetscViewersCreate(MPI_Comm,PetscViewers*);
393: EXTERN PetscErrorCode PetscViewersDestroy(PetscViewers);
394: EXTERN PetscErrorCode PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*);
397: #endif