xref: /petsc/include/petscviewer.h (revision 4ebda54ed598c6ec2aeadd2270a04461e92576e4)
173f4d377SMatthew Knepley /* $Id: petscviewer.h,v 1.85 2001/08/06 21:13:28 bsmith Exp $ */
284cb2905SBarry Smith /*
3b0a32e0cSBarry Smith      PetscViewers are objects where other objects can be looked at or stored.
484cb2905SBarry Smith */
53c119ea2SBarry Smith 
60a835dfdSSatish Balay #if !defined(__PETSCVIEWER_H)
70a835dfdSSatish Balay #define __PETSCVIEWER_H
82eb8c8abSBarry Smith 
9b9617806SBarry Smith /*S
10b9617806SBarry Smith      PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc)
11b9617806SBarry Smith          other PETSc objects
12b9617806SBarry Smith 
13b9617806SBarry Smith    Level: beginner
14b9617806SBarry Smith 
15b9617806SBarry Smith   Concepts: viewing
16b9617806SBarry Smith 
17b9617806SBarry Smith .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType
18b9617806SBarry Smith S*/
19b0a32e0cSBarry Smith typedef struct _p_PetscViewer* PetscViewer;
203c119ea2SBarry Smith 
213c119ea2SBarry Smith /*
22b0a32e0cSBarry Smith     petsc.h must be included AFTER the definition of PetscViewer for ADIC to
233c119ea2SBarry Smith    process correctly.
243c119ea2SBarry Smith */
252eb8c8abSBarry Smith #include "petsc.h"
262eb8c8abSBarry Smith 
27b0a32e0cSBarry Smith #define PETSC_VIEWER_COOKIE              PETSC_COOKIE+1
282eb8c8abSBarry Smith 
29b9617806SBarry Smith /*E
30b9617806SBarry Smith     PetscViewerType - String with the name of a PETSc PETScViewer
31b9617806SBarry Smith 
32b9617806SBarry Smith    Level: beginner
33b9617806SBarry Smith 
34b9617806SBarry Smith .seealso: PetscViewerSetType(), PetscViewer
35b9617806SBarry Smith E*/
36b9617806SBarry Smith typedef char* PetscViewerType;
37b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET       "socket"
38b0a32e0cSBarry Smith #define PETSC_VIEWER_ASCII        "ascii"
39fb9695e5SSatish Balay #define PETSC_VIEWER_BINARY       "binary"
40b0a32e0cSBarry Smith #define PETSC_VIEWER_STRING       "string"
41fb9695e5SSatish Balay #define PETSC_VIEWER_DRAW         "draw"
42b0a32e0cSBarry Smith #define PETSC_VIEWER_AMS          "ams"
43*4ebda54eSMatthew Knepley #define PETSC_VIEWER_MATHEMATICA  "mathematica"
44*4ebda54eSMatthew Knepley #define PETSC_VIEWER_SILO         "silo"
4577ed5343SBarry Smith 
46b0a32e0cSBarry Smith extern PetscFList PetscViewerList;
47b0a32e0cSBarry Smith EXTERN int PetscViewerRegisterAll(char *);
48b0a32e0cSBarry Smith EXTERN int PetscViewerRegisterDestroy(void);
497b2a1423SBarry Smith 
50b0a32e0cSBarry Smith EXTERN int PetscViewerRegister(char*,char*,char*,int(*)(PetscViewer));
51aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
52b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0)
537b2a1423SBarry Smith #else
54b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d)
557b2a1423SBarry Smith #endif
56b0a32e0cSBarry Smith EXTERN int PetscViewerCreate(MPI_Comm,PetscViewer*);
57b0a32e0cSBarry Smith EXTERN int PetscViewerSetFromOptions(PetscViewer);
587b2a1423SBarry Smith 
59b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*);
60b0a32e0cSBarry Smith typedef enum {PETSC_BINARY_RDONLY,PETSC_BINARY_WRONLY,PETSC_BINARY_CREATE} PetscViewerBinaryType;
61b0a32e0cSBarry Smith EXTERN int PetscViewerBinaryOpen(MPI_Comm,const char[],PetscViewerBinaryType,PetscViewer*);
62b0a32e0cSBarry Smith EXTERN int PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*);
63b0a32e0cSBarry Smith EXTERN int PetscViewerStringOpen(MPI_Comm,char[],int,PetscViewer*);
64b0a32e0cSBarry Smith EXTERN int PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*);
65b0a32e0cSBarry Smith EXTERN int PetscViewerAMSSetCommName(PetscViewer,const char[]);
66*4ebda54eSMatthew Knepley EXTERN int PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *);
67*4ebda54eSMatthew Knepley EXTERN int PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *);
684b0e389bSBarry Smith 
69b0a32e0cSBarry Smith EXTERN int PetscViewerGetType(PetscViewer,PetscViewerType*);
70b0a32e0cSBarry Smith EXTERN int PetscViewerSetType(PetscViewer,PetscViewerType);
71b0a32e0cSBarry Smith EXTERN int PetscViewerDestroy(PetscViewer);
72b0a32e0cSBarry Smith EXTERN int PetscViewerGetSingleton(PetscViewer,PetscViewer*);
73b0a32e0cSBarry Smith EXTERN int PetscViewerRestoreSingleton(PetscViewer,PetscViewer*);
74ae39576cSLois Curfman McInnes 
75090de74eSSatish Balay 
76b9617806SBarry Smith /*E
77b9617806SBarry Smith     PetscViewerFormat - Way a viewer presents the object
78b9617806SBarry Smith 
79b9617806SBarry Smith    Level: beginner
80b9617806SBarry Smith 
81b9617806SBarry Smith .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat()
82b9617806SBarry Smith E*/
83fb9695e5SSatish Balay typedef enum {
84f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_DEFAULT,
85f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_MATLAB,
86*4ebda54eSMatthew Knepley   PETSC_VIEWER_ASCII_MATHEMATICA,
87f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_IMPL,
88f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INFO,
89f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INFO_LONG,
90f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_COMMON,
91f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_SYMMODU,
92f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INDEX,
93f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_DENSE,
94f3ef73ceSBarry Smith   PETSC_VIEWER_BINARY_DEFAULT,
95f3ef73ceSBarry Smith   PETSC_VIEWER_BINARY_NATIVE,
96f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_BASIC,
97f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_LG,
98f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_CONTOUR,
99f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_PORTS,
100f3ef73ceSBarry Smith   PETSC_VIEWER_NATIVE,
101f3ef73ceSBarry Smith   PETSC_VIEWER_NOFORMAT} PetscViewerFormat;
102090de74eSSatish Balay 
103f3ef73ceSBarry Smith EXTERN int PetscViewerSetFormat(PetscViewer,PetscViewerFormat);
104f3ef73ceSBarry Smith EXTERN int PetscViewerPushFormat(PetscViewer,PetscViewerFormat);
105b0a32e0cSBarry Smith EXTERN int PetscViewerPopFormat(PetscViewer);
106f3ef73ceSBarry Smith EXTERN int PetscViewerGetFormat(PetscViewer,PetscViewerFormat*);
107b0a32e0cSBarry Smith EXTERN int PetscViewerFlush(PetscViewer);
1084b0e389bSBarry Smith 
10977ed5343SBarry Smith /*
11077ed5343SBarry Smith    Operations explicit to a particular class of viewers
11177ed5343SBarry Smith */
112b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIGetPointer(PetscViewer,FILE**);
113b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIPrintf(PetscViewer,const char[],...);
114b0a32e0cSBarry Smith EXTERN int PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...);
115b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIPushTab(PetscViewer);
116b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIPopTab(PetscViewer);
117b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIUseTabs(PetscViewer,PetscTruth);
118b0a32e0cSBarry Smith EXTERN int PetscViewerASCIISetTab(PetscViewer,int);
119b0a32e0cSBarry Smith EXTERN int PetscViewerBinaryGetDescriptor(PetscViewer,int*);
120b0a32e0cSBarry Smith EXTERN int PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **);
121b0a32e0cSBarry Smith EXTERN int PetscViewerBinarySetType(PetscViewer,PetscViewerBinaryType);
122b0a32e0cSBarry Smith EXTERN int PetscViewerStringSPrintf(PetscViewer,char *,...);
123b0a32e0cSBarry Smith EXTERN int PetscViewerStringSetString(PetscViewer,char[],int);
124b0a32e0cSBarry Smith EXTERN int PetscViewerDrawClear(PetscViewer);
125b0a32e0cSBarry Smith EXTERN int PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int);
126b0a32e0cSBarry Smith EXTERN int PetscViewerSocketSetConnection(PetscViewer,const char[],int);
127c655490fSBarry Smith 
128b0a32e0cSBarry Smith EXTERN int PetscViewerSetFilename(PetscViewer,const char[]);
129b0a32e0cSBarry Smith EXTERN int PetscViewerGetFilename(PetscViewer,char**);
13077ed5343SBarry Smith 
131*4ebda54eSMatthew Knepley EXTERN int ViewerMathematicaGetName(PetscViewer, char **);
132*4ebda54eSMatthew Knepley EXTERN int ViewerMathematicaSetName(PetscViewer, const char []);
133*4ebda54eSMatthew Knepley EXTERN int ViewerMathematicaClearName(PetscViewer);
134*4ebda54eSMatthew Knepley EXTERN int ViewerMathematicaSkipPackets(PetscViewer, int);
135*4ebda54eSMatthew Knepley #ifdef PETSC_HAVE_MATHEMATICA
136*4ebda54eSMatthew Knepley EXTERN int ViewerMathematicaGetLink(PetscViewer, MLINK *);
137*4ebda54eSMatthew Knepley #endif
138*4ebda54eSMatthew Knepley 
139*4ebda54eSMatthew Knepley EXTERN int ViewerSiloGetName(PetscViewer, char **);
140*4ebda54eSMatthew Knepley EXTERN int ViewerSiloSetName(PetscViewer, const char []);
141*4ebda54eSMatthew Knepley EXTERN int ViewerSiloClearName(PetscViewer);
142*4ebda54eSMatthew Knepley EXTERN int ViewerSiloGetMeshName(PetscViewer, char **);
143*4ebda54eSMatthew Knepley EXTERN int ViewerSiloSetMeshName(PetscViewer, const char []);
144*4ebda54eSMatthew Knepley EXTERN int ViewerSiloClearMeshName(PetscViewer);
145*4ebda54eSMatthew Knepley 
14677ed5343SBarry Smith /*
14777ed5343SBarry Smith      These are all the default viewers that do not have
14877ed5343SBarry Smith    to be explicitly opened
14977ed5343SBarry Smith */
150b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_STDOUT_(MPI_Comm);
151b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_STDERR_(MPI_Comm);
152b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_DRAW_(MPI_Comm);
153b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_SOCKET_(MPI_Comm);
154b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_BINARY_(MPI_Comm);
155*4ebda54eSMatthew Knepley EXTERN PetscViewer VIEWER_MATHEMATICA_WORLD_PRIVATE;
1565311e20fSBarry Smith 
157b0a32e0cSBarry Smith #define PETSC_VIEWER_STDOUT_SELF  PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
158b0a32e0cSBarry Smith #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
159b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_SELF  PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
160b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)
161b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_SELF    PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
162b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_WORLD   PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
163b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
164b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_SELF  PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
165b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
166b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_SELF  PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
167*4ebda54eSMatthew Knepley #define VIEWER_MATHEMATICA_WORLD (ViewerInitializeMathematicaWorld_Private(),VIEWER_MATHEMATICA_WORLD_PRIVATE)
16865ef3172SBarry Smith 
16977ed5343SBarry Smith /*
170b0a32e0cSBarry Smith     PetscViewer based on the ALICE Memory Snooper
17177ed5343SBarry Smith */
172aa482453SBarry Smith #if defined(PETSC_HAVE_AMS)
173cb5b572fSBarry Smith #include "ams.h"
174b0a32e0cSBarry Smith EXTERN int         PetscViewerAMSGetAMSComm(PetscViewer,AMS_Comm *);
175b0a32e0cSBarry Smith EXTERN int         PetscViewerAMSOpen(MPI_Comm,const char[],PetscViewer*);
176b1607693SBarry Smith EXTERN int         PetscViewerAMSLock(PetscViewer);
177b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_AMS_(MPI_Comm);
178b0a32e0cSBarry Smith EXTERN int         PETSC_VIEWER_AMS_Destroy(MPI_Comm);
179b0a32e0cSBarry Smith #define PETSC_VIEWER_AMS_WORLD PETSC_VIEWER_AMS_(PETSC_COMM_WORLD)
1802eb8c8abSBarry Smith #endif
181cb5b572fSBarry Smith 
182f2b01315SBarry Smith /*
183b0a32e0cSBarry Smith     PetscViewer utility routines used by PETSc that are not normally used
184f2b01315SBarry Smith    by users.
185f2b01315SBarry Smith */
18687828ca2SBarry Smith EXTERN int  PetscViewerSocketPutScalar(PetscViewer,int,int,PetscScalar*);
18787828ca2SBarry Smith EXTERN int  PetscViewerSocketPutReal(PetscViewer,int,int,PetscReal*);
188b0a32e0cSBarry Smith EXTERN int  PetscViewerSocketPutInt(PetscViewer,int,int*);
18987828ca2SBarry Smith EXTERN int  PetscViewerSocketPutSparse_Private(PetscViewer,int,int,int,PetscScalar*,int*,int *);
190b0a32e0cSBarry Smith EXTERN int  PetscViewerDestroyAMS_Private(void);
191f2b01315SBarry Smith 
192b9617806SBarry Smith /*S
193b9617806SBarry Smith      PetscViewers - Abstract collection of PetscViewers
194b9617806SBarry Smith 
195b9617806SBarry Smith    Level: intermediate
196b9617806SBarry Smith 
197b9617806SBarry Smith   Concepts: viewing
198b9617806SBarry Smith 
199b9617806SBarry Smith .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
200b9617806SBarry Smith            PetscViewersGetViewer()
201b9617806SBarry Smith S*/
202b0a32e0cSBarry Smith typedef struct _p_PetscViewers* PetscViewers;
203b0a32e0cSBarry Smith EXTERN int PetscViewersCreate(MPI_Comm,PetscViewers*);
204b0a32e0cSBarry Smith EXTERN int PetscViewersDestroy(PetscViewers);
205b0a32e0cSBarry Smith EXTERN int PetscViewersGetViewer(PetscViewers,int,PetscViewer*);
206d132466eSBarry Smith 
207cb5b572fSBarry Smith #endif
208cb5b572fSBarry Smith 
209e7592fafSBarry Smith 
210e7592fafSBarry Smith 
211e7592fafSBarry Smith 
212