Actual source code: petscviewer.h

  1: /*
  2:      PetscViewers are objects where other objects can be looked at or stored.
  3: */
  4: #pragma once

  6: #include <petscsys.h>
  7: #include <petscviewertypes.h>
  8: #include <petscdrawtypes.h>

 10: /* MANSEC = Sys */
 11: /* SUBMANSEC = Viewer */

 13: PETSC_EXTERN PetscClassId PETSC_VIEWER_CLASSID;

 15: /*J
 16:    PetscViewerType - String with the name of a PETSc `PetscViewer` implementation

 18:    Level: beginner

 20: .seealso: [](sec_viewers), `PetscViewerSetType()`, `PetscViewer`, `PetscViewerRegister()`, `PetscViewerCreate()`
 21: J*/
 22: typedef const char *PetscViewerType;
 23: #define PETSCVIEWERSOCKET      "socket"
 24: #define PETSCVIEWERASCII       "ascii"
 25: #define PETSCVIEWERBINARY      "binary"
 26: #define PETSCVIEWERSTRING      "string"
 27: #define PETSCVIEWERDRAW        "draw"
 28: #define PETSCVIEWERVU          "vu"
 29: #define PETSCVIEWERMATHEMATICA "mathematica"
 30: #define PETSCVIEWERHDF5        "hdf5"
 31: #define PETSCVIEWERVTK         "vtk"
 32: #define PETSCVIEWERMATLAB      "matlab"
 33: #define PETSCVIEWERSAWS        "saws"
 34: #define PETSCVIEWERGLVIS       "glvis"
 35: #define PETSCVIEWERADIOS       "adios"
 36: #define PETSCVIEWEREXODUSII    "exodusii"
 37: #define PETSCVIEWERCGNS        "cgns"
 38: #define PETSCVIEWERPYTHON      "python"
 39: #define PETSCVIEWERPYVISTA     "pyvista"

 41: PETSC_EXTERN PetscFunctionList PetscViewerList;
 42: PETSC_EXTERN PetscErrorCode    PetscViewerInitializePackage(void);
 43: PETSC_EXTERN PetscErrorCode    PetscViewerFinalizePackage(void);

 45: PETSC_EXTERN PetscErrorCode PetscViewerRegister(const char[], PetscErrorCode (*)(PetscViewer));

 47: PETSC_EXTERN PetscErrorCode PetscViewerCreate(MPI_Comm, PetscViewer *);
 48: PETSC_EXTERN PetscErrorCode PetscViewerSetFromOptions(PetscViewer);
 49: PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpenWithFILE(MPI_Comm, FILE *, PetscViewer *);

 51: PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpen(MPI_Comm, const char[], PetscViewer *);
 52: PETSC_EXTERN PetscErrorCode PetscViewerASCIISetFILE(PetscViewer, FILE *);
 53: PETSC_EXTERN PetscErrorCode PetscViewerBinaryOpen(MPI_Comm, const char[], PetscFileMode, PetscViewer *);
 54: PETSC_EXTERN PetscErrorCode PetscViewerADIOSOpen(MPI_Comm, const char[], PetscFileMode, PetscViewer *);
 55: PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetFlowControl(PetscViewer, PetscInt *);
 56: PETSC_EXTERN PetscErrorCode PetscViewerBinarySetFlowControl(PetscViewer, PetscInt);
 57: PETSC_EXTERN PetscErrorCode PetscViewerBinarySetUseMPIIO(PetscViewer, PetscBool);
 58: PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetUseMPIIO(PetscViewer, PetscBool *);
 59: #if defined(PETSC_HAVE_MPIIO)
 60: PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIODescriptor(PetscViewer, MPI_File *);
 61: PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIOOffset(PetscViewer, MPI_Offset *);
 62: PETSC_EXTERN PetscErrorCode PetscViewerBinaryAddMPIIOOffset(PetscViewer, MPI_Offset);
 63: #endif

 65: PETSC_EXTERN PetscErrorCode PetscViewerSocketOpen(MPI_Comm, const char[], int, PetscViewer *);
 66: PETSC_EXTERN PetscErrorCode PetscViewerStringOpen(MPI_Comm, char[], size_t, PetscViewer *);
 67: PETSC_EXTERN PetscErrorCode PetscViewerDrawOpen(MPI_Comm, const char[], const char[], int, int, int, int, PetscViewer *);
 68: PETSC_EXTERN PetscErrorCode PetscViewerDrawSetDrawType(PetscViewer, PetscDrawType);

 70: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *);
 71: PETSC_EXTERN PetscErrorCode PetscViewerMatlabOpen(MPI_Comm, const char[], PetscFileMode, PetscViewer *);

 73: /*E
 74:     PetscViewerGLVisType - indicates what type of `PETSCVIEWERGLVIS` viewer to use

 76:     Values:
 77: +   `PETSC_VIEWER_GLVIS_DUMP`   - save the data to a file
 78: -   `PETSC_VIEWER_GLVIS_SOCKET` - communicate the data to another program via a socket

 80:     Level: beginner

 82: .seealso: [](sec_viewers), `PETSCVIEWERGLVIS`, `PetscViewerGLVisOpen()`
 83: E*/
 84: typedef enum {
 85:   PETSC_VIEWER_GLVIS_DUMP,
 86:   PETSC_VIEWER_GLVIS_SOCKET
 87: } PetscViewerGLVisType;
 88: PETSC_EXTERN PetscErrorCode PetscViewerGLVisOpen(MPI_Comm, PetscViewerGLVisType, const char *, PetscInt, PetscViewer *);
 89: PETSC_EXTERN PetscErrorCode PetscViewerGLVisSetPrecision(PetscViewer, PetscInt);
 90: PETSC_EXTERN PetscErrorCode PetscViewerGLVisSetSnapId(PetscViewer, PetscInt);
 91: PETSC_EXTERN PetscErrorCode PetscViewerGLVisSetFields(PetscViewer, PetscInt, const char *[], PetscInt[], PetscErrorCode (*)(PetscObject, PetscInt, PetscObject[], void *), PetscObject[], void *, PetscCtxDestroyFn *);

 93: PETSC_EXTERN PetscErrorCode PetscViewerGetType(PetscViewer, PetscViewerType *);
 94: PETSC_EXTERN PetscErrorCode PetscViewerSetType(PetscViewer, PetscViewerType);
 95: PETSC_EXTERN PetscErrorCode PetscViewerDestroy(PetscViewer *);
 96: PETSC_EXTERN PetscErrorCode PetscViewerGetSubViewer(PetscViewer, MPI_Comm, PetscViewer *);
 97: PETSC_EXTERN PetscErrorCode PetscViewerRestoreSubViewer(PetscViewer, MPI_Comm, PetscViewer *);

 99: PETSC_EXTERN PetscErrorCode PetscViewerSetUp(PetscViewer);
100: PETSC_EXTERN PetscErrorCode PetscViewerView(PetscViewer, PetscViewer);
101: PETSC_EXTERN PetscErrorCode PetscViewerViewFromOptions(PetscViewer, PetscObject, const char[]);

103: PETSC_EXTERN PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer, const char[]);
104: PETSC_EXTERN PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer, const char[]);
105: PETSC_EXTERN PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer, const char *[]);

107: PETSC_EXTERN PetscErrorCode PetscViewerReadable(PetscViewer, PetscBool *);
108: PETSC_EXTERN PetscErrorCode PetscViewerWritable(PetscViewer, PetscBool *);
109: PETSC_EXTERN PetscErrorCode PetscViewerCheckReadable(PetscViewer);
110: PETSC_EXTERN PetscErrorCode PetscViewerCheckWritable(PetscViewer);

112: /*E
113:    PetscViewerFormat - Way a viewer presents the object

115:    Values:
116: +    `PETSC_VIEWER_DEFAULT`           - default format for the specific object being viewed
117: .    `PETSC_VIEWER_ASCII_MATLAB`      - MATLAB format
118: .    `PETSC_VIEWER_ASCII_DENSE`       - print matrix as a dense two dimensiona array
119: .    `PETSC_VIEWER_ASCII_IMPL`        - implementation-specific format (which is in many cases the same as the default)
120: .    `PETSC_VIEWER_ASCII_INFO`        - basic information about object
121: .    `PETSC_VIEWER_ASCII_INFO_DETAIL` - more detailed info about object (but still not vector or matrix entries)
122: .    `PETSC_VIEWER_ASCII_COMMON`      - identical output format for all objects of a particular type
123: .    `PETSC_VIEWER_ASCII_INDEX`       - (for vectors) prints the vector  element number next to each vector entry
124: .    `PETSC_VIEWER_ASCII_SYMMODU`     - print parallel vectors without indicating the MPI process ranges that own the entries
125: .    `PETSC_VIEWER_ASCII_VTK`         - outputs the object to a VTK file (deprecated since v3.14)
126: .    `PETSC_VIEWER_NATIVE`            - store the object to the binary file in its native format (for example, dense
127:                                         matrices are stored as dense), `DMDA` vectors are dumped directly to the
128:                                         file instead of being first put in the natural ordering
129: .    `PETSC_VIEWER_ASCII_LATEX`       - output the data in LaTeX
130: .    `PETSC_VIEWER_BINARY_MATLAB`     - output additional information that can be used to read the data into MATLAB
131: .    `PETSC_VIEWER_DRAW_BASIC`        - views the vector with a simple 1d plot
132: .    `PETSC_VIEWER_DRAW_LG`           - views the vector with a line graph
133: -    `PETSC_VIEWER_DRAW_CONTOUR`      - views the vector with a contour plot

135:    Level: beginner

137:    Note:
138:    A variety of specialized formats also exist

140: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerType`, `PetscViewerPushFormat()`, `PetscViewerPopFormat()`
141: E*/
142: typedef enum {
143:   PETSC_VIEWER_DEFAULT,
144:   PETSC_VIEWER_ASCII_MATLAB,
145:   PETSC_VIEWER_ASCII_MATHEMATICA,
146:   PETSC_VIEWER_ASCII_IMPL,
147:   PETSC_VIEWER_ASCII_INFO,
148:   PETSC_VIEWER_ASCII_INFO_DETAIL,
149:   PETSC_VIEWER_ASCII_COMMON,
150:   PETSC_VIEWER_ASCII_SYMMODU,
151:   PETSC_VIEWER_ASCII_INDEX,
152:   PETSC_VIEWER_ASCII_DENSE,
153:   PETSC_VIEWER_ASCII_MATRIXMARKET,
154:   PETSC_VIEWER_ASCII_PCICE,
155:   PETSC_VIEWER_ASCII_PYTHON,
156:   PETSC_VIEWER_ASCII_FACTOR_INFO,
157:   PETSC_VIEWER_ASCII_LATEX,
158:   PETSC_VIEWER_ASCII_XML,
159:   PETSC_VIEWER_ASCII_FLAMEGRAPH,
160:   PETSC_VIEWER_ASCII_GLVIS,
161:   PETSC_VIEWER_ASCII_CSV,
162:   PETSC_VIEWER_DRAW_BASIC,
163:   PETSC_VIEWER_DRAW_LG,
164:   PETSC_VIEWER_DRAW_LG_XRANGE,
165:   PETSC_VIEWER_DRAW_CONTOUR,
166:   PETSC_VIEWER_DRAW_PORTS,
167:   PETSC_VIEWER_VTK_VTS,
168:   PETSC_VIEWER_VTK_VTR,
169:   PETSC_VIEWER_VTK_VTU,
170:   PETSC_VIEWER_BINARY_MATLAB,
171:   PETSC_VIEWER_NATIVE,
172:   PETSC_VIEWER_HDF5_PETSC,
173:   PETSC_VIEWER_HDF5_VIZ,
174:   PETSC_VIEWER_HDF5_XDMF,
175:   PETSC_VIEWER_HDF5_MAT,
176:   PETSC_VIEWER_NOFORMAT,
177:   PETSC_VIEWER_LOAD_BALANCE,
178:   PETSC_VIEWER_FAILED,
179:   PETSC_VIEWER_ALL
180: } PetscViewerFormat;
181: PETSC_EXTERN const char *const PetscViewerFormats[];

183: PETSC_EXTERN PETSC_DEPRECATED_FUNCTION(3, 7, 0, "PetscViewerPushFormat() / PetscViewerPopFormat()", ) PetscErrorCode PetscViewerSetFormat(PetscViewer, PetscViewerFormat);
184: PETSC_EXTERN PetscErrorCode PetscViewerPushFormat(PetscViewer, PetscViewerFormat);
185: PETSC_EXTERN PetscErrorCode PetscViewerPopFormat(PetscViewer);
186: PETSC_EXTERN PetscErrorCode PetscViewerGetFormat(PetscViewer, PetscViewerFormat *);
187: PETSC_EXTERN PetscErrorCode PetscViewerFlush(PetscViewer);

189: PETSC_EXTERN PetscErrorCode PetscOptionsPushCreateViewerOff(PetscBool);
190: PETSC_EXTERN PetscErrorCode PetscOptionsPopCreateViewerOff(void);
191: PETSC_EXTERN PetscErrorCode PetscOptionsGetCreateViewerOff(PetscBool *);
192: PETSC_EXTERN PetscErrorCode PetscOptionsCreateViewer(MPI_Comm, PetscOptions, const char[], const char[], PetscViewer *, PetscViewerFormat *, PetscBool *);
193: PETSC_EXTERN PetscErrorCode PetscOptionsCreateViewers(MPI_Comm, PetscOptions, const char[], const char[], PetscInt *, PetscViewer *, PetscViewerFormat *, PetscBool *);
194: /*MC
195:    PetscOptionsViewer - From a `PetscOptionsBegin()`/`PetscOptionsEnd()` block, read a viewer specification from the options database and create the requested `PetscViewer`

197:    Synopsis:
198: #include <petscviewer.h>
199:    PetscErrorCode PetscOptionsViewer(const char opt[], const char text[], const char man[], PetscViewer *viewer, PetscViewerFormat *format, PetscBool *set)

201:    Logically Collective

203:    Input Parameters:
204: +  opt  - the option name, for example `-vec_view`
205: .  text - help string shown by `-help`
206: -  man  - manual page name (the name of an `.html` file under the PETSc doc tree)

208:    Output Parameters:
209: +  viewer - the `PetscViewer` created, or `NULL` if the option was not given
210: .  format - the `PetscViewerFormat` requested by the option, or the default
211: -  set    - `PETSC_TRUE` if the user supplied the option, `PETSC_FALSE` otherwise

213:    Level: beginner

215:    Note:
216:    Must be called between `PetscOptionsBegin()` and `PetscOptionsEnd()`; expands to a call to the internal `PetscOptionsViewer_Private()`, which has access to the current `PetscOptionsObject`. Destroy `viewer` with `PetscViewerDestroy()` when finished.

218: .seealso: `PetscOptionsCreateViewer()`, `PetscOptionsBegin()`, `PetscOptionsEnd()`, `PetscViewer`, `PetscViewerFormat`,
219:           `PetscViewerDestroy()`
220: M*/
221: #define PetscOptionsViewer(a, b, c, d, e, f) PetscOptionsViewer_Private(PetscOptionsObject, a, b, c, d, e, f)
222: PETSC_EXTERN PetscErrorCode PetscOptionsViewer_Private(PetscOptionItems, const char[], const char[], const char[], PetscViewer *, PetscViewerFormat *, PetscBool *);

224: PETSC_DEPRECATED_FUNCTION(3, 22, 0, "PetscViewerDestroy()", ) static inline PetscErrorCode PetscOptionsRestoreViewer(PetscViewer *viewer)
225: {
226:   return PetscViewerDestroy(viewer);
227: }
228: PETSC_DEPRECATED_FUNCTION(3, 22, 0, "PetscOptionsCreateViewer()", ) static inline PetscErrorCode PetscOptionsGetViewer(MPI_Comm comm, PetscOptions op, const char a[], const char b[], PetscViewer *v, PetscViewerFormat *f, PetscBool *fg)
229: {
230:   return PetscOptionsCreateViewer(comm, op, a, b, v, f, fg);
231: }
232: PETSC_DEPRECATED_FUNCTION(3, 22, 0, "PetscOptionsCreateViewers()", ) static inline PetscErrorCode PetscOptionsGetViewers(MPI_Comm comm, PetscOptions op, const char a[], const char b[], PetscInt *n, PetscViewer *v, PetscViewerFormat *f, PetscBool *fg)
233: {
234:   return PetscOptionsCreateViewers(comm, op, a, b, n, v, f, fg);
235: }
236: PETSC_DEPRECATED_FUNCTION(3, 22, 0, "PetscOptionsGetCreateViewerOff()", ) static inline PetscErrorCode PetscOptionsGetViewerOff(PetscBool *fg)
237: {
238:   return PetscOptionsGetCreateViewerOff(fg);
239: }
240: PETSC_DEPRECATED_FUNCTION(3, 22, 0, "PetscOptionsPushCreateViewerOff()", ) static inline PetscErrorCode PetscOptionsPushGetViewerOff(PetscBool fg)
241: {
242:   return PetscOptionsPushCreateViewerOff(fg);
243: }
244: PETSC_DEPRECATED_FUNCTION(3, 22, 0, "PetscOptionsPushCreateViewerOff()", ) static inline PetscErrorCode PetscOptionsPopGetViewerOff(void)
245: {
246:   return PetscOptionsPopCreateViewerOff();
247: }

249: /*S
250:   PetscViewerAndFormat - A struct that contains both a `PetscViewer` and a `PetscViewerFormat` plus some optional situation-dependent data

252:   Level: beginner

254:   Note:
255:   Used by most monitor functions including, for example, `KSPMonitorResidual()`

257: .seealso: [](sec_viewers), `PetscViewerType`, `PETSCVIEWERASCII`, `PetscViewerCreate()`, `PetscViewerSetType()`,
258:           `VecView()`, `VecViewFromOptions()`, `PetscObjectView()`, `PetscViewerFormat`, `PetscViewer`,
259:           `PetscViewerAndFormatCreate()`, `PetscViewerAndFormatDestroy()`, `KSPMonitorResidual()`
260: S*/
261: typedef struct {
262:   PetscViewer        viewer;
263:   PetscViewerFormat  format;
264:   PetscInt           view_interval;
265:   void              *data;
266:   PetscCtxDestroyFn *data_destroy;
267: } PetscViewerAndFormat;

269: PETSC_EXTERN PetscErrorCode PetscViewerAndFormatCreate(PetscViewer, PetscViewerFormat, PetscViewerAndFormat **);
270: PETSC_EXTERN PetscErrorCode PetscViewerAndFormatDestroy(PetscViewerAndFormat **);

272: /*
273:    Operations explicit to a particular class of viewers
274: */

276: PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetPointer(PetscViewer, FILE **);
277: PETSC_EXTERN PetscErrorCode PetscViewerFileGetMode(PetscViewer, PetscFileMode *);
278: PETSC_EXTERN PetscErrorCode PetscViewerFileSetMode(PetscViewer, PetscFileMode);
279: PETSC_EXTERN PetscErrorCode PetscViewerRead(PetscViewer, void *, PetscInt, PetscInt *, PetscDataType);
280: PETSC_EXTERN PetscErrorCode PetscViewerASCIIPrintf(PetscViewer, const char[], ...) PETSC_ATTRIBUTE_FORMAT(2, 3);
281: PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedPrintf(PetscViewer, const char[], ...) PETSC_ATTRIBUTE_FORMAT(2, 3);
282: PETSC_EXTERN PetscErrorCode PetscViewerASCIIPushSynchronized(PetscViewer);
283: PETSC_EXTERN PetscErrorCode PetscViewerASCIIPopSynchronized(PetscViewer);
284: PETSC_EXTERN PetscErrorCode PetscViewerASCIIPushTab(PetscViewer);
285: PETSC_EXTERN PetscErrorCode PetscViewerASCIIPopTab(PetscViewer);
286: PETSC_EXTERN PetscErrorCode PetscViewerASCIIUseTabs(PetscViewer, PetscBool);
287: PETSC_EXTERN PetscErrorCode PetscViewerASCIISetTab(PetscViewer, PetscInt);
288: PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetTab(PetscViewer, PetscInt *);
289: PETSC_EXTERN PetscErrorCode PetscViewerASCIIAddTab(PetscViewer, PetscInt);
290: PETSC_EXTERN PetscErrorCode PetscViewerASCIISubtractTab(PetscViewer, PetscInt);
291: PETSC_EXTERN PetscErrorCode PetscViewerASCIIRead(PetscViewer, void *, PetscInt, PetscInt *, PetscDataType);
292: PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetDescriptor(PetscViewer, int *);
293: PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetInfoPointer(PetscViewer, FILE **);
294: PETSC_EXTERN PetscErrorCode PetscViewerBinaryRead(PetscViewer, void *, PetscInt, PetscInt *, PetscDataType);
295: PETSC_EXTERN PetscErrorCode PetscViewerBinaryWrite(PetscViewer, const void *, PetscInt, PetscDataType);
296: PETSC_EXTERN PetscErrorCode PetscViewerBinaryReadAll(PetscViewer, void *, PetscCount, PetscCount, PetscCount, PetscDataType);
297: PETSC_EXTERN PetscErrorCode PetscViewerBinaryWriteAll(PetscViewer, const void *, PetscCount, PetscCount, PetscCount, PetscDataType);
298: PETSC_EXTERN PetscErrorCode PetscViewerStringSPrintf(PetscViewer, const char[], ...) PETSC_ATTRIBUTE_FORMAT(2, 3);
299: PETSC_EXTERN PetscErrorCode PetscViewerStringSetString(PetscViewer, char[], size_t);
300: PETSC_EXTERN PetscErrorCode PetscViewerStringGetStringRead(PetscViewer, const char *[], size_t *);
301: PETSC_EXTERN PetscErrorCode PetscViewerStringSetOwnString(PetscViewer);
302: PETSC_EXTERN PetscErrorCode PetscViewerDrawClear(PetscViewer);
303: PETSC_EXTERN PetscErrorCode PetscViewerDrawSetHold(PetscViewer, PetscBool);
304: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetHold(PetscViewer, PetscBool *);
305: PETSC_EXTERN PetscErrorCode PetscViewerDrawSetPause(PetscViewer, PetscReal);
306: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetPause(PetscViewer, PetscReal *);
307: PETSC_EXTERN PetscErrorCode PetscViewerDrawSetInfo(PetscViewer, const char[], const char[], int, int, int, int);
308: PETSC_EXTERN PetscErrorCode PetscViewerDrawResize(PetscViewer, int, int);
309: PETSC_EXTERN PetscErrorCode PetscViewerDrawSetBounds(PetscViewer, PetscInt, const PetscReal *);
310: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetBounds(PetscViewer, PetscInt *, const PetscReal **);
311: PETSC_EXTERN PetscErrorCode PetscViewerSocketSetConnection(PetscViewer, const char[], int);
312: PETSC_EXTERN PetscErrorCode PetscViewerBinarySkipInfo(PetscViewer);
313: PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipInfo(PetscViewer, PetscBool);
314: PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipInfo(PetscViewer, PetscBool *);
315: PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipOptions(PetscViewer, PetscBool);
316: PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipOptions(PetscViewer, PetscBool *);
317: PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipHeader(PetscViewer, PetscBool);
318: PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipHeader(PetscViewer, PetscBool *);
319: PETSC_EXTERN PetscErrorCode PetscViewerBinaryReadStringArray(PetscViewer, char ***);
320: PETSC_EXTERN PetscErrorCode PetscViewerBinaryWriteStringArray(PetscViewer, const char *const *);

322: PETSC_EXTERN PetscErrorCode PetscViewerFileSetName(PetscViewer, const char[]);
323: PETSC_EXTERN PetscErrorCode PetscViewerFileGetName(PetscViewer, const char *[]);

325: PETSC_EXTERN PetscErrorCode PetscViewerVUGetPointer(PetscViewer, FILE **);
326: PETSC_EXTERN PetscErrorCode PetscViewerVUSetVecSeen(PetscViewer, PetscBool);
327: PETSC_EXTERN PetscErrorCode PetscViewerVUGetVecSeen(PetscViewer, PetscBool *);
328: PETSC_EXTERN PetscErrorCode PetscViewerVUPrintDeferred(PetscViewer, const char[], ...) PETSC_ATTRIBUTE_FORMAT(2, 3);
329: PETSC_EXTERN PetscErrorCode PetscViewerVUFlushDeferred(PetscViewer);

331: /*@C
332:   PetscViewerVUSetMode - Sets the mode in which to open the file.

334:   Not Collective

336:   Input Parameters:
337: + viewer - The `PetscViewer`
338: - mode   - The file mode

340:   Level: deprecated

342:   Note:
343:   Use `PetscViewerFileSetMode()` instead.

345: .seealso: [](sec_viewers), `PetscViewer`, `PetscViewerFileSetMode()`
346: @*/
347: PETSC_DEPRECATED_FUNCTION(3, 15, 0, "PetscViewerFileSetMode()", ) static inline PetscErrorCode PetscViewerVUSetMode(PetscViewer viewer, PetscFileMode mode)
348: {
349:   return PetscViewerFileSetMode(viewer, mode);
350: }

352: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaInitializePackage(void);
353: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaFinalizePackage(void);
354: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetName(PetscViewer, const char **);
355: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSetName(PetscViewer, const char[]);
356: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaClearName(PetscViewer);
357: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSkipPackets(PetscViewer, int);

359: PETSC_EXTERN PetscErrorCode PetscViewerSiloClearName(PetscViewer);
360: PETSC_EXTERN PetscErrorCode PetscViewerSiloClearMeshName(PetscViewer);

362: /*E
363:    PetscViewerVTKFieldType - Categorizes a field that is being written through a `PETSCVIEWERVTK` viewer so that the VTK writer can place it on the correct mesh entity and with the correct component layout

365:    Values:
366: +   `PETSC_VTK_INVALID`            - sentinel for an uninitialized entry
367: .   `PETSC_VTK_POINT_FIELD`        - scalar (or generic multi-component) field stored at mesh points
368: .   `PETSC_VTK_POINT_VECTOR_FIELD` - vector-valued field stored at mesh points
369: .   `PETSC_VTK_CELL_FIELD`         - scalar (or generic multi-component) field stored on mesh cells
370: -   `PETSC_VTK_CELL_VECTOR_FIELD`  - vector-valued field stored on mesh cells

372:    Level: developer

374: .seealso: `PETSCVIEWERVTK`, `PetscViewerVTKAddField()`, `PetscViewerVTKOpen()`, `PetscViewer`
375: E*/
376: typedef enum {
377:   PETSC_VTK_INVALID,
378:   PETSC_VTK_POINT_FIELD,
379:   PETSC_VTK_POINT_VECTOR_FIELD,
380:   PETSC_VTK_CELL_FIELD,
381:   PETSC_VTK_CELL_VECTOR_FIELD
382: } PetscViewerVTKFieldType;
383: PETSC_EXTERN PetscErrorCode PetscViewerVTKAddField(PetscViewer, PetscObject, PetscErrorCode (*PetscViewerVTKWriteFunction)(PetscObject, PetscViewer), PetscInt, PetscViewerVTKFieldType, PetscBool, PetscObject);
384: PETSC_EXTERN PetscErrorCode PetscViewerVTKGetDM(PetscViewer, PetscObject *);
385: PETSC_EXTERN PetscErrorCode PetscViewerVTKOpen(MPI_Comm, const char[], PetscFileMode, PetscViewer *);

387: /*
388:      These are all the default viewers that do not have to be explicitly opened
389: */
390: PETSC_EXTERN PetscViewer    PETSC_VIEWER_STDOUT_(MPI_Comm);
391: PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStdout(MPI_Comm, PetscViewer *);
392: PETSC_EXTERN PetscViewer    PETSC_VIEWER_STDERR_(MPI_Comm);
393: PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStderr(MPI_Comm, PetscViewer *);
394: PETSC_EXTERN PetscViewer    PETSC_VIEWER_DRAW_(MPI_Comm);
395: PETSC_EXTERN PetscViewer    PETSC_VIEWER_SOCKET_(MPI_Comm);
396: PETSC_EXTERN PetscViewer    PETSC_VIEWER_BINARY_(MPI_Comm);
397: PETSC_EXTERN PetscViewer    PETSC_VIEWER_MATLAB_(MPI_Comm);
398: PETSC_EXTERN PetscViewer    PETSC_VIEWER_HDF5_(MPI_Comm);
399: PETSC_EXTERN PetscViewer    PETSC_VIEWER_GLVIS_(MPI_Comm);
400: PETSC_EXTERN PetscViewer    PETSC_VIEWER_EXODUSII_(MPI_Comm);
401: PETSC_EXTERN PetscViewer    PETSC_VIEWER_PYTHON_(MPI_Comm);
402: PETSC_EXTERN PetscViewer    PETSC_VIEWER_PYVISTA_(MPI_Comm);
403: PETSC_EXTERN PetscViewer    PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE;

405: /*MC
406:   PETSC_VIEWER_STDERR_SELF  - same as `PETSC_VIEWER_STDERR_`(PETSC_COMM_SELF)

408:   Level: beginner
409: M*/
410: #define PETSC_VIEWER_STDERR_SELF PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)

412: /*MC
413:   PETSC_VIEWER_STDERR_WORLD  - same as `PETSC_VIEWER_STDERR_`(PETSC_COMM_WORLD)

415:   Level: beginner
416: M*/
417: #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)

419: /*MC
420:   PETSC_VIEWER_STDOUT_WORLD  - same as `PETSC_VIEWER_STDOUT_`(PETSC_COMM_WORLD)

422:   Level: beginner
423: M*/
424: #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)

426: /*MC
427:   PETSC_VIEWER_STDOUT_SELF  - same as `PETSC_VIEWER_STDOUT_`(PETSC_COMM_SELF)

429:   Level: beginner
430: M*/
431: #define PETSC_VIEWER_STDOUT_SELF PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)

433: /*MC
434:   PETSC_VIEWER_DRAW_WORLD  - same as `PETSC_VIEWER_DRAW_`(PETSC_COMM_WORLD)

436:   Level: intermediate
437: M*/
438: #define PETSC_VIEWER_DRAW_WORLD PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)

440: /*MC
441:   PETSC_VIEWER_DRAW_SELF  - same as `PETSC_VIEWER_DRAW_`(PETSC_COMM_SELF)

443:   Level: intermediate
444: M*/
445: #define PETSC_VIEWER_DRAW_SELF PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)

447: /*MC
448:   PETSC_VIEWER_SOCKET_WORLD  - same as `PETSC_VIEWER_SOCKET_`(PETSC_COMM_WORLD)

450:   Level: intermediate
451: M*/
452: #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)

454: /*MC
455:   PETSC_VIEWER_SOCKET_SELF  - same as `PETSC_VIEWER_SOCKET_`(PETSC_COMM_SELF)

457:   Level: intermediate
458: M*/
459: #define PETSC_VIEWER_SOCKET_SELF PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)

461: /*MC
462:   PETSC_VIEWER_BINARY_WORLD  - same as `PETSC_VIEWER_BINARY_`(PETSC_COMM_WORLD)

464:   Level: intermediate
465: M*/
466: #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)

468: /*MC
469:   PETSC_VIEWER_BINARY_SELF  - same as `PETSC_VIEWER_BINARY_`(PETSC_COMM_SELF)

471:   Level: intermediate
472: M*/
473: #define PETSC_VIEWER_BINARY_SELF PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)

475: /*MC
476:   PETSC_VIEWER_MATLAB_WORLD  - same as `PETSC_VIEWER_MATLAB_`(PETSC_COMM_WORLD)

478:   Level: intermediate
479: M*/
480: #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)

482: /*MC
483:   PETSC_VIEWER_MATLAB_SELF  - same as `PETSC_VIEWER_MATLAB_`(PETSC_COMM_SELF)

485:   Level: intermediate
486: M*/
487: #define PETSC_VIEWER_MATLAB_SELF PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)

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

491: PETSC_EXTERN PetscErrorCode PetscViewerFlowControlStart(PetscViewer, PetscInt *, PetscInt *);
492: PETSC_EXTERN PetscErrorCode PetscViewerFlowControlStepMain(PetscViewer, PetscInt, PetscInt *, PetscInt);
493: PETSC_EXTERN PetscErrorCode PetscViewerFlowControlEndMain(PetscViewer, PetscInt *);
494: PETSC_EXTERN PetscErrorCode PetscViewerFlowControlStepWorker(PetscViewer, PetscMPIInt, PetscInt *);
495: PETSC_EXTERN PetscErrorCode PetscViewerFlowControlEndWorker(PetscViewer, PetscInt *);
496: PETSC_DEPRECATED_FUNCTION(3, 15, 0, "PetscViewerFlowControlStepMain()", ) static inline PetscErrorCode PetscViewerFlowControlStepMaster(PetscViewer viewer, PetscInt i, PetscInt *mcnt, PetscInt cnt)
497: {
498:   return PetscViewerFlowControlStepMain(viewer, i, mcnt, cnt);
499: }
500: PETSC_DEPRECATED_FUNCTION(3, 15, 0, "PetscViewerFlowControlEndMain()", ) static inline PetscErrorCode PetscViewerFlowControlEndMaster(PetscViewer viewer, PetscInt *mcnt)
501: {
502:   return PetscViewerFlowControlEndMain(viewer, mcnt);
503: }

505: /*
506:    PetscViewer writes to MATLAB .mat file
507: */
508: PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutArray(PetscViewer, int, int, const PetscScalar *, const char *);
509: PETSC_EXTERN PetscErrorCode PetscViewerMatlabGetArray(PetscViewer, int, int, PetscScalar *, const char *);
510: PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutVariable(PetscViewer, const char *, void *);

512: #if defined(PETSC_HAVE_SAWS)
513: PETSC_EXTERN PetscErrorCode PetscObjectViewSAWs(PetscObject, PetscViewer);
514: #endif

516: PETSC_EXTERN PetscErrorCode PetscViewerPythonSetType(PetscViewer, const char[]);
517: PETSC_EXTERN PetscErrorCode PetscViewerPythonGetType(PetscViewer, const char *[]);
518: PETSC_EXTERN PetscErrorCode PetscViewerPythonCreate(MPI_Comm, const char[], PetscViewer *);
519: PETSC_EXTERN PetscErrorCode PetscViewerPythonViewObject(PetscViewer, PetscObject);

521: PETSC_EXTERN PetscErrorCode PetscViewerMonitorLGSetUp(PetscViewer, const char[], const char[], const char[], PetscInt, const char *[], int, int, int, int);

523: /*S
524:    PetscViewers - Abstract collection of `PetscViewer`s. It is stored as an expandable array of viewers.

526:    Level: intermediate

528: .seealso: [](sec_viewers), `PetscViewerCreate()`, `PetscViewerSetType()`, `PetscViewerType`, `PetscViewer`, `PetscViewersCreate()`,
529:           `PetscViewersGetViewer()`
530: S*/
531: typedef struct _n_PetscViewers *PetscViewers;
532: PETSC_EXTERN PetscErrorCode     PetscViewersCreate(MPI_Comm, PetscViewers *);
533: PETSC_EXTERN PetscErrorCode     PetscViewersDestroy(PetscViewers *);
534: PETSC_EXTERN PetscErrorCode     PetscViewersGetViewer(PetscViewers, PetscInt, PetscViewer *);