xref: /petsc/include/petscviewer.h (revision d70abbfa351bf2129349cbf5335527b71949552f)
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 
86420c192SJed Brown #include <petscsys.h>
96420c192SJed Brown 
10e9fa29b7SSatish Balay #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
11e9fa29b7SSatish Balay extern "C" {
12e9fa29b7SSatish Balay #endif
132eb8c8abSBarry Smith 
14b9617806SBarry Smith /*S
15b9617806SBarry Smith      PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc)
16b9617806SBarry Smith          other PETSc objects
17b9617806SBarry Smith 
18b9617806SBarry Smith    Level: beginner
19b9617806SBarry Smith 
20b9617806SBarry Smith   Concepts: viewing
21b9617806SBarry Smith 
22b9617806SBarry Smith .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType
23b9617806SBarry Smith S*/
24b0a32e0cSBarry Smith typedef struct _p_PetscViewer* PetscViewer;
253c119ea2SBarry Smith 
26e9fa29b7SSatish Balay #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
27e9fa29b7SSatish Balay }
28e9fa29b7SSatish Balay #endif
29e9fa29b7SSatish Balay 
30014dd563SJed Brown PETSC_EXTERN PetscClassId PETSC_VIEWER_CLASSID;
31e9fa29b7SSatish Balay 
3276bdecfbSBarry Smith /*J
33b9617806SBarry Smith     PetscViewerType - String with the name of a PETSc PETScViewer
34b9617806SBarry Smith 
35b9617806SBarry Smith    Level: beginner
36b9617806SBarry Smith 
37b9617806SBarry Smith .seealso: PetscViewerSetType(), PetscViewer
3876bdecfbSBarry Smith J*/
3919fd82e9SBarry Smith typedef const char* PetscViewerType;
402692d6eeSBarry Smith #define PETSCVIEWERSOCKET       "socket"
412692d6eeSBarry Smith #define PETSCVIEWERASCII        "ascii"
422692d6eeSBarry Smith #define PETSCVIEWERBINARY       "binary"
432692d6eeSBarry Smith #define PETSCVIEWERSTRING       "string"
442692d6eeSBarry Smith #define PETSCVIEWERDRAW         "draw"
452692d6eeSBarry Smith #define PETSCVIEWERVU           "vu"
462692d6eeSBarry Smith #define PETSCVIEWERMATHEMATICA  "mathematica"
472692d6eeSBarry Smith #define PETSCVIEWERNETCDF       "netcdf"
482692d6eeSBarry Smith #define PETSCVIEWERHDF5         "hdf5"
494061b8bfSJed Brown #define PETSCVIEWERVTK          "vtk"
502692d6eeSBarry Smith #define PETSCVIEWERMATLAB       "matlab"
51b3506946SBarry Smith #define PETSCVIEWERAMS          "ams"
5277ed5343SBarry Smith 
53140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList PetscViewerList;
54014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRegisterAll(const char *);
55014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRegisterDestroy(void);
56014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerInitializePackage(const char[]);
577b2a1423SBarry Smith 
58014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRegister(const char*,const char*,const char*,PetscErrorCode (*)(PetscViewer));
5930de9b25SBarry Smith 
6030de9b25SBarry Smith /*MC
6192c97de8SJed Brown    PetscViewerRegisterDynamic - Adds a viewer
6230de9b25SBarry Smith 
63f2ba6396SBarry Smith    Synopsis
64f2ba6396SBarry Smith    #include "petscviewer.h"
651890ba74SBarry Smith    PetscErrorCode PetscViewerRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(PetscViewer))
6630de9b25SBarry Smith 
6730de9b25SBarry Smith    Not Collective
6830de9b25SBarry Smith 
6930de9b25SBarry Smith    Input Parameters:
7092c97de8SJed Brown +  name_solver - name of a new user-defined viewer
7192c97de8SJed Brown .  path - path (either absolute or relative) the library containing this viewer
7230de9b25SBarry Smith .  name_create - name of routine to create method context
7330de9b25SBarry Smith -  routine_create - routine to create method context
7430de9b25SBarry Smith 
7530de9b25SBarry Smith    Level: developer
7630de9b25SBarry Smith 
7730de9b25SBarry Smith    Notes:
7892c97de8SJed Brown    PetscViewerRegisterDynamic() may be called multiple times to add several user-defined viewers.
7930de9b25SBarry Smith 
8030de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (routine_create)
8130de9b25SBarry Smith    is ignored.
8230de9b25SBarry Smith 
8330de9b25SBarry Smith    Sample usage:
8430de9b25SBarry Smith .vb
8530de9b25SBarry Smith    PetscViewerRegisterDynamic("my_viewer_type",/home/username/my_lib/lib/libO/solaris/mylib.a,
8630de9b25SBarry Smith                "MyViewerCreate",MyViewerCreate);
8730de9b25SBarry Smith .ve
8830de9b25SBarry Smith 
8930de9b25SBarry Smith    Then, your solver can be chosen with the procedural interface via
9092c97de8SJed Brown $     PetscViewerSetType(viewer,"my_viewer_type")
9130de9b25SBarry Smith    or at runtime via the option
9230de9b25SBarry Smith $     -viewer_type my_viewer_type
9330de9b25SBarry Smith 
9430de9b25SBarry Smith   Concepts: registering^Viewers
9530de9b25SBarry Smith 
9630de9b25SBarry Smith .seealso: PetscViewerRegisterAll(), PetscViewerRegisterDestroy()
9730de9b25SBarry Smith M*/
98aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
99b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0)
1007b2a1423SBarry Smith #else
101b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d)
1027b2a1423SBarry Smith #endif
10330de9b25SBarry Smith 
104014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerCreate(MPI_Comm,PetscViewer*);
105014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetFromOptions(PetscViewer);
106014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpenWithFILE(MPI_Comm,FILE*,PetscViewer*);
1077b2a1423SBarry Smith 
108014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*);
109014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISetFILE(PetscViewer,FILE*);
110014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
111014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetFlowControl(PetscViewer,PetscInt*);
112014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetFlowControl(PetscViewer,PetscInt);
113014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetMPIIO(PetscViewer);
114014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIO(PetscViewer,PetscBool *);
1150fc9d207SBarry Smith #if defined(PETSC_HAVE_MPIIO)
116014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIODescriptor(PetscViewer,MPI_File*);
117014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIOOffset(PetscViewer,MPI_Offset*);
118014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryAddMPIIOOffset(PetscViewer,MPI_Offset);
119951e3c8eSBarry Smith #endif
12039802e9eSBarry Smith 
121014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*);
122014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerStringOpen(MPI_Comm,char[],PetscInt,PetscViewer*);
123014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*);
124014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *);
125014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *);
126014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
1274b0e389bSBarry Smith 
12819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerGetType(PetscViewer,PetscViewerType*);
12919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerSetType(PetscViewer,PetscViewerType);
130014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDestroy(PetscViewer*);
131014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetSingleton(PetscViewer,PetscViewer*);
132014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRestoreSingleton(PetscViewer,PetscViewer*);
133014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
134014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRestoreSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
135ae39576cSLois Curfman McInnes 
136014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetUp(PetscViewer);
137014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerView(PetscViewer,PetscViewer);
138f69a0ea3SMatthew Knepley 
139014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer,const char[]);
140014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer,const char[]);
141014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer,const char*[]);
142090de74eSSatish Balay 
143b9617806SBarry Smith /*E
144b9617806SBarry Smith     PetscViewerFormat - Way a viewer presents the object
145b9617806SBarry Smith 
146b9617806SBarry Smith    Level: beginner
147b9617806SBarry Smith 
148cfaaf4edSHong Zhang    The values below are also listed in finclude/petscviewer.h. If another values is added below it
149cfaaf4edSHong Zhang    must also be added there.
150cfaaf4edSHong Zhang 
151b9617806SBarry Smith .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat()
152b9617806SBarry Smith E*/
153fb9695e5SSatish Balay typedef enum {
154117016b1SBarry Smith   PETSC_VIEWER_DEFAULT,
155f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_MATLAB,
1564ebda54eSMatthew Knepley   PETSC_VIEWER_ASCII_MATHEMATICA,
157f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_IMPL,
158f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INFO,
159456192e2SBarry Smith   PETSC_VIEWER_ASCII_INFO_DETAIL,
160f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_COMMON,
161f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_SYMMODU,
162f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INDEX,
163f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_DENSE,
1643c215bfdSMatthew Knepley   PETSC_VIEWER_ASCII_MATRIXMARKET,
165a505fa5bSMatthew Knepley   PETSC_VIEWER_ASCII_VTK,
166b85befe5SMatthew Knepley   PETSC_VIEWER_ASCII_VTK_CELL,
167b6d733afSMatthew Knepley   PETSC_VIEWER_ASCII_VTK_COORDS,
168493617b5SMatthew Knepley   PETSC_VIEWER_ASCII_PCICE,
169cfaaf4edSHong Zhang   PETSC_VIEWER_ASCII_PYTHON,
170cfaaf4edSHong Zhang   PETSC_VIEWER_ASCII_FACTOR_INFO,
17167ad5babSMatthew G Knepley   PETSC_VIEWER_ASCII_LATEX,
172f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_BASIC,
173f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_LG,
174f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_CONTOUR,
175f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_PORTS,
1764061b8bfSJed Brown   PETSC_VIEWER_VTK_VTS,
177b263465dSJed Brown   PETSC_VIEWER_VTK_VTU,
178a261c58fSBarry Smith   PETSC_VIEWER_BINARY_MATLAB,
179f3ef73ceSBarry Smith   PETSC_VIEWER_NATIVE,
180cfaaf4edSHong Zhang   PETSC_VIEWER_NOFORMAT
181cfaaf4edSHong Zhang   } PetscViewerFormat;
182014dd563SJed Brown PETSC_EXTERN const char *const PetscViewerFormats[];
183090de74eSSatish Balay 
184014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetFormat(PetscViewer,PetscViewerFormat);
185014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerPushFormat(PetscViewer,PetscViewerFormat);
186014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerPopFormat(PetscViewer);
187014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetFormat(PetscViewer,PetscViewerFormat*);
188014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFlush(PetscViewer);
1894b0e389bSBarry Smith 
190cffb1e40SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetViewer(MPI_Comm,const char[],const char[],PetscViewer*,PetscViewerFormat*,PetscBool*);
191cffb1e40SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsViewer(const char[],const char[],const char[],PetscViewer*,PetscViewerFormat *,PetscBool *);
1922bf49c77SBarry Smith 
19377ed5343SBarry Smith /*
19477ed5343SBarry Smith    Operations explicit to a particular class of viewers
19577ed5343SBarry Smith */
196ed5c6e3eSMatthew Knepley 
197014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetPointer(PetscViewer,FILE**);
198014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileGetMode(PetscViewer,PetscFileMode*);
199014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileSetMode(PetscViewer,PetscFileMode);
200014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIPrintf(PetscViewer,const char[],...);
201014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...);
202014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedAllow(PetscViewer,PetscBool);
203014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIPushTab(PetscViewer);
204014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIPopTab(PetscViewer);
205014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIUseTabs(PetscViewer,PetscBool );
206014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISetTab(PetscViewer,PetscInt);
207014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetTab(PetscViewer,PetscInt*);
208014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIAddTab(PetscViewer,PetscInt);
209014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISubtractTab(PetscViewer,PetscInt);
210014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetDescriptor(PetscViewer,int*);
211014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **);
212014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryRead(PetscViewer,void*,PetscInt,PetscDataType);
213014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryWrite(PetscViewer,void*,PetscInt,PetscDataType,PetscBool );
214014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerStringSPrintf(PetscViewer,const char[],...);
215014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerStringSetString(PetscViewer,char[],PetscInt);
216014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawClear(PetscViewer);
217014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetHold(PetscViewer,PetscBool);
218014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawGetHold(PetscViewer,PetscBool*);
219014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetPause(PetscViewer,PetscReal);
220014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawGetPause(PetscViewer,PetscReal*);
221014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int);
222014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawResize(PetscViewer,int,int);
223014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetBounds(PetscViewer,PetscInt,const PetscReal*);
224014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawGetBounds(PetscViewer,PetscInt*,const PetscReal**);
225014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSocketSetConnection(PetscViewer,const char[],int);
226014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySkipInfo(PetscViewer);
227014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipOptions(PetscViewer,PetscBool );
228014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipOptions(PetscViewer,PetscBool *);
229014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipHeader(PetscViewer,PetscBool);
230014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipHeader(PetscViewer,PetscBool*);
231014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryReadStringArray(PetscViewer,char***);
232014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryWriteStringArray(PetscViewer,char**);
233c655490fSBarry Smith 
234014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileSetName(PetscViewer,const char[]);
235014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileGetName(PetscViewer,const char**);
23677ed5343SBarry Smith 
237014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUGetPointer(PetscViewer, FILE**);
238014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUSetVecSeen(PetscViewer, PetscBool );
239014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUGetVecSeen(PetscViewer, PetscBool  *);
240014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUPrintDeferred(PetscViewer, const char [], ...);
241014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUFlushDeferred(PetscViewer);
24255dcf840SMatthew Knepley 
243014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaInitializePackage(const char[]);
244014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaFinalizePackage(void);
245014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetName(PetscViewer, const char **);
246014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSetName(PetscViewer, const char []);
247014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaClearName(PetscViewer);
248014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSkipPackets(PetscViewer, int);
2494ebda54eSMatthew Knepley 
250014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloGetName(PetscViewer, char **);
251014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloSetName(PetscViewer, const char []);
252014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloClearName(PetscViewer);
253014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloGetMeshName(PetscViewer, char **);
254014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloSetMeshName(PetscViewer, const char []);
255014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloClearMeshName(PetscViewer);
2564ebda54eSMatthew Knepley 
257014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
258014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerNetcdfGetID(PetscViewer, int *);
259e3eb5169SDinesh Kaushik 
260893c9c94SMatthew G Knepley typedef enum {PETSC_VTK_POINT_FIELD, PETSC_VTK_POINT_VECTOR_FIELD, PETSC_VTK_CELL_FIELD, PETSC_VTK_CELL_VECTOR_FIELD} PetscViewerVTKFieldType;
26118e2ec27SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerVTKAddField(PetscViewer,PetscObject,PetscErrorCode (*PetscViewerVTKWriteFunction)(PetscObject,PetscViewer),PetscViewerVTKFieldType,PetscObject);
262014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVTKOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
2634061b8bfSJed Brown 
26477ed5343SBarry Smith /*
265*d70abbfaSBarry Smith      These are all the default viewers that do not have to be explicitly opened
26677ed5343SBarry Smith */
267014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_STDOUT_(MPI_Comm);
268014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*);
269014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_STDERR_(MPI_Comm);
270014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*);
271014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_DRAW_(MPI_Comm);
272014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_SOCKET_(MPI_Comm);
273014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_BINARY_(MPI_Comm);
274014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_MATLAB_(MPI_Comm);
275014dd563SJed Brown PETSC_EXTERN PetscViewer   PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE;
2765311e20fSBarry Smith 
277b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_SELF  PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
278b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)
27930de9b25SBarry Smith 
28030de9b25SBarry Smith /*MC
28130de9b25SBarry Smith   PETSC_VIEWER_STDOUT_WORLD  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
28230de9b25SBarry Smith 
28330de9b25SBarry Smith   Level: beginner
28430de9b25SBarry Smith M*/
28530de9b25SBarry Smith #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
28630de9b25SBarry Smith 
28730de9b25SBarry Smith /*MC
28830de9b25SBarry Smith   PETSC_VIEWER_STDOUT_SELF  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
28930de9b25SBarry Smith 
29030de9b25SBarry Smith   Level: beginner
29130de9b25SBarry Smith M*/
29230de9b25SBarry Smith #define PETSC_VIEWER_STDOUT_SELF  PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
29330de9b25SBarry Smith 
29430de9b25SBarry Smith /*MC
29530de9b25SBarry Smith   PETSC_VIEWER_DRAW_WORLD  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
29630de9b25SBarry Smith 
29730de9b25SBarry Smith   Level: intermediate
29830de9b25SBarry Smith M*/
299b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_WORLD   PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
30030de9b25SBarry Smith 
30130de9b25SBarry Smith /*MC
30230de9b25SBarry Smith   PETSC_VIEWER_DRAW_SELF  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
30330de9b25SBarry Smith 
30430de9b25SBarry Smith   Level: intermediate
30530de9b25SBarry Smith M*/
30630de9b25SBarry Smith #define PETSC_VIEWER_DRAW_SELF    PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
30730de9b25SBarry Smith 
30830de9b25SBarry Smith /*MC
30930de9b25SBarry Smith   PETSC_VIEWER_SOCKET_WORLD  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
31030de9b25SBarry Smith 
31130de9b25SBarry Smith   Level: intermediate
31230de9b25SBarry Smith M*/
313b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
31430de9b25SBarry Smith 
31530de9b25SBarry Smith /*MC
31630de9b25SBarry Smith   PETSC_VIEWER_SOCKET_SELF  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
31730de9b25SBarry Smith 
31830de9b25SBarry Smith   Level: intermediate
31930de9b25SBarry Smith M*/
320b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_SELF  PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
32130de9b25SBarry Smith 
32230de9b25SBarry Smith /*MC
32330de9b25SBarry Smith   PETSC_VIEWER_BINARY_WORLD  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
32430de9b25SBarry Smith 
32530de9b25SBarry Smith   Level: intermediate
32630de9b25SBarry Smith M*/
327b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
32830de9b25SBarry Smith 
32930de9b25SBarry Smith /*MC
33030de9b25SBarry Smith   PETSC_VIEWER_BINARY_SELF  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
33130de9b25SBarry Smith 
33230de9b25SBarry Smith   Level: intermediate
33330de9b25SBarry Smith M*/
334b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_SELF  PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
33530de9b25SBarry Smith 
336cbb32127SBarry Smith /*MC
337cbb32127SBarry Smith   PETSC_VIEWER_MATLAB_WORLD  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
338cbb32127SBarry Smith 
339cbb32127SBarry Smith   Level: intermediate
340cbb32127SBarry Smith M*/
341cbb32127SBarry Smith #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
342cbb32127SBarry Smith 
343cbb32127SBarry Smith /*MC
344cbb32127SBarry Smith   PETSC_VIEWER_MATLAB_SELF  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
345cbb32127SBarry Smith 
346cbb32127SBarry Smith   Level: intermediate
347cbb32127SBarry Smith M*/
348cbb32127SBarry Smith #define PETSC_VIEWER_MATLAB_SELF  PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
349cbb32127SBarry Smith 
3507eb62a3eSMatthew Knepley #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE)
35165ef3172SBarry Smith 
352639ff905SBarry Smith #undef __FUNCT__
353639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlStart"
354639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStart(PetscViewer viewer,PetscInt *mcnt,PetscInt *cnt)
355639ff905SBarry Smith {
356639ff905SBarry Smith   PetscErrorCode ierr;
357639ff905SBarry Smith   PetscFunctionBegin;
358639ff905SBarry Smith   ierr = PetscViewerBinaryGetFlowControl(viewer,mcnt);CHKERRQ(ierr);
359639ff905SBarry Smith   ierr = PetscViewerBinaryGetFlowControl(viewer,cnt);CHKERRQ(ierr);
360639ff905SBarry Smith   PetscFunctionReturn(0);
361e03d165dSBarry Smith }
362639ff905SBarry Smith 
363639ff905SBarry Smith #undef __FUNCT__
364639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlStepMaster"
365639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStepMaster(PetscViewer viewer,PetscInt i,PetscInt *mcnt,PetscInt cnt)
366639ff905SBarry Smith {
367639ff905SBarry Smith   PetscErrorCode ierr;
368639ff905SBarry Smith   MPI_Comm       comm;
369639ff905SBarry Smith 
370639ff905SBarry Smith   PetscFunctionBegin;
371639ff905SBarry Smith   ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr);
372639ff905SBarry Smith   if (i >= *mcnt) {
373639ff905SBarry Smith     *mcnt += cnt;
374639ff905SBarry Smith     ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr);
375639ff905SBarry Smith   }
376639ff905SBarry Smith   PetscFunctionReturn(0);
377639ff905SBarry Smith }
378639ff905SBarry Smith 
379639ff905SBarry Smith #undef __FUNCT__
380639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlEndMaster"
381639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlEndMaster(PetscViewer viewer,PetscInt *mcnt)
382639ff905SBarry Smith {
383639ff905SBarry Smith   PetscErrorCode ierr;
384639ff905SBarry Smith   MPI_Comm       comm;
385639ff905SBarry Smith   PetscFunctionBegin;
386639ff905SBarry Smith   ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr);
387639ff905SBarry Smith   *mcnt = 0;
388639ff905SBarry Smith   ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr);
389639ff905SBarry Smith   PetscFunctionReturn(0);
390639ff905SBarry Smith }
391639ff905SBarry Smith 
392639ff905SBarry Smith #undef __FUNCT__
393639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlStepWorker"
394639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStepWorker(PetscViewer viewer,PetscMPIInt rank,PetscInt *mcnt)
395639ff905SBarry Smith {
396639ff905SBarry Smith   PetscErrorCode ierr;
397639ff905SBarry Smith   MPI_Comm       comm;
398639ff905SBarry Smith   PetscFunctionBegin;
399639ff905SBarry Smith   ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr);
400639ff905SBarry Smith   while (PETSC_TRUE) {
401639ff905SBarry Smith     if (rank < *mcnt) break;
402639ff905SBarry Smith     ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr);
403639ff905SBarry Smith   }
404639ff905SBarry Smith   PetscFunctionReturn(0);
405639ff905SBarry Smith }
406639ff905SBarry Smith 
407639ff905SBarry Smith #undef __FUNCT__
408639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlEndWorker"
409639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlEndWorker(PetscViewer viewer,PetscInt *mcnt)
410639ff905SBarry Smith {
411639ff905SBarry Smith   PetscErrorCode ierr;
412639ff905SBarry Smith   MPI_Comm       comm;
413639ff905SBarry Smith   PetscFunctionBegin;
414639ff905SBarry Smith   ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr);
415639ff905SBarry Smith   while (PETSC_TRUE) {
416639ff905SBarry Smith     ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr);
417639ff905SBarry Smith     if (!*mcnt) break;
418639ff905SBarry Smith   }
419639ff905SBarry Smith   PetscFunctionReturn(0);
420fca9dd48SBarry Smith }
421e03d165dSBarry Smith 
42277ed5343SBarry Smith /*
423a5057860SBarry Smith    PetscViewer writes to MATLAB .mat file
424cbb32127SBarry Smith */
425014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutArray(PetscViewer,int,int,const PetscScalar*,const char*);
426014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,const char*);
427014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutVariable(PetscViewer,const char*,void*);
428cbb32127SBarry Smith 
429b9617806SBarry Smith /*S
4301890ba74SBarry Smith      PetscViewers - Abstract collection of PetscViewers. It is just an expandable array of viewers.
431b9617806SBarry Smith 
432b9617806SBarry Smith    Level: intermediate
433b9617806SBarry Smith 
434b9617806SBarry Smith   Concepts: viewing
435b9617806SBarry Smith 
436b9617806SBarry Smith .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
437b9617806SBarry Smith            PetscViewersGetViewer()
438b9617806SBarry Smith S*/
43995fbd943SSatish Balay typedef struct _n_PetscViewers* PetscViewers;
440014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewersCreate(MPI_Comm,PetscViewers*);
441014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewersDestroy(PetscViewers*);
442014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*);
443d132466eSBarry Smith 
444b3506946SBarry Smith #if defined(PETSC_HAVE_AMS)
445b3506946SBarry Smith #include <ams.h>
446014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSSetCommName(PetscViewer,const char[]);
447014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSGetAMSComm(PetscViewer,AMS_Comm *);
448014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSOpen(MPI_Comm,const char[],PetscViewer*);
449014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSLock(PetscViewer);
450014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_AMS_(MPI_Comm);
451014dd563SJed Brown PETSC_EXTERN PetscErrorCode PETSC_VIEWER_AMS_Destroy(MPI_Comm);
452b3506946SBarry Smith #define PETSC_VIEWER_AMS_WORLD PETSC_VIEWER_AMS_(PETSC_COMM_WORLD)
453b3506946SBarry Smith #endif
454b3506946SBarry Smith 
455cb5b572fSBarry Smith #endif
456