xref: /petsc/include/petscviewer.h (revision b961780643a09dddcde1fa5de76862b9b9b6ff18)
1*b9617806SBarry Smith /* $Id: petscviewer.h,v 1.83 2001/03/08 17:29:14 bsmith Exp bsmith $ */
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 
9*b9617806SBarry Smith /*S
10*b9617806SBarry Smith      PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc)
11*b9617806SBarry Smith          other PETSc objects
12*b9617806SBarry Smith 
13*b9617806SBarry Smith    Level: beginner
14*b9617806SBarry Smith 
15*b9617806SBarry Smith   Concepts: viewing
16*b9617806SBarry Smith 
17*b9617806SBarry Smith .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType
18*b9617806SBarry 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 
29*b9617806SBarry Smith /*E
30*b9617806SBarry Smith     PetscViewerType - String with the name of a PETSc PETScViewer
31*b9617806SBarry Smith 
32*b9617806SBarry Smith    Level: beginner
33*b9617806SBarry Smith 
34*b9617806SBarry Smith .seealso: PetscViewerSetType(), PetscViewer
35*b9617806SBarry Smith E*/
36*b9617806SBarry 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"
4377ed5343SBarry Smith 
44b0a32e0cSBarry Smith extern PetscFList PetscViewerList;
45b0a32e0cSBarry Smith EXTERN int PetscViewerRegisterAll(char *);
46b0a32e0cSBarry Smith EXTERN int PetscViewerRegisterDestroy(void);
477b2a1423SBarry Smith 
48b0a32e0cSBarry Smith EXTERN int PetscViewerRegister(char*,char*,char*,int(*)(PetscViewer));
49aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
50b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0)
517b2a1423SBarry Smith #else
52b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d)
537b2a1423SBarry Smith #endif
54b0a32e0cSBarry Smith EXTERN int PetscViewerCreate(MPI_Comm,PetscViewer*);
55b0a32e0cSBarry Smith EXTERN int PetscViewerSetFromOptions(PetscViewer);
567b2a1423SBarry Smith 
57b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*);
58b0a32e0cSBarry Smith typedef enum {PETSC_BINARY_RDONLY,PETSC_BINARY_WRONLY,PETSC_BINARY_CREATE} PetscViewerBinaryType;
59b0a32e0cSBarry Smith EXTERN int PetscViewerBinaryOpen(MPI_Comm,const char[],PetscViewerBinaryType,PetscViewer*);
60b0a32e0cSBarry Smith EXTERN int PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*);
61b0a32e0cSBarry Smith EXTERN int PetscViewerStringOpen(MPI_Comm,char[],int,PetscViewer*);
62b0a32e0cSBarry Smith EXTERN int PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*);
63b0a32e0cSBarry Smith EXTERN int PetscViewerAMSSetCommName(PetscViewer,const char[]);
644b0e389bSBarry Smith 
65b0a32e0cSBarry Smith EXTERN int PetscViewerGetType(PetscViewer,PetscViewerType*);
66b0a32e0cSBarry Smith EXTERN int PetscViewerSetType(PetscViewer,PetscViewerType);
67b0a32e0cSBarry Smith EXTERN int PetscViewerDestroy(PetscViewer);
68b0a32e0cSBarry Smith EXTERN int PetscViewerGetSingleton(PetscViewer,PetscViewer*);
69b0a32e0cSBarry Smith EXTERN int PetscViewerRestoreSingleton(PetscViewer,PetscViewer*);
70ae39576cSLois Curfman McInnes 
71090de74eSSatish Balay 
72*b9617806SBarry Smith /*E
73*b9617806SBarry Smith     PetscViewerFormat - Way a viewer presents the object
74*b9617806SBarry Smith 
75*b9617806SBarry Smith    Level: beginner
76*b9617806SBarry Smith 
77*b9617806SBarry Smith .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat()
78*b9617806SBarry Smith E*/
79fb9695e5SSatish Balay typedef enum {
80f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_DEFAULT,
81f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_MATLAB,
82f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_IMPL,
83f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INFO,
84f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INFO_LONG,
85f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_COMMON,
86f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_SYMMODU,
87f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_INDEX,
88f3ef73ceSBarry Smith   PETSC_VIEWER_ASCII_DENSE,
89f3ef73ceSBarry Smith   PETSC_VIEWER_BINARY_DEFAULT,
90f3ef73ceSBarry Smith   PETSC_VIEWER_BINARY_NATIVE,
91f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_BASIC,
92f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_LG,
93f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_CONTOUR,
94f3ef73ceSBarry Smith   PETSC_VIEWER_DRAW_PORTS,
95f3ef73ceSBarry Smith   PETSC_VIEWER_NATIVE,
96f3ef73ceSBarry Smith   PETSC_VIEWER_NOFORMAT} PetscViewerFormat;
97090de74eSSatish Balay 
98f3ef73ceSBarry Smith EXTERN int PetscViewerSetFormat(PetscViewer,PetscViewerFormat);
99f3ef73ceSBarry Smith EXTERN int PetscViewerPushFormat(PetscViewer,PetscViewerFormat);
100b0a32e0cSBarry Smith EXTERN int PetscViewerPopFormat(PetscViewer);
101f3ef73ceSBarry Smith EXTERN int PetscViewerGetFormat(PetscViewer,PetscViewerFormat*);
102b0a32e0cSBarry Smith EXTERN int PetscViewerFlush(PetscViewer);
1034b0e389bSBarry Smith 
10477ed5343SBarry Smith /*
10577ed5343SBarry Smith    Operations explicit to a particular class of viewers
10677ed5343SBarry Smith */
107b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIGetPointer(PetscViewer,FILE**);
108b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIPrintf(PetscViewer,const char[],...);
109b0a32e0cSBarry Smith EXTERN int PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...);
110b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIPushTab(PetscViewer);
111b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIPopTab(PetscViewer);
112b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIUseTabs(PetscViewer,PetscTruth);
113b0a32e0cSBarry Smith EXTERN int PetscViewerASCIISetTab(PetscViewer,int);
114b0a32e0cSBarry Smith EXTERN int PetscViewerBinaryGetDescriptor(PetscViewer,int*);
115b0a32e0cSBarry Smith EXTERN int PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **);
116b0a32e0cSBarry Smith EXTERN int PetscViewerBinarySetType(PetscViewer,PetscViewerBinaryType);
117b0a32e0cSBarry Smith EXTERN int PetscViewerStringSPrintf(PetscViewer,char *,...);
118b0a32e0cSBarry Smith EXTERN int PetscViewerStringSetString(PetscViewer,char[],int);
119b0a32e0cSBarry Smith EXTERN int PetscViewerDrawClear(PetscViewer);
120b0a32e0cSBarry Smith EXTERN int PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int);
121b0a32e0cSBarry Smith EXTERN int PetscViewerSocketSetConnection(PetscViewer,const char[],int);
122c655490fSBarry Smith 
123b0a32e0cSBarry Smith EXTERN int PetscViewerSetFilename(PetscViewer,const char[]);
124b0a32e0cSBarry Smith EXTERN int PetscViewerGetFilename(PetscViewer,char**);
12577ed5343SBarry Smith 
12677ed5343SBarry Smith /*
12777ed5343SBarry Smith      These are all the default viewers that do not have
12877ed5343SBarry Smith    to be explicitly opened
12977ed5343SBarry Smith */
130b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_STDOUT_(MPI_Comm);
131b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_STDERR_(MPI_Comm);
132b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_DRAW_(MPI_Comm);
133b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_SOCKET_(MPI_Comm);
134b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_BINARY_(MPI_Comm);
1355311e20fSBarry Smith 
136b0a32e0cSBarry Smith #define PETSC_VIEWER_STDOUT_SELF  PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
137b0a32e0cSBarry Smith #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
138b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_SELF  PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
139b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)
140b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_SELF    PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
141b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_WORLD   PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
142b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
143b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_SELF  PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
144b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
145b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_SELF  PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
14665ef3172SBarry Smith 
14777ed5343SBarry Smith /*
148b0a32e0cSBarry Smith     PetscViewer based on the ALICE Memory Snooper
14977ed5343SBarry Smith */
150aa482453SBarry Smith #if defined(PETSC_HAVE_AMS)
151cb5b572fSBarry Smith #include "ams.h"
152b0a32e0cSBarry Smith EXTERN int         PetscViewerAMSGetAMSComm(PetscViewer,AMS_Comm *);
153b0a32e0cSBarry Smith EXTERN int         PetscViewerAMSOpen(MPI_Comm,const char[],PetscViewer*);
154b1607693SBarry Smith EXTERN int         PetscViewerAMSLock(PetscViewer);
155b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_AMS_(MPI_Comm);
156b0a32e0cSBarry Smith EXTERN int         PETSC_VIEWER_AMS_Destroy(MPI_Comm);
157b0a32e0cSBarry Smith #define PETSC_VIEWER_AMS_WORLD PETSC_VIEWER_AMS_(PETSC_COMM_WORLD)
1582eb8c8abSBarry Smith #endif
159cb5b572fSBarry Smith 
160f2b01315SBarry Smith /*
161b0a32e0cSBarry Smith     PetscViewer utility routines used by PETSc that are not normally used
162f2b01315SBarry Smith    by users.
163f2b01315SBarry Smith */
164b0a32e0cSBarry Smith EXTERN int  PetscViewerSocketPutScalar(PetscViewer,int,int,Scalar*);
165b0a32e0cSBarry Smith EXTERN int  PetscViewerSocketPutReal(PetscViewer,int,int,double*);
166b0a32e0cSBarry Smith EXTERN int  PetscViewerSocketPutInt(PetscViewer,int,int*);
167b0a32e0cSBarry Smith EXTERN int  PetscViewerSocketPutSparse_Private(PetscViewer,int,int,int,Scalar*,int*,int *);
168b0a32e0cSBarry Smith EXTERN int  PetscViewerDestroyAMS_Private(void);
169f2b01315SBarry Smith 
170*b9617806SBarry Smith /*S
171*b9617806SBarry Smith      PetscViewers - Abstract collection of PetscViewers
172*b9617806SBarry Smith 
173*b9617806SBarry Smith    Level: intermediate
174*b9617806SBarry Smith 
175*b9617806SBarry Smith   Concepts: viewing
176*b9617806SBarry Smith 
177*b9617806SBarry Smith .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
178*b9617806SBarry Smith            PetscViewersGetViewer()
179*b9617806SBarry Smith S*/
180b0a32e0cSBarry Smith typedef struct _p_PetscViewers* PetscViewers;
181b0a32e0cSBarry Smith EXTERN int PetscViewersCreate(MPI_Comm,PetscViewers*);
182b0a32e0cSBarry Smith EXTERN int PetscViewersDestroy(PetscViewers);
183b0a32e0cSBarry Smith EXTERN int PetscViewersGetViewer(PetscViewers,int,PetscViewer*);
184d132466eSBarry Smith 
185cb5b572fSBarry Smith #endif
186cb5b572fSBarry Smith 
187e7592fafSBarry Smith 
188e7592fafSBarry Smith 
189e7592fafSBarry Smith 
190