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_HDF4 "hdf4"
64: #define PETSC_VIEWER_HDF5 "hdf5"
65: #define PETSC_VIEWER_MATLAB "matlab"
68: EXTERN PetscErrorCode PetscViewerRegisterAll(const char *);
69: EXTERN PetscErrorCode PetscViewerRegisterDestroy(void);
70: EXTERN PetscErrorCode PetscViewerInitializePackage(const char[]);
72: EXTERN PetscErrorCode PetscViewerRegister(const char*,const char*,const char*,PetscErrorCode (*)(PetscViewer));
74: /*MC
75: PetscViewerRegisterDynamic - Adds a method to the Krylov subspace solver package.
77: Synopsis:
78: PetscErrorCode PetscViewerRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(PetscViewer))
80: Not Collective
82: Input Parameters:
83: + name_solver - name of a new user-defined solver
84: . path - path (either absolute or relative) the library containing this solver
85: . name_create - name of routine to create method context
86: - routine_create - routine to create method context
88: Level: developer
90: Notes:
91: PetscViewerRegisterDynamic() may be called multiple times to add several user-defined solvers.
93: If dynamic libraries are used, then the fourth input argument (routine_create)
94: is ignored.
96: Sample usage:
97: .vb
98: PetscViewerRegisterDynamic("my_viewer_type",/home/username/my_lib/lib/libO/solaris/mylib.a,
99: "MyViewerCreate",MyViewerCreate);
100: .ve
102: Then, your solver can be chosen with the procedural interface via
103: $ PetscViewerSetType(ksp,"my_viewer_type")
104: or at runtime via the option
105: $ -viewer_type my_viewer_type
107: Concepts: registering^Viewers
109: .seealso: PetscViewerRegisterAll(), PetscViewerRegisterDestroy()
110: M*/
111: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
112: #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0)
113: #else
114: #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d)
115: #endif
117: EXTERN PetscErrorCode PetscViewerCreate(MPI_Comm,PetscViewer*);
118: PetscPolymorphicSubroutine(PetscViewerCreate,(PetscViewer *v),(PETSC_COMM_SELF,v))
119: EXTERN PetscErrorCode PetscViewerSetFromOptions(PetscViewer);
121: EXTERN PetscErrorCode PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*);
122: EXTERN PetscErrorCode PetscViewerBinaryCreate(MPI_Comm,PetscViewer*);
123: EXTERN PetscErrorCode PetscViewerBinaryOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
124: EXTERN PetscErrorCode PetscViewerBinarySetMPIIO(PetscViewer);
125: EXTERN PetscErrorCode PetscViewerBinaryGetMPIIO(PetscViewer,PetscTruth*);
126: #if defined(PETSC_HAVE_MPIIO)
127: EXTERN PetscErrorCode PetscViewerBinaryGetMPIIODescriptor(PetscViewer,MPI_File*);
128: EXTERN PetscErrorCode PetscViewerBinaryGetMPIIOOffset(PetscViewer,MPI_Offset*);
129: EXTERN PetscErrorCode PetscViewerBinaryAddMPIIOOffset(PetscViewer,MPI_Offset);
130: #endif
132: EXTERN PetscErrorCode PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*);
133: EXTERN PetscErrorCode PetscViewerStringOpen(MPI_Comm,char[],PetscInt,PetscViewer*);
134: EXTERN PetscErrorCode PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*);
135: EXTERN PetscErrorCode PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *);
136: EXTERN PetscErrorCode PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *);
137: EXTERN PetscErrorCode PetscViewerMatlabOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
139: EXTERN PetscErrorCode PetscViewerGetType(PetscViewer,const PetscViewerType*);
140: EXTERN PetscErrorCode PetscViewerSetType(PetscViewer,const PetscViewerType);
141: EXTERN PetscErrorCode PetscViewerDestroy(PetscViewer);
142: EXTERN PetscErrorCode PetscViewerGetSingleton(PetscViewer,PetscViewer*);
143: EXTERN PetscErrorCode PetscViewerRestoreSingleton(PetscViewer,PetscViewer*);
144: EXTERN PetscErrorCode PetscViewerGetSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
145: EXTERN PetscErrorCode PetscViewerRestoreSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
147: EXTERN PetscErrorCode PetscViewerSetUp(PetscViewer);
148: EXTERN PetscErrorCode PetscViewerView(PetscViewer,PetscViewer);
150: EXTERN PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer,const char[]);
151: EXTERN PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer,const char[]);
152: EXTERN PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer,const char*[]);
154: /*E
155: PetscViewerFormat - Way a viewer presents the object
157: Level: beginner
159: The values below are also listed in finclude/petscviewer.h. If another values is added below it
160: must also be added there.
162: .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat()
163: E*/
164: typedef enum {
165: PETSC_VIEWER_DEFAULT,
166: PETSC_VIEWER_ASCII_MATLAB,
167: PETSC_VIEWER_ASCII_MATHEMATICA,
168: PETSC_VIEWER_ASCII_IMPL,
169: PETSC_VIEWER_ASCII_INFO,
170: PETSC_VIEWER_ASCII_INFO_DETAIL,
171: PETSC_VIEWER_ASCII_COMMON,
172: PETSC_VIEWER_ASCII_SYMMODU,
173: PETSC_VIEWER_ASCII_INDEX,
174: PETSC_VIEWER_ASCII_DENSE,
175: PETSC_VIEWER_ASCII_MATRIXMARKET,
176: PETSC_VIEWER_ASCII_VTK,
177: PETSC_VIEWER_ASCII_VTK_CELL,
178: PETSC_VIEWER_ASCII_VTK_COORDS,
179: PETSC_VIEWER_ASCII_PCICE,
180: PETSC_VIEWER_ASCII_PYLITH,
181: PETSC_VIEWER_ASCII_PYLITH_LOCAL,
182: PETSC_VIEWER_ASCII_PYTHON,
183: PETSC_VIEWER_ASCII_FACTOR_INFO,
184: PETSC_VIEWER_DRAW_BASIC,
185: PETSC_VIEWER_DRAW_LG,
186: PETSC_VIEWER_DRAW_CONTOUR,
187: PETSC_VIEWER_DRAW_PORTS,
188: PETSC_VIEWER_NATIVE,
189: PETSC_VIEWER_NOFORMAT
190: } PetscViewerFormat;
192: EXTERN PetscErrorCode PetscViewerSetFormat(PetscViewer,PetscViewerFormat);
193: EXTERN PetscErrorCode PetscViewerPushFormat(PetscViewer,PetscViewerFormat);
194: EXTERN PetscErrorCode PetscViewerPopFormat(PetscViewer);
195: EXTERN PetscErrorCode PetscViewerGetFormat(PetscViewer,PetscViewerFormat*);
196: EXTERN PetscErrorCode PetscViewerFlush(PetscViewer);
198: /*S
199: PetscViewerASCIIMonitor - Context for the default KSP, SNES and TS monitors that print
200: ASCII strings of residual norms etc.
203: Level: advanced
205: Concepts: viewing, monitoring
207: .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, KSPMonitorSet(), SNESMonitorSet(), TSMonitorSet(),
208: KSPMonitorDefault(), SNESMonitorDefault()
210: S*/
211: struct _p_PetscViewerASCIIMonitor {
212: PetscViewer viewer;
213: PetscInt tabs;
214: };
215: typedef struct _p_PetscViewerASCIIMonitor* PetscViewerASCIIMonitor;
217: EXTERN PetscErrorCode PetscViewerASCIIMonitorCreate(MPI_Comm,const char *,PetscInt,PetscViewerASCIIMonitor*);
218: EXTERN PetscErrorCode PetscViewerASCIIMonitorDestroy(PetscViewerASCIIMonitor);
219: EXTERN PetscErrorCode PetscViewerASCIIMonitorPrintf(PetscViewerASCIIMonitor,const char[],...);
221: /*
222: Operations explicit to a particular class of viewers
223: */
225: EXTERN PetscErrorCode PetscViewerASCIIGetPointer(PetscViewer,FILE**);
226: EXTERN PetscErrorCode PetscViewerFileGetMode(PetscViewer,PetscFileMode*);
227: EXTERN PetscErrorCode PetscViewerFileSetMode(PetscViewer,PetscFileMode);
228: EXTERN PetscErrorCode PetscViewerASCIIPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
229: EXTERN PetscErrorCode PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
230: EXTERN PetscErrorCode PetscViewerASCIIPushTab(PetscViewer);
231: EXTERN PetscErrorCode PetscViewerASCIIPopTab(PetscViewer);
232: EXTERN PetscErrorCode PetscViewerASCIIUseTabs(PetscViewer,PetscTruth);
233: EXTERN PetscErrorCode PetscViewerASCIISetTab(PetscViewer,PetscInt);
234: EXTERN PetscErrorCode PetscViewerBinaryGetDescriptor(PetscViewer,int*);
235: EXTERN PetscErrorCode PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **);
236: EXTERN PetscErrorCode PetscViewerBinaryRead(PetscViewer,void*,PetscInt,PetscDataType);
237: EXTERN PetscErrorCode PetscViewerBinaryWrite(PetscViewer,void*,PetscInt,PetscDataType,PetscTruth);
238: EXTERN PetscErrorCode PetscViewerStringSPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
239: EXTERN PetscErrorCode PetscViewerStringSetString(PetscViewer,char[],PetscInt);
240: EXTERN PetscErrorCode PetscViewerDrawClear(PetscViewer);
241: EXTERN PetscErrorCode PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int);
242: EXTERN PetscErrorCode PetscViewerSocketSetConnection(PetscViewer,const char[],PetscInt);
243: EXTERN PetscErrorCode PetscViewerBinarySkipInfo(PetscViewer);
244: EXTERN PetscErrorCode PetscViewerBinarySetSkipOptions(PetscViewer,PetscTruth);
245: EXTERN PetscErrorCode PetscViewerBinaryGetSkipOptions(PetscViewer,PetscTruth*);
246: EXTERN PetscErrorCode PetscViewerBinaryReadStringArray(PetscViewer,char***);
247: EXTERN PetscErrorCode PetscViewerBinaryWriteStringArray(PetscViewer,char**);
249: EXTERN PetscErrorCode PetscViewerFileSetName(PetscViewer,const char[]);
250: EXTERN PetscErrorCode PetscViewerFileGetName(PetscViewer,char**);
252: EXTERN PetscErrorCode PetscPLAPACKInitializePackage(MPI_Comm com);
253: EXTERN PetscErrorCode PetscPLAPACKFinalizePackage(void);
255: EXTERN PetscErrorCode PetscViewerVUGetPointer(PetscViewer, FILE**);
256: EXTERN PetscErrorCode PetscViewerVUSetVecSeen(PetscViewer, PetscTruth);
257: EXTERN PetscErrorCode PetscViewerVUGetVecSeen(PetscViewer, PetscTruth *);
258: EXTERN PetscErrorCode PetscViewerVUPrintDeferred(PetscViewer, const char [], ...) PETSC_PRINTF_FORMAT_CHECK(2,3);
259: EXTERN PetscErrorCode PetscViewerVUFlushDeferred(PetscViewer);
261: EXTERN PetscErrorCode PetscViewerMathematicaInitializePackage(const char[]);
262: EXTERN PetscErrorCode PetscViewerMathematicaFinalizePackage(void);
263: EXTERN PetscErrorCode PetscViewerMathematicaGetName(PetscViewer, const char **);
264: EXTERN PetscErrorCode PetscViewerMathematicaSetName(PetscViewer, const char []);
265: EXTERN PetscErrorCode PetscViewerMathematicaClearName(PetscViewer);
266: EXTERN PetscErrorCode PetscViewerMathematicaSkipPackets(PetscViewer, int);
268: EXTERN PetscErrorCode PetscViewerSiloGetName(PetscViewer, char **);
269: EXTERN PetscErrorCode PetscViewerSiloSetName(PetscViewer, const char []);
270: EXTERN PetscErrorCode PetscViewerSiloClearName(PetscViewer);
271: EXTERN PetscErrorCode PetscViewerSiloGetMeshName(PetscViewer, char **);
272: EXTERN PetscErrorCode PetscViewerSiloSetMeshName(PetscViewer, const char []);
273: EXTERN PetscErrorCode PetscViewerSiloClearMeshName(PetscViewer);
275: EXTERN PetscErrorCode PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
276: EXTERN PetscErrorCode PetscViewerNetcdfGetID(PetscViewer, int *);
278: EXTERN PetscErrorCode PetscViewerHDF4Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
279: EXTERN PetscErrorCode PetscViewerHDF4WriteSDS(PetscViewer,float *,int,int *,int);
281: EXTERN PetscErrorCode PetscViewerHDF5Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
282: #ifdef PETSC_HAVE_HDF5
283: #include <hdf5.h>
284: EXTERN PetscErrorCode PetscViewerHDF5GetFileId(PetscViewer,hid_t*);
285: #endif
287: /*
288: These are all the default viewers that do not have
289: to be explicitly opened
290: */
291: EXTERN PetscViewer PETSC_VIEWER_STDOUT_(MPI_Comm);
292: EXTERN PetscErrorCode PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*);
293: EXTERN PetscViewer PETSC_VIEWER_STDERR_(MPI_Comm);
294: EXTERN PetscErrorCode PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*);
295: EXTERN PetscViewer PETSC_VIEWER_DRAW_(MPI_Comm);
296: EXTERN PetscViewer PETSC_VIEWER_SOCKET_(MPI_Comm);
297: EXTERN PetscViewer PETSC_VIEWER_BINARY_(MPI_Comm);
298: EXTERN PetscViewer PETSC_VIEWER_MATLAB_(MPI_Comm);
299: EXTERN PetscViewer PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE;
301: #define PETSC_VIEWER_STDERR_SELF PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
302: #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)
304: /*MC
305: PETSC_VIEWER_STDOUT_WORLD - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
307: Level: beginner
308: M*/
309: #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
311: /*MC
312: PETSC_VIEWER_STDOUT_SELF - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
314: Level: beginner
315: M*/
316: #define PETSC_VIEWER_STDOUT_SELF PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
318: /*MC
319: PETSC_VIEWER_DRAW_WORLD - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
321: Level: intermediate
322: M*/
323: #define PETSC_VIEWER_DRAW_WORLD PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
325: /*MC
326: PETSC_VIEWER_DRAW_SELF - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
328: Level: intermediate
329: M*/
330: #define PETSC_VIEWER_DRAW_SELF PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
332: /*MC
333: PETSC_VIEWER_SOCKET_WORLD - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
335: Level: intermediate
336: M*/
337: #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
339: /*MC
340: PETSC_VIEWER_SOCKET_SELF - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
342: Level: intermediate
343: M*/
344: #define PETSC_VIEWER_SOCKET_SELF PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
346: /*MC
347: PETSC_VIEWER_BINARY_WORLD - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
349: Level: intermediate
350: M*/
351: #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
353: /*MC
354: PETSC_VIEWER_BINARY_SELF - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
356: Level: intermediate
357: M*/
358: #define PETSC_VIEWER_BINARY_SELF PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
360: /*MC
361: PETSC_VIEWER_MATLAB_WORLD - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
363: Level: intermediate
364: M*/
365: #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
367: /*MC
368: PETSC_VIEWER_MATLAB_SELF - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
370: Level: intermediate
371: M*/
372: #define PETSC_VIEWER_MATLAB_SELF PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
374: #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE)
376: /*
377: petscViewer writes to Matlab .mat file
378: */
379: EXTERN PetscErrorCode PetscViewerMatlabPutArray(PetscViewer,int,int,PetscScalar*,char*);
380: EXTERN PetscErrorCode PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,char*);
381: EXTERN PetscErrorCode PetscViewerMatlabPutVariable(PetscViewer,const char*,void*);
383: /*S
384: PetscViewers - Abstract collection of PetscViewers
386: Level: intermediate
388: Concepts: viewing
390: .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
391: PetscViewersGetViewer()
392: S*/
393: typedef struct _n_PetscViewers* PetscViewers;
394: EXTERN PetscErrorCode PetscViewersCreate(MPI_Comm,PetscViewers*);
395: EXTERN PetscErrorCode PetscViewersDestroy(PetscViewers);
396: EXTERN PetscErrorCode PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*);
399: #endif