xref: /petsc/include/petscviewer.h (revision a5057860b72a2a574eaf7af7a4da4e3775d71143)
184cb2905SBarry Smith /*
2b0a32e0cSBarry Smith      PetscViewers are objects where other objects can be looked at or stored.
384cb2905SBarry Smith */
43c119ea2SBarry Smith 
50a835dfdSSatish Balay #if !defined(__PETSCVIEWER_H)
60a835dfdSSatish Balay #define __PETSCVIEWER_H
7dfbe8321SBarry Smith 
8e9fa29b7SSatish Balay #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
9e9fa29b7SSatish Balay extern "C" {
10e9fa29b7SSatish Balay #endif
112eb8c8abSBarry Smith 
12b9617806SBarry Smith /*S
13b9617806SBarry Smith      PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc)
14b9617806SBarry Smith          other PETSc objects
15b9617806SBarry Smith 
16b9617806SBarry Smith    Level: beginner
17b9617806SBarry Smith 
18b9617806SBarry Smith   Concepts: viewing
19b9617806SBarry Smith 
20b9617806SBarry Smith .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType
21b9617806SBarry Smith S*/
22b0a32e0cSBarry Smith typedef struct _p_PetscViewer* PetscViewer;
233c119ea2SBarry Smith 
24e9fa29b7SSatish Balay #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
25e9fa29b7SSatish Balay }
26e9fa29b7SSatish Balay #endif
27e9fa29b7SSatish Balay 
28d382aafbSBarry Smith #include "petscsys.h"
298fb59f0aSKris Buschelman 
308fb59f0aSKris Buschelman #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
318fb59f0aSKris Buschelman extern "C" {
328fb59f0aSKris Buschelman #endif
338fb59f0aSKris Buschelman 
347087cfbeSBarry Smith extern  PetscClassId PETSC_VIEWER_CLASSID;
358fb59f0aSKris Buschelman 
368fb59f0aSKris Buschelman #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
378fb59f0aSKris Buschelman }
388fb59f0aSKris Buschelman #endif
398fb59f0aSKris Buschelman 
40e9fa29b7SSatish Balay 
413c119ea2SBarry Smith /*
42d382aafbSBarry Smith     petscsys.h must be included AFTER the definition of PetscViewer for ADIC to
433c119ea2SBarry Smith    process correctly.
443c119ea2SBarry Smith */
45e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN
4676bdecfbSBarry Smith /*J
47b9617806SBarry Smith     PetscViewerType - String with the name of a PETSc PETScViewer
48b9617806SBarry Smith 
49b9617806SBarry Smith    Level: beginner
50b9617806SBarry Smith 
51b9617806SBarry Smith .seealso: PetscViewerSetType(), PetscViewer
5276bdecfbSBarry Smith J*/
53a313700dSBarry Smith #define PetscViewerType char*
542692d6eeSBarry Smith #define PETSCVIEWERSOCKET       "socket"
552692d6eeSBarry Smith #define PETSCVIEWERASCII        "ascii"
562692d6eeSBarry Smith #define PETSCVIEWERBINARY       "binary"
572692d6eeSBarry Smith #define PETSCVIEWERSTRING       "string"
582692d6eeSBarry Smith #define PETSCVIEWERDRAW         "draw"
592692d6eeSBarry Smith #define PETSCVIEWERVU           "vu"
602692d6eeSBarry Smith #define PETSCVIEWERMATHEMATICA  "mathematica"
612692d6eeSBarry Smith #define PETSCVIEWERNETCDF       "netcdf"
622692d6eeSBarry Smith #define PETSCVIEWERHDF5         "hdf5"
634061b8bfSJed Brown #define PETSCVIEWERVTK          "vtk"
642692d6eeSBarry Smith #define PETSCVIEWERMATLAB       "matlab"
65b3506946SBarry Smith #define PETSCVIEWERAMS          "ams"
6677ed5343SBarry Smith 
67b0a32e0cSBarry Smith extern PetscFList PetscViewerList;
687087cfbeSBarry Smith extern PetscErrorCode  PetscViewerRegisterAll(const char *);
697087cfbeSBarry Smith extern PetscErrorCode  PetscViewerRegisterDestroy(void);
707087cfbeSBarry Smith extern PetscErrorCode  PetscViewerInitializePackage(const char[]);
717b2a1423SBarry Smith 
727087cfbeSBarry Smith extern PetscErrorCode  PetscViewerRegister(const char*,const char*,const char*,PetscErrorCode (*)(PetscViewer));
7330de9b25SBarry Smith 
7430de9b25SBarry Smith /*MC
7592c97de8SJed Brown    PetscViewerRegisterDynamic - Adds a viewer
7630de9b25SBarry Smith 
7730de9b25SBarry Smith    Synopsis:
781890ba74SBarry Smith    PetscErrorCode PetscViewerRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(PetscViewer))
7930de9b25SBarry Smith 
8030de9b25SBarry Smith    Not Collective
8130de9b25SBarry Smith 
8230de9b25SBarry Smith    Input Parameters:
8392c97de8SJed Brown +  name_solver - name of a new user-defined viewer
8492c97de8SJed Brown .  path - path (either absolute or relative) the library containing this viewer
8530de9b25SBarry Smith .  name_create - name of routine to create method context
8630de9b25SBarry Smith -  routine_create - routine to create method context
8730de9b25SBarry Smith 
8830de9b25SBarry Smith    Level: developer
8930de9b25SBarry Smith 
9030de9b25SBarry Smith    Notes:
9192c97de8SJed Brown    PetscViewerRegisterDynamic() may be called multiple times to add several user-defined viewers.
9230de9b25SBarry Smith 
9330de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (routine_create)
9430de9b25SBarry Smith    is ignored.
9530de9b25SBarry Smith 
9630de9b25SBarry Smith    Sample usage:
9730de9b25SBarry Smith .vb
9830de9b25SBarry Smith    PetscViewerRegisterDynamic("my_viewer_type",/home/username/my_lib/lib/libO/solaris/mylib.a,
9930de9b25SBarry Smith                "MyViewerCreate",MyViewerCreate);
10030de9b25SBarry Smith .ve
10130de9b25SBarry Smith 
10230de9b25SBarry Smith    Then, your solver can be chosen with the procedural interface via
10392c97de8SJed Brown $     PetscViewerSetType(viewer,"my_viewer_type")
10430de9b25SBarry Smith    or at runtime via the option
10530de9b25SBarry Smith $     -viewer_type my_viewer_type
10630de9b25SBarry Smith 
10730de9b25SBarry Smith   Concepts: registering^Viewers
10830de9b25SBarry Smith 
10930de9b25SBarry Smith .seealso: PetscViewerRegisterAll(), PetscViewerRegisterDestroy()
11030de9b25SBarry Smith M*/
111aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
112b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0)
1137b2a1423SBarry Smith #else
114b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d)
1157b2a1423SBarry Smith #endif
11630de9b25SBarry Smith 
1177087cfbeSBarry Smith extern PetscErrorCode  PetscViewerCreate(MPI_Comm,PetscViewer*);
1187087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSetFromOptions(PetscViewer);
11988c29154SBarry Smith extern PetscErrorCode  PetscViewerASCIIOpenWithFILE(MPI_Comm,FILE*,PetscViewer*);
1207b2a1423SBarry Smith 
1217087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*);
12288c29154SBarry Smith extern PetscErrorCode  PetscViewerASCIISetFILE(PetscViewer,FILE*);
1237087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
1247087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryGetFlowControl(PetscViewer,PetscInt*);
1257087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinarySetFlowControl(PetscViewer,PetscInt);
1267087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinarySetMPIIO(PetscViewer);
1277087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryGetMPIIO(PetscViewer,PetscBool *);
1280fc9d207SBarry Smith #if defined(PETSC_HAVE_MPIIO)
1297087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryGetMPIIODescriptor(PetscViewer,MPI_File*);
1307087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryGetMPIIOOffset(PetscViewer,MPI_Offset*);
1317087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryAddMPIIOOffset(PetscViewer,MPI_Offset);
132951e3c8eSBarry Smith #endif
13339802e9eSBarry Smith 
1347087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*);
1357087cfbeSBarry Smith extern PetscErrorCode  PetscViewerStringOpen(MPI_Comm,char[],PetscInt,PetscViewer*);
1367087cfbeSBarry Smith extern PetscErrorCode  PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*);
1377087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *);
1387087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *);
1397087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMatlabOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
1404b0e389bSBarry Smith 
1417087cfbeSBarry Smith extern PetscErrorCode  PetscViewerGetType(PetscViewer,const PetscViewerType*);
1427087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSetType(PetscViewer,const PetscViewerType);
143fcfd50ebSBarry Smith extern PetscErrorCode  PetscViewerDestroy(PetscViewer*);
1447087cfbeSBarry Smith extern PetscErrorCode  PetscViewerGetSingleton(PetscViewer,PetscViewer*);
1457087cfbeSBarry Smith extern PetscErrorCode  PetscViewerRestoreSingleton(PetscViewer,PetscViewer*);
1467087cfbeSBarry Smith extern PetscErrorCode  PetscViewerGetSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
1477087cfbeSBarry Smith extern PetscErrorCode  PetscViewerRestoreSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
148ae39576cSLois Curfman McInnes 
1497087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSetUp(PetscViewer);
1507087cfbeSBarry Smith extern PetscErrorCode  PetscViewerView(PetscViewer,PetscViewer);
151f69a0ea3SMatthew Knepley 
1527087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSetOptionsPrefix(PetscViewer,const char[]);
1537087cfbeSBarry Smith extern PetscErrorCode  PetscViewerAppendOptionsPrefix(PetscViewer,const char[]);
1547087cfbeSBarry Smith extern PetscErrorCode  PetscViewerGetOptionsPrefix(PetscViewer,const char*[]);
155090de74eSSatish Balay 
156b9617806SBarry Smith /*E
157b9617806SBarry Smith     PetscViewerFormat - Way a viewer presents the object
158b9617806SBarry Smith 
159b9617806SBarry Smith    Level: beginner
160b9617806SBarry Smith 
161cfaaf4edSHong Zhang    The values below are also listed in finclude/petscviewer.h. If another values is added below it
162cfaaf4edSHong Zhang    must also be added there.
163cfaaf4edSHong Zhang 
164b9617806SBarry Smith .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat()
165b9617806SBarry Smith E*/
166fb9695e5SSatish Balay typedef enum {
167117016b1SBarry Smith   PETSC_VIEWER_DEFAULT,
168f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_MATLAB,
1694ebda54eSMatthew Knepley   PETSC_VIEWER_ASCII_MATHEMATICA,
170f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_IMPL,
171f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INFO,
172456192e2SBarry Smith   PETSC_VIEWER_ASCII_INFO_DETAIL,
173f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_COMMON,
174f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_SYMMODU,
175f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INDEX,
176f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_DENSE,
1773c215bfdSMatthew Knepley   PETSC_VIEWER_ASCII_MATRIXMARKET,
178a505fa5bSMatthew Knepley   PETSC_VIEWER_ASCII_VTK,
179b85befe5SMatthew Knepley   PETSC_VIEWER_ASCII_VTK_CELL,
180b6d733afSMatthew Knepley   PETSC_VIEWER_ASCII_VTK_COORDS,
181493617b5SMatthew Knepley   PETSC_VIEWER_ASCII_PCICE,
182cfaaf4edSHong Zhang   PETSC_VIEWER_ASCII_PYTHON,
183cfaaf4edSHong Zhang   PETSC_VIEWER_ASCII_FACTOR_INFO,
18467ad5babSMatthew G Knepley   PETSC_VIEWER_ASCII_LATEX,
185f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_BASIC,
186f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_LG,
187f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_CONTOUR,
188f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_PORTS,
1894061b8bfSJed Brown   PETSC_VIEWER_VTK_VTS,
190f3ef73ceSBarry Smith   PETSC_VIEWER_NATIVE,
191cfaaf4edSHong Zhang   PETSC_VIEWER_NOFORMAT
192cfaaf4edSHong Zhang   } PetscViewerFormat;
1934061b8bfSJed Brown extern const char *const PetscViewerFormats[];
194090de74eSSatish Balay 
1957087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSetFormat(PetscViewer,PetscViewerFormat);
1967087cfbeSBarry Smith extern PetscErrorCode  PetscViewerPushFormat(PetscViewer,PetscViewerFormat);
1977087cfbeSBarry Smith extern PetscErrorCode  PetscViewerPopFormat(PetscViewer);
1987087cfbeSBarry Smith extern PetscErrorCode  PetscViewerGetFormat(PetscViewer,PetscViewerFormat*);
1997087cfbeSBarry Smith extern PetscErrorCode  PetscViewerFlush(PetscViewer);
2004b0e389bSBarry Smith 
20177ed5343SBarry Smith /*
20277ed5343SBarry Smith    Operations explicit to a particular class of viewers
20377ed5343SBarry Smith */
204ed5c6e3eSMatthew Knepley 
2057087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIIGetPointer(PetscViewer,FILE**);
2067087cfbeSBarry Smith extern PetscErrorCode  PetscViewerFileGetMode(PetscViewer,PetscFileMode*);
2077087cfbeSBarry Smith extern PetscErrorCode  PetscViewerFileSetMode(PetscViewer,PetscFileMode);
2087087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIIPrintf(PetscViewer,const char[],...);
2097087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...);
2107b23a99aSBarry Smith extern PetscErrorCode  PetscViewerASCIISynchronizedAllow(PetscViewer,PetscBool);
2117087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIIPushTab(PetscViewer);
2127087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIIPopTab(PetscViewer);
2137087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIIUseTabs(PetscViewer,PetscBool );
2147087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIISetTab(PetscViewer,PetscInt);
21501bc414fSDmitry Karpeev extern PetscErrorCode  PetscViewerASCIIGetTab(PetscViewer,PetscInt*);
21602f152b6SBarry Smith extern PetscErrorCode  PetscViewerASCIIAddTab(PetscViewer,PetscInt);
21702f152b6SBarry Smith extern PetscErrorCode  PetscViewerASCIISubtractTab(PetscViewer,PetscInt);
2187087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryGetDescriptor(PetscViewer,int*);
2197087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **);
2207087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryRead(PetscViewer,void*,PetscInt,PetscDataType);
2217087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryWrite(PetscViewer,void*,PetscInt,PetscDataType,PetscBool );
2227087cfbeSBarry Smith extern PetscErrorCode  PetscViewerStringSPrintf(PetscViewer,const char[],...);
2237087cfbeSBarry Smith extern PetscErrorCode  PetscViewerStringSetString(PetscViewer,char[],PetscInt);
2247087cfbeSBarry Smith extern PetscErrorCode  PetscViewerDrawClear(PetscViewer);
2256083293cSBarry Smith extern PetscErrorCode  PetscViewerDrawSetHold(PetscViewer,PetscBool);
2266083293cSBarry Smith extern PetscErrorCode  PetscViewerDrawGetHold(PetscViewer,PetscBool*);
2276083293cSBarry Smith extern PetscErrorCode  PetscViewerDrawSetPause(PetscViewer,PetscReal);
2286083293cSBarry Smith extern PetscErrorCode  PetscViewerDrawGetPause(PetscViewer,PetscReal*);
2297087cfbeSBarry Smith extern PetscErrorCode  PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int);
230717e37fcSBarry Smith extern PetscErrorCode  PetscViewerDrawResize(PetscViewer,int,int);
23167dd0837SBarry Smith extern PetscErrorCode  PetscViewerDrawSetBounds(PetscViewer,PetscInt,const PetscReal*);
23267dd0837SBarry Smith extern PetscErrorCode  PetscViewerDrawGetBounds(PetscViewer,PetscInt*,const PetscReal**);
2337087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSocketSetConnection(PetscViewer,const char[],int);
2347087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinarySkipInfo(PetscViewer);
2357087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinarySetSkipOptions(PetscViewer,PetscBool );
2367087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryGetSkipOptions(PetscViewer,PetscBool *);
237067f2660SJed Brown extern PetscErrorCode  PetscViewerBinarySetSkipHeader(PetscViewer,PetscBool);
238067f2660SJed Brown extern PetscErrorCode  PetscViewerBinaryGetSkipHeader(PetscViewer,PetscBool*);
2397087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryReadStringArray(PetscViewer,char***);
2407087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryWriteStringArray(PetscViewer,char**);
241c655490fSBarry Smith 
2427087cfbeSBarry Smith extern PetscErrorCode  PetscViewerFileSetName(PetscViewer,const char[]);
2431daa0841SJed Brown extern PetscErrorCode  PetscViewerFileGetName(PetscViewer,const char**);
24477ed5343SBarry Smith 
2457087cfbeSBarry Smith extern PetscErrorCode  PetscPLAPACKInitializePackage(MPI_Comm com);
2467087cfbeSBarry Smith extern PetscErrorCode  PetscPLAPACKFinalizePackage(void);
24744c6da4fSMatthew Knepley 
2487087cfbeSBarry Smith extern PetscErrorCode  PetscViewerVUGetPointer(PetscViewer, FILE**);
2497087cfbeSBarry Smith extern PetscErrorCode  PetscViewerVUSetVecSeen(PetscViewer, PetscBool );
2507087cfbeSBarry Smith extern PetscErrorCode  PetscViewerVUGetVecSeen(PetscViewer, PetscBool  *);
2517087cfbeSBarry Smith extern PetscErrorCode  PetscViewerVUPrintDeferred(PetscViewer, const char [], ...);
2527087cfbeSBarry Smith extern PetscErrorCode  PetscViewerVUFlushDeferred(PetscViewer);
25355dcf840SMatthew Knepley 
2547087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMathematicaInitializePackage(const char[]);
2557087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMathematicaFinalizePackage(void);
2567087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMathematicaGetName(PetscViewer, const char **);
2577087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMathematicaSetName(PetscViewer, const char []);
2587087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMathematicaClearName(PetscViewer);
2597087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMathematicaSkipPackets(PetscViewer, int);
2604ebda54eSMatthew Knepley 
2617087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSiloGetName(PetscViewer, char **);
2627087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSiloSetName(PetscViewer, const char []);
2637087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSiloClearName(PetscViewer);
2647087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSiloGetMeshName(PetscViewer, char **);
2657087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSiloSetMeshName(PetscViewer, const char []);
2667087cfbeSBarry Smith extern PetscErrorCode  PetscViewerSiloClearMeshName(PetscViewer);
2674ebda54eSMatthew Knepley 
2687087cfbeSBarry Smith extern PetscErrorCode  PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
2697087cfbeSBarry Smith extern PetscErrorCode  PetscViewerNetcdfGetID(PetscViewer, int *);
270e3eb5169SDinesh Kaushik 
2717087cfbeSBarry Smith extern PetscErrorCode  PetscViewerHDF5WriteSDS(PetscViewer,float *,int,int *,int);
27200ccbe27SDinesh Kaushik 
2737087cfbeSBarry Smith extern PetscErrorCode  PetscViewerHDF5Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
2747087cfbeSBarry Smith extern PetscErrorCode  PetscViewerHDF5PushGroup(PetscViewer,const char *);
2757087cfbeSBarry Smith extern PetscErrorCode  PetscViewerHDF5PopGroup(PetscViewer);
2767087cfbeSBarry Smith extern PetscErrorCode  PetscViewerHDF5GetGroup(PetscViewer, const char **);
27708e6896eSMatthew G Knepley extern PetscErrorCode  PetscViewerHDF5IncrementTimestep(PetscViewer);
2787087cfbeSBarry Smith extern PetscErrorCode  PetscViewerHDF5SetTimestep(PetscViewer,PetscInt);
2797087cfbeSBarry Smith extern PetscErrorCode  PetscViewerHDF5GetTimestep(PetscViewer,PetscInt*);
2808e72c77eSMatthew Knepley #ifdef PETSC_HAVE_HDF5
2818e72c77eSMatthew Knepley #include <hdf5.h>
2827087cfbeSBarry Smith extern PetscErrorCode  PetscViewerHDF5GetFileId(PetscViewer,hid_t*);
2837087cfbeSBarry Smith extern PetscErrorCode  PetscViewerHDF5OpenGroup(PetscViewer, hid_t *, hid_t *);
2848e72c77eSMatthew Knepley #endif
2858e72c77eSMatthew Knepley 
286893c9c94SMatthew G Knepley typedef enum {PETSC_VTK_POINT_FIELD, PETSC_VTK_POINT_VECTOR_FIELD, PETSC_VTK_CELL_FIELD, PETSC_VTK_CELL_VECTOR_FIELD} PetscViewerVTKFieldType;
2874061b8bfSJed Brown typedef PetscErrorCode (*PetscViewerVTKWriteFunction)(PetscObject,PetscViewer);
28862b69a3fSMatthew G Knepley extern PetscErrorCode PetscViewerVTKAddField(PetscViewer,PetscObject,PetscViewerVTKWriteFunction,PetscViewerVTKFieldType,PetscObject);
2891f8fb9d9SJed Brown extern PetscErrorCode PetscViewerVTKOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
2904061b8bfSJed Brown 
29177ed5343SBarry Smith /*
29277ed5343SBarry Smith      These are all the default viewers that do not have
29377ed5343SBarry Smith    to be explicitly opened
29477ed5343SBarry Smith */
2957087cfbeSBarry Smith extern PetscViewer  PETSC_VIEWER_STDOUT_(MPI_Comm);
2967087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*);
2977087cfbeSBarry Smith extern PetscViewer  PETSC_VIEWER_STDERR_(MPI_Comm);
2987087cfbeSBarry Smith extern PetscErrorCode  PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*);
2997087cfbeSBarry Smith extern PetscViewer  PETSC_VIEWER_DRAW_(MPI_Comm);
3007087cfbeSBarry Smith extern PetscViewer  PETSC_VIEWER_SOCKET_(MPI_Comm);
3017087cfbeSBarry Smith extern PetscViewer  PETSC_VIEWER_BINARY_(MPI_Comm);
3027087cfbeSBarry Smith extern PetscViewer  PETSC_VIEWER_MATLAB_(MPI_Comm);
30309573ac7SBarry Smith extern PetscViewer PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE;
3045311e20fSBarry Smith 
305b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_SELF  PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
306b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)
30730de9b25SBarry Smith 
30830de9b25SBarry Smith /*MC
30930de9b25SBarry Smith   PETSC_VIEWER_STDOUT_WORLD  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
31030de9b25SBarry Smith 
31130de9b25SBarry Smith   Level: beginner
31230de9b25SBarry Smith M*/
31330de9b25SBarry Smith #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
31430de9b25SBarry Smith 
31530de9b25SBarry Smith /*MC
31630de9b25SBarry Smith   PETSC_VIEWER_STDOUT_SELF  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
31730de9b25SBarry Smith 
31830de9b25SBarry Smith   Level: beginner
31930de9b25SBarry Smith M*/
32030de9b25SBarry Smith #define PETSC_VIEWER_STDOUT_SELF  PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
32130de9b25SBarry Smith 
32230de9b25SBarry Smith /*MC
32330de9b25SBarry Smith   PETSC_VIEWER_DRAW_WORLD  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
32430de9b25SBarry Smith 
32530de9b25SBarry Smith   Level: intermediate
32630de9b25SBarry Smith M*/
327b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_WORLD   PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
32830de9b25SBarry Smith 
32930de9b25SBarry Smith /*MC
33030de9b25SBarry Smith   PETSC_VIEWER_DRAW_SELF  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
33130de9b25SBarry Smith 
33230de9b25SBarry Smith   Level: intermediate
33330de9b25SBarry Smith M*/
33430de9b25SBarry Smith #define PETSC_VIEWER_DRAW_SELF    PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
33530de9b25SBarry Smith 
33630de9b25SBarry Smith /*MC
33730de9b25SBarry Smith   PETSC_VIEWER_SOCKET_WORLD  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
33830de9b25SBarry Smith 
33930de9b25SBarry Smith   Level: intermediate
34030de9b25SBarry Smith M*/
341b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
34230de9b25SBarry Smith 
34330de9b25SBarry Smith /*MC
34430de9b25SBarry Smith   PETSC_VIEWER_SOCKET_SELF  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
34530de9b25SBarry Smith 
34630de9b25SBarry Smith   Level: intermediate
34730de9b25SBarry Smith M*/
348b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_SELF  PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
34930de9b25SBarry Smith 
35030de9b25SBarry Smith /*MC
35130de9b25SBarry Smith   PETSC_VIEWER_BINARY_WORLD  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
35230de9b25SBarry Smith 
35330de9b25SBarry Smith   Level: intermediate
35430de9b25SBarry Smith M*/
355b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
35630de9b25SBarry Smith 
35730de9b25SBarry Smith /*MC
35830de9b25SBarry Smith   PETSC_VIEWER_BINARY_SELF  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
35930de9b25SBarry Smith 
36030de9b25SBarry Smith   Level: intermediate
36130de9b25SBarry Smith M*/
362b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_SELF  PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
36330de9b25SBarry Smith 
364cbb32127SBarry Smith /*MC
365cbb32127SBarry Smith   PETSC_VIEWER_MATLAB_WORLD  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
366cbb32127SBarry Smith 
367cbb32127SBarry Smith   Level: intermediate
368cbb32127SBarry Smith M*/
369cbb32127SBarry Smith #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
370cbb32127SBarry Smith 
371cbb32127SBarry Smith /*MC
372cbb32127SBarry Smith   PETSC_VIEWER_MATLAB_SELF  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
373cbb32127SBarry Smith 
374cbb32127SBarry Smith   Level: intermediate
375cbb32127SBarry Smith M*/
376cbb32127SBarry Smith #define PETSC_VIEWER_MATLAB_SELF  PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
377cbb32127SBarry Smith 
3787eb62a3eSMatthew Knepley #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE)
37965ef3172SBarry Smith 
380e03d165dSBarry Smith #define PetscViewerFlowControlStart(viewer,mcnt,cnt)  (PetscViewerBinaryGetFlowControl(viewer,mcnt) || PetscViewerBinaryGetFlowControl(viewer,cnt))
38185ebf7a4SBarry Smith #define PetscViewerFlowControlStepMaster(viewer,i,mcnt,cnt) ((i >= mcnt) ?  (mcnt += cnt,MPI_Bcast(&mcnt,1,MPIU_INT,0,((PetscObject)viewer)->comm)) : 0)
382e03d165dSBarry Smith #define PetscViewerFlowControlEndMaster(viewer,mcnt) (mcnt = 0,MPI_Bcast(&mcnt,1,MPIU_INT,0,((PetscObject)viewer)->comm))
383fca9dd48SBarry Smith #define PetscViewerFlowControlStepWorker(viewer,rank,mcnt) 0; while (1) { PetscErrorCode _ierr; \
384fca9dd48SBarry Smith     if (rank < mcnt) break;				\
385e03d165dSBarry Smith   _ierr = MPI_Bcast(&mcnt,1,MPIU_INT,0,((PetscObject)viewer)->comm);CHKERRQ(_ierr);\
386e03d165dSBarry Smith   }
387fca9dd48SBarry Smith #define PetscViewerFlowControlEndWorker(viewer,mcnt) 0; while (1) { PetscErrorCode _ierr; \
388fca9dd48SBarry Smith   _ierr = MPI_Bcast(&mcnt,1,MPIU_INT,0,((PetscObject)viewer)->comm);CHKERRQ(_ierr);\
389fca9dd48SBarry Smith     if (mcnt == 0) break;				\
390fca9dd48SBarry Smith   }
391e03d165dSBarry Smith 
39277ed5343SBarry Smith /*
393*a5057860SBarry Smith    PetscViewer writes to MATLAB .mat file
394cbb32127SBarry Smith */
3957087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMatlabPutArray(PetscViewer,int,int,const PetscScalar*,const char*);
3967087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,const char*);
3977087cfbeSBarry Smith extern PetscErrorCode  PetscViewerMatlabPutVariable(PetscViewer,const char*,void*);
398cbb32127SBarry Smith 
399b9617806SBarry Smith /*S
4001890ba74SBarry Smith      PetscViewers - Abstract collection of PetscViewers. It is just an expandable array of viewers.
401b9617806SBarry Smith 
402b9617806SBarry Smith    Level: intermediate
403b9617806SBarry Smith 
404b9617806SBarry Smith   Concepts: viewing
405b9617806SBarry Smith 
406b9617806SBarry Smith .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
407b9617806SBarry Smith            PetscViewersGetViewer()
408b9617806SBarry Smith S*/
40995fbd943SSatish Balay typedef struct _n_PetscViewers* PetscViewers;
4107087cfbeSBarry Smith extern PetscErrorCode  PetscViewersCreate(MPI_Comm,PetscViewers*);
411fcfd50ebSBarry Smith extern PetscErrorCode  PetscViewersDestroy(PetscViewers*);
4127087cfbeSBarry Smith extern PetscErrorCode  PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*);
413d132466eSBarry Smith 
414b3506946SBarry Smith #if defined(PETSC_HAVE_AMS)
415b3506946SBarry Smith #include <ams.h>
41609573ac7SBarry Smith extern PetscErrorCode PetscViewerAMSSetCommName(PetscViewer,const char[]);
41709573ac7SBarry Smith extern PetscErrorCode PetscViewerAMSGetAMSComm(PetscViewer,AMS_Comm *);
41809573ac7SBarry Smith extern PetscErrorCode PetscViewerAMSOpen(MPI_Comm,const char[],PetscViewer*);
41909573ac7SBarry Smith extern PetscErrorCode PetscViewerAMSLock(PetscViewer);
42009573ac7SBarry Smith extern PetscViewer    PETSC_VIEWER_AMS_(MPI_Comm);
42109573ac7SBarry Smith extern PetscErrorCode PETSC_VIEWER_AMS_Destroy(MPI_Comm);
422b3506946SBarry Smith #define PETSC_VIEWER_AMS_WORLD PETSC_VIEWER_AMS_(PETSC_COMM_WORLD)
423b3506946SBarry Smith #endif
424b3506946SBarry Smith 
425e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
426cb5b572fSBarry Smith #endif
427