1*329f5518SBarry Smith /* $Id: viewer.h,v 1.72 1999/11/24 21:55:57 bsmith Exp bsmith $ */ 284cb2905SBarry Smith /* 384cb2905SBarry Smith Viewers are objects where other objects can be looked at or stored. 484cb2905SBarry Smith */ 53c119ea2SBarry Smith 688d459dfSBarry Smith #if !defined(__VIEWER_H) 788d459dfSBarry Smith #define __VIEWER_H 82eb8c8abSBarry Smith 9f09e8eb9SSatish Balay typedef struct _p_Viewer* Viewer; 103c119ea2SBarry Smith 113c119ea2SBarry Smith /* 123c119ea2SBarry Smith petsc.h must be included AFTER the definition of Viewer for ADIC to 133c119ea2SBarry Smith process correctly. 143c119ea2SBarry Smith */ 152eb8c8abSBarry Smith #include "petsc.h" 162eb8c8abSBarry Smith 172eb8c8abSBarry Smith #define VIEWER_COOKIE PETSC_COOKIE+1 1877ed5343SBarry Smith typedef char* ViewerType; 192eb8c8abSBarry Smith 207b2a1423SBarry Smith #define SOCKET_VIEWER "socket" 2177ed5343SBarry Smith #define ASCII_VIEWER "ascii" 2277ed5343SBarry Smith #define BINARY_VIEWER "binary" 2377ed5343SBarry Smith #define STRING_VIEWER "string" 2477ed5343SBarry Smith #define DRAW_VIEWER "draw" 2577ed5343SBarry Smith #define AMS_VIEWER "ams" 2677ed5343SBarry Smith 277b2a1423SBarry Smith extern FList ViewerList; 287b2a1423SBarry Smith extern int ViewerRegisterAll(char *); 297b2a1423SBarry Smith extern int ViewerRegisterDestroy(void); 307b2a1423SBarry Smith 31f1af5d2fSBarry Smith extern int ViewerRegister(char*,char*,char*,int(*)(Viewer)); 32aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 33f1af5d2fSBarry Smith #define ViewerRegisterDynamic(a,b,c,d) ViewerRegister(a,b,c,0) 347b2a1423SBarry Smith #else 35f1af5d2fSBarry Smith #define ViewerRegisterDynamic(a,b,c,d) ViewerRegister(a,b,c,d) 367b2a1423SBarry Smith #endif 377b2a1423SBarry Smith extern int ViewerCreate(MPI_Comm,Viewer*); 387b2a1423SBarry Smith extern int ViewerSetFromOptions(Viewer); 397b2a1423SBarry Smith 407b2a1423SBarry Smith 4177ed5343SBarry Smith extern int ViewerASCIIOpen(MPI_Comm,const char[],Viewer*); 424b0e389bSBarry Smith typedef enum {BINARY_RDONLY,BINARY_WRONLY,BINARY_CREATE} ViewerBinaryType; 4377ed5343SBarry Smith extern int ViewerBinaryOpen(MPI_Comm,const char[],ViewerBinaryType,Viewer*); 447b2a1423SBarry Smith extern int ViewerSocketOpen(MPI_Comm,const char[],int,Viewer*); 45e26ad7d8SSatish Balay extern int ViewerStringOpen(MPI_Comm,char[],int,Viewer*); 4677ed5343SBarry Smith extern int ViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,Viewer*); 475ef9f2a5SBarry Smith extern int ViewerAMSSetCommName(Viewer,const char[]); 484b0e389bSBarry Smith 4977ed5343SBarry Smith extern int ViewerGetOutputname(Viewer,char**); 50bcd2baecSBarry Smith extern int ViewerGetType(Viewer,ViewerType*); 517b2a1423SBarry Smith extern int ViewerSetType(Viewer,ViewerType); 529651b370SBarry Smith extern int ViewerDestroy(Viewer); 5356bb596eSSatish Balay extern int ViewerGetSingleton(Viewer,Viewer*); 5456bb596eSSatish Balay extern int ViewerRestoreSingleton(Viewer,Viewer*); 55ae39576cSLois Curfman McInnes 56639f9d9dSBarry Smith #define VIEWER_FORMAT_ASCII_DEFAULT 0 57639f9d9dSBarry Smith #define VIEWER_FORMAT_ASCII_MATLAB 1 58639f9d9dSBarry Smith #define VIEWER_FORMAT_ASCII_IMPL 2 59639f9d9dSBarry Smith #define VIEWER_FORMAT_ASCII_INFO 3 60639f9d9dSBarry Smith #define VIEWER_FORMAT_ASCII_INFO_LONG 4 61639f9d9dSBarry Smith #define VIEWER_FORMAT_ASCII_COMMON 5 6209b0ea9bSLois Curfman McInnes #define VIEWER_FORMAT_ASCII_SYMMODU 6 6347e7184fSBarry Smith #define VIEWER_FORMAT_ASCII_INDEX 7 64e24b481bSBarry Smith #define VIEWER_FORMAT_ASCII_DENSE 8 65090de74eSSatish Balay 665a655dc6SBarry Smith #define VIEWER_FORMAT_BINARY_DEFAULT 9 675a655dc6SBarry Smith #define VIEWER_FORMAT_BINARY_NATIVE 10 68090de74eSSatish Balay 695a655dc6SBarry Smith #define VIEWER_FORMAT_DRAW_BASIC 11 705a655dc6SBarry Smith #define VIEWER_FORMAT_DRAW_LG 12 715a655dc6SBarry Smith #define VIEWER_FORMAT_DRAW_CONTOUR 13 727c922b88SBarry Smith #define VIEWER_FORMAT_DRAW_PORTS 15 735a655dc6SBarry Smith 745a655dc6SBarry Smith #define VIEWER_FORMAT_NATIVE 14 755311e20fSBarry Smith 76e26ad7d8SSatish Balay extern int ViewerSetFormat(Viewer,int,char[]); 77e26ad7d8SSatish Balay extern int ViewerPushFormat(Viewer,int,char[]); 785311e20fSBarry Smith extern int ViewerPopFormat(Viewer); 7990ace30eSBarry Smith extern int ViewerGetFormat(Viewer,int*); 805fe861cdSBarry Smith extern int ViewerFlush(Viewer); 814b0e389bSBarry Smith 8277ed5343SBarry Smith /* 8377ed5343SBarry Smith Operations explicit to a particular class of viewers 8477ed5343SBarry Smith */ 8577ed5343SBarry Smith extern int ViewerASCIIGetPointer(Viewer,FILE**); 860ef38995SBarry Smith extern int ViewerASCIIPrintf(Viewer,const char[],...); 8756bb596eSSatish Balay extern int ViewerASCIISynchronizedPrintf(Viewer,const char[],...); 880ef38995SBarry Smith extern int ViewerASCIIPushTab(Viewer); 890ef38995SBarry Smith extern int ViewerASCIIPopTab(Viewer); 9056bb596eSSatish Balay extern int ViewerASCIIUseTabs(Viewer,PetscTruth); 9177ed5343SBarry Smith extern int ViewerBinaryGetDescriptor(Viewer,int*); 9277ed5343SBarry Smith extern int ViewerBinaryGetInfoPointer(Viewer,FILE **); 93c655490fSBarry Smith extern int ViewerBinarySetType(Viewer,ViewerBinaryType); 9477ed5343SBarry Smith extern int ViewerStringSPrintf(Viewer,char *,...); 95c655490fSBarry Smith extern int ViewerStringSetString(Viewer,char[],int); 9677ed5343SBarry Smith extern int ViewerDrawClear(Viewer); 97c655490fSBarry Smith extern int ViewerDrawSetInfo(Viewer,const char[],const char[],int,int,int,int); 9826fae399SBarry Smith extern int ViewerSocketSetConnection(Viewer,const char[],int); 99c655490fSBarry Smith 100c655490fSBarry Smith extern int ViewerSetFilename(Viewer,const char[]); 1017c922b88SBarry Smith extern int ViewerGetFilename(Viewer,char**); 10277ed5343SBarry Smith 10377ed5343SBarry Smith /* 10477ed5343SBarry Smith These are all the default viewers that do not have 10577ed5343SBarry Smith to be explicitly opened 10677ed5343SBarry Smith */ 1076d4a8577SBarry Smith extern Viewer VIEWER_STDOUT_SELF; 1086d4a8577SBarry Smith extern Viewer VIEWER_STDERR_SELF; 10925482d47SBarry Smith extern Viewer VIEWER_STDOUT_WORLD; 1100752156aSBarry Smith extern Viewer VIEWER_STDOUT_(MPI_Comm); 1110752156aSBarry Smith extern int VIEWER_STDOUT_Destroy(MPI_Comm); 112c22c1629SBarry Smith extern Viewer VIEWER_STDERR_WORLD; 1130752156aSBarry Smith extern Viewer VIEWER_STDERR_(MPI_Comm); 1140752156aSBarry Smith extern int VIEWER_STDERR_Destroy(MPI_Comm); 115c655490fSBarry Smith extern Viewer VIEWER_DRAW_WORLD_PRIVATE_0; 116c655490fSBarry Smith extern Viewer VIEWER_DRAW_WORLD_PRIVATE_1; 117c655490fSBarry Smith extern Viewer VIEWER_DRAW_WORLD_PRIVATE_2; 118c655490fSBarry Smith extern Viewer VIEWER_DRAW_SELF_PRIVATE; 1197b2a1423SBarry Smith extern Viewer VIEWER_SOCKET_WORLD_PRIVATE; 1207b2a1423SBarry Smith extern Viewer VIEWER_SOCKET_SELF_PRIVATE; /* not yet used */ 1215311e20fSBarry Smith 122f4d8af11SBarry Smith extern int ViewerInitializeDrawWorld_Private_0(void); 123f4d8af11SBarry Smith extern int ViewerInitializeDrawWorld_Private_1(void); 124f4d8af11SBarry Smith extern int ViewerInitializeDrawWorld_Private_2(void); 125f4d8af11SBarry Smith extern int ViewerInitializeDrawSelf_Private(void); 1267b2a1423SBarry Smith extern int ViewerInitializeSocketWorld_Private(void); 127c655490fSBarry Smith extern Viewer VIEWER_DRAW_(MPI_Comm); 128c655490fSBarry Smith extern int VIEWER_DRAW_Destroy(MPI_Comm); 129c655490fSBarry Smith extern Viewer VIEWER_SOCKET_(MPI_Comm); 130c655490fSBarry Smith extern int VIEWER_SOCKET_Destroy(MPI_Comm); 1315311e20fSBarry Smith 132c655490fSBarry Smith #define VIEWER_DRAW_WORLD_0 \ 133f4d8af11SBarry Smith (ViewerInitializeDrawWorld_Private_0(),VIEWER_DRAW_WORLD_PRIVATE_0) 134c655490fSBarry Smith #define VIEWER_DRAW_WORLD_1 \ 135f4d8af11SBarry Smith (ViewerInitializeDrawWorld_Private_1(),VIEWER_DRAW_WORLD_PRIVATE_1) 136c655490fSBarry Smith #define VIEWER_DRAW_WORLD_2 \ 137f4d8af11SBarry Smith (ViewerInitializeDrawWorld_Private_2(),VIEWER_DRAW_WORLD_PRIVATE_2) 138639f9d9dSBarry Smith 139c655490fSBarry Smith #define VIEWER_DRAW_SELF \ 140f4d8af11SBarry Smith (ViewerInitializeDrawSelf_Private(),VIEWER_DRAW_SELF_PRIVATE) 141c655490fSBarry Smith #define VIEWER_DRAW_WORLD VIEWER_DRAW_WORLD_0 142e1311b90SBarry Smith 1437b2a1423SBarry Smith #define VIEWER_SOCKET_WORLD \ 1447b2a1423SBarry Smith (ViewerInitializeSocketWorld_Private(),VIEWER_SOCKET_WORLD_PRIVATE) 145c16cb8f2SBarry Smith 14677ed5343SBarry Smith /* 14777ed5343SBarry Smith Viewer based on the ALICE Memory Snooper 14877ed5343SBarry Smith */ 149aa482453SBarry Smith #if defined(PETSC_HAVE_AMS) 150cb5b572fSBarry Smith #include "ams.h" 151cb5b572fSBarry Smith extern int ViewerAMSGetAMSComm(Viewer,AMS_Comm *); 152cb5b572fSBarry Smith extern int ViewerAMSOpen(MPI_Comm,const char[],Viewer*); 153cb5b572fSBarry Smith extern Viewer VIEWER_AMS_(MPI_Comm); 154cb5b572fSBarry Smith extern int VIEWER_AMS_Destroy(MPI_Comm); 155cb5b572fSBarry Smith extern Viewer VIEWER_AMS_WORLD_PRIVATE; 156cb5b572fSBarry Smith extern int ViewerInitializeAMSWorld_Private(void); 157cb5b572fSBarry Smith #define VIEWER_AMS_WORLD (ViewerInitializeAMSWorld_Private(),VIEWER_AMS_WORLD_PRIVATE) 1582eb8c8abSBarry Smith #endif 159cb5b572fSBarry Smith 160f2b01315SBarry Smith /* 161f2b01315SBarry Smith Viewer utility routines used by PETSc that are not normally used 162f2b01315SBarry Smith by users. 163f2b01315SBarry Smith */ 1647b2a1423SBarry Smith extern int ViewerSocketPutScalar_Private(Viewer,int,int,Scalar*); 165*329f5518SBarry Smith extern int ViewerSocketPutReal_Private(Viewer,int,int,double*); 1667b2a1423SBarry Smith extern int ViewerSocketPutInt_Private(Viewer,int,int*); 1677b2a1423SBarry Smith extern int ViewerSocketPutSparse_Private(Viewer,int,int,int,Scalar*,int*,int *); 168f2b01315SBarry Smith extern int ViewerInitializeASCII_Private(void); 169f2b01315SBarry Smith extern int ViewerDestroyASCII_Private(void); 170f4d8af11SBarry Smith extern int ViewerDestroyDraw_Private(void); 1717b2a1423SBarry Smith extern int ViewerDestroySocket_Private(void); 172f2b01315SBarry Smith extern int ViewerDestroyAMS_Private(void); 173f2b01315SBarry Smith 174d132466eSBarry Smith /* 175d132466eSBarry Smith Manages sets of viewers 176d132466eSBarry Smith */ 177d132466eSBarry Smith typedef struct _p_Viewers* Viewers; 178d132466eSBarry Smith extern int ViewersCreate(MPI_Comm,Viewers*); 179d132466eSBarry Smith extern int ViewersDestroy(Viewers); 180d132466eSBarry Smith extern int ViewersGetViewer(Viewers,int,Viewer*); 181d132466eSBarry Smith 182cb5b572fSBarry Smith #endif 183cb5b572fSBarry Smith 184