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 petscsys.h

 32: #endif


 37: }
 38: #endif


 41: /*
 42:     petscsys.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 viewer

 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 viewer
 83: .  path - path (either absolute or relative) the library containing this viewer
 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 viewers.

 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(viewer,"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  PetscViewerBinaryGetFlowControl(PetscViewer,PetscInt*);
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  PetscViewerHDF5WriteSDS(PetscViewer,float *,int,int *,int);

280: EXTERN PetscErrorCode  PetscViewerHDF5Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
281: #ifdef PETSC_HAVE_HDF5
282: #include <hdf5.h>
283: EXTERN PetscErrorCode  PetscViewerHDF5GetFileId(PetscViewer,hid_t*);
284: #endif

286: /*
287:      These are all the default viewers that do not have 
288:    to be explicitly opened
289: */
290: EXTERN PetscViewer  PETSC_VIEWER_STDOUT_(MPI_Comm);
291: EXTERN PetscErrorCode  PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*);
292: EXTERN PetscViewer  PETSC_VIEWER_STDERR_(MPI_Comm);
293: EXTERN PetscErrorCode  PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*);
294: EXTERN PetscViewer  PETSC_VIEWER_DRAW_(MPI_Comm);
295: EXTERN PetscViewer  PETSC_VIEWER_SOCKET_(MPI_Comm);
296: EXTERN PetscViewer  PETSC_VIEWER_BINARY_(MPI_Comm);
297: EXTERN PetscViewer  PETSC_VIEWER_MATLAB_(MPI_Comm);
298: EXTERN PetscViewer PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE;

300: #define PETSC_VIEWER_STDERR_SELF  PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
301: #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)

303: /*MC
304:   PETSC_VIEWER_STDOUT_WORLD  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)

306:   Level: beginner
307: M*/
308: #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)

310: /*MC
311:   PETSC_VIEWER_STDOUT_SELF  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)

313:   Level: beginner
314: M*/
315: #define PETSC_VIEWER_STDOUT_SELF  PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)

317: /*MC
318:   PETSC_VIEWER_DRAW_WORLD  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)

320:   Level: intermediate
321: M*/
322: #define PETSC_VIEWER_DRAW_WORLD   PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)

324: /*MC
325:   PETSC_VIEWER_DRAW_SELF  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)

327:   Level: intermediate
328: M*/
329: #define PETSC_VIEWER_DRAW_SELF    PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)

331: /*MC
332:   PETSC_VIEWER_SOCKET_WORLD  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)

334:   Level: intermediate
335: M*/
336: #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)

338: /*MC
339:   PETSC_VIEWER_SOCKET_SELF  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)

341:   Level: intermediate
342: M*/
343: #define PETSC_VIEWER_SOCKET_SELF  PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)

345: /*MC
346:   PETSC_VIEWER_BINARY_WORLD  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)

348:   Level: intermediate
349: M*/
350: #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)

352: /*MC
353:   PETSC_VIEWER_BINARY_SELF  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)

355:   Level: intermediate
356: M*/
357: #define PETSC_VIEWER_BINARY_SELF  PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)

359: /*MC
360:   PETSC_VIEWER_MATLAB_WORLD  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)

362:   Level: intermediate
363: M*/
364: #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)

366: /*MC
367:   PETSC_VIEWER_MATLAB_SELF  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)

369:   Level: intermediate
370: M*/
371: #define PETSC_VIEWER_MATLAB_SELF  PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)

373: #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE) 

375: /*
376:    petscViewer writes to Matlab .mat file
377: */
378: EXTERN PetscErrorCode  PetscViewerMatlabPutArray(PetscViewer,int,int,PetscScalar*,char*);
379: EXTERN PetscErrorCode  PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,char*);
380: EXTERN PetscErrorCode  PetscViewerMatlabPutVariable(PetscViewer,const char*,void*);

382: /*S
383:      PetscViewers - Abstract collection of PetscViewers

385:    Level: intermediate

387:   Concepts: viewing

389: .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
390:            PetscViewersGetViewer()
391: S*/
392: typedef struct _n_PetscViewers* PetscViewers;
393: EXTERN PetscErrorCode  PetscViewersCreate(MPI_Comm,PetscViewers*);
394: EXTERN PetscErrorCode  PetscViewersDestroy(PetscViewers);
395: EXTERN PetscErrorCode  PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*);

398: #endif