xref: /petsc/include/petscviewer.h (revision c619b03e9a39856418a9e23c79aa5be44c20f181)
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>
9*c619b03eSJed Brown #include <petscviewertypes.h>
10e9fa29b7SSatish Balay 
11014dd563SJed Brown PETSC_EXTERN PetscClassId PETSC_VIEWER_CLASSID;
12e9fa29b7SSatish Balay 
1376bdecfbSBarry Smith /*J
14b9617806SBarry Smith     PetscViewerType - String with the name of a PETSc PETScViewer
15b9617806SBarry Smith 
16b9617806SBarry Smith    Level: beginner
17b9617806SBarry Smith 
18b9617806SBarry Smith .seealso: PetscViewerSetType(), PetscViewer
1976bdecfbSBarry Smith J*/
2019fd82e9SBarry Smith typedef const char* PetscViewerType;
212692d6eeSBarry Smith #define PETSCVIEWERSOCKET       "socket"
222692d6eeSBarry Smith #define PETSCVIEWERASCII        "ascii"
232692d6eeSBarry Smith #define PETSCVIEWERBINARY       "binary"
242692d6eeSBarry Smith #define PETSCVIEWERSTRING       "string"
252692d6eeSBarry Smith #define PETSCVIEWERDRAW         "draw"
262692d6eeSBarry Smith #define PETSCVIEWERVU           "vu"
272692d6eeSBarry Smith #define PETSCVIEWERMATHEMATICA  "mathematica"
282692d6eeSBarry Smith #define PETSCVIEWERNETCDF       "netcdf"
292692d6eeSBarry Smith #define PETSCVIEWERHDF5         "hdf5"
304061b8bfSJed Brown #define PETSCVIEWERVTK          "vtk"
312692d6eeSBarry Smith #define PETSCVIEWERMATLAB       "matlab"
32b3506946SBarry Smith #define PETSCVIEWERAMS          "ams"
3377ed5343SBarry Smith 
34140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList PetscViewerList;
35014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRegisterAll(const char *);
36014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRegisterDestroy(void);
37014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerInitializePackage(const char[]);
387b2a1423SBarry Smith 
39014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRegister(const char*,const char*,const char*,PetscErrorCode (*)(PetscViewer));
4030de9b25SBarry Smith 
4130de9b25SBarry Smith /*MC
4292c97de8SJed Brown    PetscViewerRegisterDynamic - Adds a viewer
4330de9b25SBarry Smith 
44f2ba6396SBarry Smith    Synopsis
45f2ba6396SBarry Smith    #include "petscviewer.h"
461890ba74SBarry Smith    PetscErrorCode PetscViewerRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(PetscViewer))
4730de9b25SBarry Smith 
4830de9b25SBarry Smith    Not Collective
4930de9b25SBarry Smith 
5030de9b25SBarry Smith    Input Parameters:
5192c97de8SJed Brown +  name_solver - name of a new user-defined viewer
5292c97de8SJed Brown .  path - path (either absolute or relative) the library containing this viewer
5330de9b25SBarry Smith .  name_create - name of routine to create method context
5430de9b25SBarry Smith -  routine_create - routine to create method context
5530de9b25SBarry Smith 
5630de9b25SBarry Smith    Level: developer
5730de9b25SBarry Smith 
5830de9b25SBarry Smith    Notes:
5992c97de8SJed Brown    PetscViewerRegisterDynamic() may be called multiple times to add several user-defined viewers.
6030de9b25SBarry Smith 
6130de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (routine_create)
6230de9b25SBarry Smith    is ignored.
6330de9b25SBarry Smith 
6430de9b25SBarry Smith    Sample usage:
6530de9b25SBarry Smith .vb
6630de9b25SBarry Smith    PetscViewerRegisterDynamic("my_viewer_type",/home/username/my_lib/lib/libO/solaris/mylib.a,
6730de9b25SBarry Smith                "MyViewerCreate",MyViewerCreate);
6830de9b25SBarry Smith .ve
6930de9b25SBarry Smith 
7030de9b25SBarry Smith    Then, your solver can be chosen with the procedural interface via
7192c97de8SJed Brown $     PetscViewerSetType(viewer,"my_viewer_type")
7230de9b25SBarry Smith    or at runtime via the option
7330de9b25SBarry Smith $     -viewer_type my_viewer_type
7430de9b25SBarry Smith 
7530de9b25SBarry Smith   Concepts: registering^Viewers
7630de9b25SBarry Smith 
7730de9b25SBarry Smith .seealso: PetscViewerRegisterAll(), PetscViewerRegisterDestroy()
7830de9b25SBarry Smith M*/
79aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
80b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0)
817b2a1423SBarry Smith #else
82b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d)
837b2a1423SBarry Smith #endif
8430de9b25SBarry Smith 
85014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerCreate(MPI_Comm,PetscViewer*);
86014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetFromOptions(PetscViewer);
87014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpenWithFILE(MPI_Comm,FILE*,PetscViewer*);
887b2a1423SBarry Smith 
89014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*);
90014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISetFILE(PetscViewer,FILE*);
91014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
92014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetFlowControl(PetscViewer,PetscInt*);
93014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetFlowControl(PetscViewer,PetscInt);
94014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetMPIIO(PetscViewer);
95014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIO(PetscViewer,PetscBool *);
960fc9d207SBarry Smith #if defined(PETSC_HAVE_MPIIO)
97014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIODescriptor(PetscViewer,MPI_File*);
98014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIOOffset(PetscViewer,MPI_Offset*);
99014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryAddMPIIOOffset(PetscViewer,MPI_Offset);
100951e3c8eSBarry Smith #endif
10139802e9eSBarry Smith 
102014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*);
103014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerStringOpen(MPI_Comm,char[],PetscInt,PetscViewer*);
104014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*);
105014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *);
106014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *);
107014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
1084b0e389bSBarry Smith 
10919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerGetType(PetscViewer,PetscViewerType*);
11019fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerSetType(PetscViewer,PetscViewerType);
111014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDestroy(PetscViewer*);
112014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetSingleton(PetscViewer,PetscViewer*);
113014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRestoreSingleton(PetscViewer,PetscViewer*);
114014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
115014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRestoreSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
116ae39576cSLois Curfman McInnes 
117014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetUp(PetscViewer);
118014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerView(PetscViewer,PetscViewer);
119f69a0ea3SMatthew Knepley 
120014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer,const char[]);
121014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer,const char[]);
122014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer,const char*[]);
123090de74eSSatish Balay 
124b9617806SBarry Smith /*E
125b9617806SBarry Smith     PetscViewerFormat - Way a viewer presents the object
126b9617806SBarry Smith 
127b9617806SBarry Smith    Level: beginner
128b9617806SBarry Smith 
129cfaaf4edSHong Zhang    The values below are also listed in finclude/petscviewer.h. If another values is added below it
130cfaaf4edSHong Zhang    must also be added there.
131cfaaf4edSHong Zhang 
132b9617806SBarry Smith .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat()
133b9617806SBarry Smith E*/
134fb9695e5SSatish Balay typedef enum {
135117016b1SBarry Smith   PETSC_VIEWER_DEFAULT,
136f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_MATLAB,
1374ebda54eSMatthew Knepley   PETSC_VIEWER_ASCII_MATHEMATICA,
138f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_IMPL,
139f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INFO,
140456192e2SBarry Smith   PETSC_VIEWER_ASCII_INFO_DETAIL,
141f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_COMMON,
142f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_SYMMODU,
143f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INDEX,
144f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_DENSE,
1453c215bfdSMatthew Knepley   PETSC_VIEWER_ASCII_MATRIXMARKET,
146a505fa5bSMatthew Knepley   PETSC_VIEWER_ASCII_VTK,
147b85befe5SMatthew Knepley   PETSC_VIEWER_ASCII_VTK_CELL,
148b6d733afSMatthew Knepley   PETSC_VIEWER_ASCII_VTK_COORDS,
149493617b5SMatthew Knepley   PETSC_VIEWER_ASCII_PCICE,
150cfaaf4edSHong Zhang   PETSC_VIEWER_ASCII_PYTHON,
151cfaaf4edSHong Zhang   PETSC_VIEWER_ASCII_FACTOR_INFO,
15267ad5babSMatthew G Knepley   PETSC_VIEWER_ASCII_LATEX,
153f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_BASIC,
154f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_LG,
155f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_CONTOUR,
156f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_PORTS,
1574061b8bfSJed Brown   PETSC_VIEWER_VTK_VTS,
158b263465dSJed Brown   PETSC_VIEWER_VTK_VTU,
159a261c58fSBarry Smith   PETSC_VIEWER_BINARY_MATLAB,
160f3ef73ceSBarry Smith   PETSC_VIEWER_NATIVE,
161cfaaf4edSHong Zhang   PETSC_VIEWER_NOFORMAT
162cfaaf4edSHong Zhang   } PetscViewerFormat;
163014dd563SJed Brown PETSC_EXTERN const char *const PetscViewerFormats[];
164090de74eSSatish Balay 
165014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetFormat(PetscViewer,PetscViewerFormat);
166014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerPushFormat(PetscViewer,PetscViewerFormat);
167014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerPopFormat(PetscViewer);
168014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetFormat(PetscViewer,PetscViewerFormat*);
169014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFlush(PetscViewer);
1704b0e389bSBarry Smith 
171cffb1e40SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetViewer(MPI_Comm,const char[],const char[],PetscViewer*,PetscViewerFormat*,PetscBool*);
172cffb1e40SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsViewer(const char[],const char[],const char[],PetscViewer*,PetscViewerFormat *,PetscBool *);
1732bf49c77SBarry Smith 
17477ed5343SBarry Smith /*
17577ed5343SBarry Smith    Operations explicit to a particular class of viewers
17677ed5343SBarry Smith */
177ed5c6e3eSMatthew Knepley 
178014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetPointer(PetscViewer,FILE**);
179014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileGetMode(PetscViewer,PetscFileMode*);
180014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileSetMode(PetscViewer,PetscFileMode);
181014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIPrintf(PetscViewer,const char[],...);
182014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...);
183014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedAllow(PetscViewer,PetscBool);
184014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIPushTab(PetscViewer);
185014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIPopTab(PetscViewer);
186014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIUseTabs(PetscViewer,PetscBool );
187014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISetTab(PetscViewer,PetscInt);
188014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetTab(PetscViewer,PetscInt*);
189014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIAddTab(PetscViewer,PetscInt);
190014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISubtractTab(PetscViewer,PetscInt);
191014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetDescriptor(PetscViewer,int*);
192014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **);
193014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryRead(PetscViewer,void*,PetscInt,PetscDataType);
194014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryWrite(PetscViewer,void*,PetscInt,PetscDataType,PetscBool );
195014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerStringSPrintf(PetscViewer,const char[],...);
196014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerStringSetString(PetscViewer,char[],PetscInt);
197014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawClear(PetscViewer);
198014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetHold(PetscViewer,PetscBool);
199014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawGetHold(PetscViewer,PetscBool*);
200014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetPause(PetscViewer,PetscReal);
201014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawGetPause(PetscViewer,PetscReal*);
202014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int);
203014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawResize(PetscViewer,int,int);
204014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetBounds(PetscViewer,PetscInt,const PetscReal*);
205014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawGetBounds(PetscViewer,PetscInt*,const PetscReal**);
206014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSocketSetConnection(PetscViewer,const char[],int);
207014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySkipInfo(PetscViewer);
208014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipOptions(PetscViewer,PetscBool );
209014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipOptions(PetscViewer,PetscBool *);
210014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipHeader(PetscViewer,PetscBool);
211014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipHeader(PetscViewer,PetscBool*);
212014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryReadStringArray(PetscViewer,char***);
213014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryWriteStringArray(PetscViewer,char**);
214c655490fSBarry Smith 
215014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileSetName(PetscViewer,const char[]);
216014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileGetName(PetscViewer,const char**);
21777ed5343SBarry Smith 
218014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUGetPointer(PetscViewer, FILE**);
219014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUSetVecSeen(PetscViewer, PetscBool );
220014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUGetVecSeen(PetscViewer, PetscBool  *);
221014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUPrintDeferred(PetscViewer, const char [], ...);
222014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUFlushDeferred(PetscViewer);
22355dcf840SMatthew Knepley 
224014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaInitializePackage(const char[]);
225014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaFinalizePackage(void);
226014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetName(PetscViewer, const char **);
227014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSetName(PetscViewer, const char []);
228014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaClearName(PetscViewer);
229014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSkipPackets(PetscViewer, int);
2304ebda54eSMatthew Knepley 
231014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloGetName(PetscViewer, char **);
232014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloSetName(PetscViewer, const char []);
233014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloClearName(PetscViewer);
234014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloGetMeshName(PetscViewer, char **);
235014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloSetMeshName(PetscViewer, const char []);
236014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloClearMeshName(PetscViewer);
2374ebda54eSMatthew Knepley 
238014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
239014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerNetcdfGetID(PetscViewer, int *);
240e3eb5169SDinesh Kaushik 
241893c9c94SMatthew G Knepley typedef enum {PETSC_VTK_POINT_FIELD, PETSC_VTK_POINT_VECTOR_FIELD, PETSC_VTK_CELL_FIELD, PETSC_VTK_CELL_VECTOR_FIELD} PetscViewerVTKFieldType;
24218e2ec27SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerVTKAddField(PetscViewer,PetscObject,PetscErrorCode (*PetscViewerVTKWriteFunction)(PetscObject,PetscViewer),PetscViewerVTKFieldType,PetscObject);
243014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVTKOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
2444061b8bfSJed Brown 
24577ed5343SBarry Smith /*
246d70abbfaSBarry Smith      These are all the default viewers that do not have to be explicitly opened
24777ed5343SBarry Smith */
248014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_STDOUT_(MPI_Comm);
249014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*);
250014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_STDERR_(MPI_Comm);
251014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*);
252014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_DRAW_(MPI_Comm);
253014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_SOCKET_(MPI_Comm);
254014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_BINARY_(MPI_Comm);
255014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_MATLAB_(MPI_Comm);
256014dd563SJed Brown PETSC_EXTERN PetscViewer   PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE;
2575311e20fSBarry Smith 
258b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_SELF  PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
259b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)
26030de9b25SBarry Smith 
26130de9b25SBarry Smith /*MC
26230de9b25SBarry Smith   PETSC_VIEWER_STDOUT_WORLD  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
26330de9b25SBarry Smith 
26430de9b25SBarry Smith   Level: beginner
26530de9b25SBarry Smith M*/
26630de9b25SBarry Smith #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
26730de9b25SBarry Smith 
26830de9b25SBarry Smith /*MC
26930de9b25SBarry Smith   PETSC_VIEWER_STDOUT_SELF  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
27030de9b25SBarry Smith 
27130de9b25SBarry Smith   Level: beginner
27230de9b25SBarry Smith M*/
27330de9b25SBarry Smith #define PETSC_VIEWER_STDOUT_SELF  PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
27430de9b25SBarry Smith 
27530de9b25SBarry Smith /*MC
27630de9b25SBarry Smith   PETSC_VIEWER_DRAW_WORLD  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
27730de9b25SBarry Smith 
27830de9b25SBarry Smith   Level: intermediate
27930de9b25SBarry Smith M*/
280b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_WORLD   PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
28130de9b25SBarry Smith 
28230de9b25SBarry Smith /*MC
28330de9b25SBarry Smith   PETSC_VIEWER_DRAW_SELF  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
28430de9b25SBarry Smith 
28530de9b25SBarry Smith   Level: intermediate
28630de9b25SBarry Smith M*/
28730de9b25SBarry Smith #define PETSC_VIEWER_DRAW_SELF    PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
28830de9b25SBarry Smith 
28930de9b25SBarry Smith /*MC
29030de9b25SBarry Smith   PETSC_VIEWER_SOCKET_WORLD  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
29130de9b25SBarry Smith 
29230de9b25SBarry Smith   Level: intermediate
29330de9b25SBarry Smith M*/
294b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
29530de9b25SBarry Smith 
29630de9b25SBarry Smith /*MC
29730de9b25SBarry Smith   PETSC_VIEWER_SOCKET_SELF  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
29830de9b25SBarry Smith 
29930de9b25SBarry Smith   Level: intermediate
30030de9b25SBarry Smith M*/
301b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_SELF  PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
30230de9b25SBarry Smith 
30330de9b25SBarry Smith /*MC
30430de9b25SBarry Smith   PETSC_VIEWER_BINARY_WORLD  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
30530de9b25SBarry Smith 
30630de9b25SBarry Smith   Level: intermediate
30730de9b25SBarry Smith M*/
308b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
30930de9b25SBarry Smith 
31030de9b25SBarry Smith /*MC
31130de9b25SBarry Smith   PETSC_VIEWER_BINARY_SELF  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
31230de9b25SBarry Smith 
31330de9b25SBarry Smith   Level: intermediate
31430de9b25SBarry Smith M*/
315b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_SELF  PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
31630de9b25SBarry Smith 
317cbb32127SBarry Smith /*MC
318cbb32127SBarry Smith   PETSC_VIEWER_MATLAB_WORLD  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
319cbb32127SBarry Smith 
320cbb32127SBarry Smith   Level: intermediate
321cbb32127SBarry Smith M*/
322cbb32127SBarry Smith #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
323cbb32127SBarry Smith 
324cbb32127SBarry Smith /*MC
325cbb32127SBarry Smith   PETSC_VIEWER_MATLAB_SELF  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
326cbb32127SBarry Smith 
327cbb32127SBarry Smith   Level: intermediate
328cbb32127SBarry Smith M*/
329cbb32127SBarry Smith #define PETSC_VIEWER_MATLAB_SELF  PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
330cbb32127SBarry Smith 
3317eb62a3eSMatthew Knepley #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE)
33265ef3172SBarry Smith 
333639ff905SBarry Smith #undef __FUNCT__
334639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlStart"
335639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStart(PetscViewer viewer,PetscInt *mcnt,PetscInt *cnt)
336639ff905SBarry Smith {
337639ff905SBarry Smith   PetscErrorCode ierr;
338639ff905SBarry Smith   PetscFunctionBegin;
339639ff905SBarry Smith   ierr = PetscViewerBinaryGetFlowControl(viewer,mcnt);CHKERRQ(ierr);
340639ff905SBarry Smith   ierr = PetscViewerBinaryGetFlowControl(viewer,cnt);CHKERRQ(ierr);
341639ff905SBarry Smith   PetscFunctionReturn(0);
342e03d165dSBarry Smith }
343639ff905SBarry Smith 
344639ff905SBarry Smith #undef __FUNCT__
345639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlStepMaster"
346639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStepMaster(PetscViewer viewer,PetscInt i,PetscInt *mcnt,PetscInt cnt)
347639ff905SBarry Smith {
348639ff905SBarry Smith   PetscErrorCode ierr;
349639ff905SBarry Smith   MPI_Comm       comm;
350639ff905SBarry Smith 
351639ff905SBarry Smith   PetscFunctionBegin;
352639ff905SBarry Smith   ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr);
353639ff905SBarry Smith   if (i >= *mcnt) {
354639ff905SBarry Smith     *mcnt += cnt;
355639ff905SBarry Smith     ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr);
356639ff905SBarry Smith   }
357639ff905SBarry Smith   PetscFunctionReturn(0);
358639ff905SBarry Smith }
359639ff905SBarry Smith 
360639ff905SBarry Smith #undef __FUNCT__
361639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlEndMaster"
362639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlEndMaster(PetscViewer viewer,PetscInt *mcnt)
363639ff905SBarry Smith {
364639ff905SBarry Smith   PetscErrorCode ierr;
365639ff905SBarry Smith   MPI_Comm       comm;
366639ff905SBarry Smith   PetscFunctionBegin;
367639ff905SBarry Smith   ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr);
368639ff905SBarry Smith   *mcnt = 0;
369639ff905SBarry Smith   ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr);
370639ff905SBarry Smith   PetscFunctionReturn(0);
371639ff905SBarry Smith }
372639ff905SBarry Smith 
373639ff905SBarry Smith #undef __FUNCT__
374639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlStepWorker"
375639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStepWorker(PetscViewer viewer,PetscMPIInt rank,PetscInt *mcnt)
376639ff905SBarry Smith {
377639ff905SBarry Smith   PetscErrorCode ierr;
378639ff905SBarry Smith   MPI_Comm       comm;
379639ff905SBarry Smith   PetscFunctionBegin;
380639ff905SBarry Smith   ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr);
381639ff905SBarry Smith   while (PETSC_TRUE) {
382639ff905SBarry Smith     if (rank < *mcnt) break;
383639ff905SBarry Smith     ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr);
384639ff905SBarry Smith   }
385639ff905SBarry Smith   PetscFunctionReturn(0);
386639ff905SBarry Smith }
387639ff905SBarry Smith 
388639ff905SBarry Smith #undef __FUNCT__
389639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlEndWorker"
390639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlEndWorker(PetscViewer viewer,PetscInt *mcnt)
391639ff905SBarry Smith {
392639ff905SBarry Smith   PetscErrorCode ierr;
393639ff905SBarry Smith   MPI_Comm       comm;
394639ff905SBarry Smith   PetscFunctionBegin;
395639ff905SBarry Smith   ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr);
396639ff905SBarry Smith   while (PETSC_TRUE) {
397639ff905SBarry Smith     ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr);
398639ff905SBarry Smith     if (!*mcnt) break;
399639ff905SBarry Smith   }
400639ff905SBarry Smith   PetscFunctionReturn(0);
401fca9dd48SBarry Smith }
402e03d165dSBarry Smith 
40377ed5343SBarry Smith /*
404a5057860SBarry Smith    PetscViewer writes to MATLAB .mat file
405cbb32127SBarry Smith */
406014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutArray(PetscViewer,int,int,const PetscScalar*,const char*);
407014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,const char*);
408014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutVariable(PetscViewer,const char*,void*);
409cbb32127SBarry Smith 
410b9617806SBarry Smith /*S
4111890ba74SBarry Smith      PetscViewers - Abstract collection of PetscViewers. It is just an expandable array of viewers.
412b9617806SBarry Smith 
413b9617806SBarry Smith    Level: intermediate
414b9617806SBarry Smith 
415b9617806SBarry Smith   Concepts: viewing
416b9617806SBarry Smith 
417b9617806SBarry Smith .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
418b9617806SBarry Smith            PetscViewersGetViewer()
419b9617806SBarry Smith S*/
42095fbd943SSatish Balay typedef struct _n_PetscViewers* PetscViewers;
421014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewersCreate(MPI_Comm,PetscViewers*);
422014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewersDestroy(PetscViewers*);
423014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*);
424d132466eSBarry Smith 
425b3506946SBarry Smith #if defined(PETSC_HAVE_AMS)
426b3506946SBarry Smith #include <ams.h>
427014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSSetCommName(PetscViewer,const char[]);
428014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSGetAMSComm(PetscViewer,AMS_Comm *);
429014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSOpen(MPI_Comm,const char[],PetscViewer*);
430014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSLock(PetscViewer);
431014dd563SJed Brown PETSC_EXTERN PetscViewer    PETSC_VIEWER_AMS_(MPI_Comm);
432014dd563SJed Brown PETSC_EXTERN PetscErrorCode PETSC_VIEWER_AMS_Destroy(MPI_Comm);
433b3506946SBarry Smith #define PETSC_VIEWER_AMS_WORLD PETSC_VIEWER_AMS_(PETSC_COMM_WORLD)
434b3506946SBarry Smith #endif
435b3506946SBarry Smith 
436cb5b572fSBarry Smith #endif
437