1*ca44d042SBarry Smith /* $Id: petscviewer.h,v 1.75 2000/05/08 15:09:50 balay Exp bsmith $ */ 284cb2905SBarry Smith /* 384cb2905SBarry Smith Viewers 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 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; 28*ca44d042SBarry Smith EXTERN int ViewerRegisterAll(char *); 29*ca44d042SBarry Smith EXTERN int ViewerRegisterDestroy(void); 307b2a1423SBarry Smith 31*ca44d042SBarry 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 37*ca44d042SBarry Smith EXTERN int ViewerCreate(MPI_Comm,Viewer*); 38*ca44d042SBarry Smith EXTERN int ViewerSetFromOptions(Viewer); 397b2a1423SBarry Smith 407b2a1423SBarry Smith 41*ca44d042SBarry Smith EXTERN int ViewerASCIIOpen(MPI_Comm,const char[],Viewer*); 424b0e389bSBarry Smith typedef enum {BINARY_RDONLY,BINARY_WRONLY,BINARY_CREATE} ViewerBinaryType; 43*ca44d042SBarry Smith EXTERN int ViewerBinaryOpen(MPI_Comm,const char[],ViewerBinaryType,Viewer*); 44*ca44d042SBarry Smith EXTERN int ViewerSocketOpen(MPI_Comm,const char[],int,Viewer*); 45*ca44d042SBarry Smith EXTERN int ViewerStringOpen(MPI_Comm,char[],int,Viewer*); 46*ca44d042SBarry Smith EXTERN int ViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,Viewer*); 47*ca44d042SBarry Smith EXTERN int ViewerAMSSetCommName(Viewer,const char[]); 484b0e389bSBarry Smith 49*ca44d042SBarry Smith EXTERN int ViewerGetOutputname(Viewer,char**); 50*ca44d042SBarry Smith EXTERN int ViewerGetType(Viewer,ViewerType*); 51*ca44d042SBarry Smith EXTERN int ViewerSetType(Viewer,ViewerType); 52*ca44d042SBarry Smith EXTERN int ViewerDestroy(Viewer); 53*ca44d042SBarry Smith EXTERN int ViewerGetSingleton(Viewer,Viewer*); 54*ca44d042SBarry Smith 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 76*ca44d042SBarry Smith EXTERN int ViewerSetFormat(Viewer,int,char[]); 77*ca44d042SBarry Smith EXTERN int ViewerPushFormat(Viewer,int,char[]); 78*ca44d042SBarry Smith EXTERN int ViewerPopFormat(Viewer); 79*ca44d042SBarry Smith EXTERN int ViewerGetFormat(Viewer,int*); 80*ca44d042SBarry Smith EXTERN int ViewerFlush(Viewer); 814b0e389bSBarry Smith 8277ed5343SBarry Smith /* 8377ed5343SBarry Smith Operations explicit to a particular class of viewers 8477ed5343SBarry Smith */ 85*ca44d042SBarry Smith EXTERN int ViewerASCIIGetPointer(Viewer,FILE**); 86*ca44d042SBarry Smith EXTERN int ViewerASCIIPrintf(Viewer,const char[],...); 87*ca44d042SBarry Smith EXTERN int ViewerASCIISynchronizedPrintf(Viewer,const char[],...); 88*ca44d042SBarry Smith EXTERN int ViewerASCIIPushTab(Viewer); 89*ca44d042SBarry Smith EXTERN int ViewerASCIIPopTab(Viewer); 90*ca44d042SBarry Smith EXTERN int ViewerASCIIUseTabs(Viewer,PetscTruth); 91*ca44d042SBarry Smith EXTERN int ViewerBinaryGetDescriptor(Viewer,int*); 92*ca44d042SBarry Smith EXTERN int ViewerBinaryGetInfoPointer(Viewer,FILE **); 93*ca44d042SBarry Smith EXTERN int ViewerBinarySetType(Viewer,ViewerBinaryType); 94*ca44d042SBarry Smith EXTERN int ViewerStringSPrintf(Viewer,char *,...); 95*ca44d042SBarry Smith EXTERN int ViewerStringSetString(Viewer,char[],int); 96*ca44d042SBarry Smith EXTERN int ViewerDrawClear(Viewer); 97*ca44d042SBarry Smith EXTERN int ViewerDrawSetInfo(Viewer,const char[],const char[],int,int,int,int); 98*ca44d042SBarry Smith EXTERN int ViewerSocketSetConnection(Viewer,const char[],int); 99c655490fSBarry Smith 100*ca44d042SBarry Smith EXTERN int ViewerSetFilename(Viewer,const char[]); 101*ca44d042SBarry 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 */ 107*ca44d042SBarry Smith EXTERN Viewer VIEWER_STDOUT_(MPI_Comm); 108*ca44d042SBarry Smith EXTERN int VIEWER_STDOUT_Destroy(MPI_Comm); 109*ca44d042SBarry Smith EXTERN Viewer VIEWER_STDERR_(MPI_Comm); 110*ca44d042SBarry Smith EXTERN int VIEWER_STDERR_Destroy(MPI_Comm); 111*ca44d042SBarry Smith EXTERN Viewer VIEWER_DRAW_(MPI_Comm); 112*ca44d042SBarry Smith EXTERN int VIEWER_DRAW_Destroy(MPI_Comm); 113*ca44d042SBarry Smith EXTERN Viewer VIEWER_SOCKET_(MPI_Comm); 114*ca44d042SBarry Smith EXTERN int VIEWER_SOCKET_Destroy(MPI_Comm); 1155311e20fSBarry Smith 116e7592fafSBarry Smith #define VIEWER_STDOUT_SELF VIEWER_STDOUT_(PETSC_COMM_SELF) 117e7592fafSBarry Smith #define VIEWER_STDOUT_WORLD VIEWER_STDOUT_(PETSC_COMM_WORLD) 118e7592fafSBarry Smith #define VIEWER_STDERR_SELF VIEWER_STDERR_(PETSC_COMM_SELF) 119e7592fafSBarry Smith #define VIEWER_STDERR_WORLD VIEWER_STDERR_(PETSC_COMM_WORLD) 120639f9d9dSBarry Smith 121e7592fafSBarry Smith #define VIEWER_DRAW_SELF VIEWER_DRAW_(PETSC_COMM_SELF) 122e7592fafSBarry Smith #define VIEWER_DRAW_WORLD VIEWER_DRAW_(PETSC_COMM_WORLD) 123e7592fafSBarry Smith #define VIEWER_SOCKET_WORLD VIEWER_SOCKET_(PETSC_COMM_WORLD) 124e7592fafSBarry Smith #define VIEWER_SOCKET_SELF VIEWER_SOCKET_(PETSC_COMM_SELF) 12577ed5343SBarry Smith /* 12677ed5343SBarry Smith Viewer based on the ALICE Memory Snooper 12777ed5343SBarry Smith */ 128aa482453SBarry Smith #if defined(PETSC_HAVE_AMS) 129cb5b572fSBarry Smith #include "ams.h" 130*ca44d042SBarry Smith EXTERN int ViewerAMSGetAMSComm(Viewer,AMS_Comm *); 131*ca44d042SBarry Smith EXTERN int ViewerAMSOpen(MPI_Comm,const char[],Viewer*); 132*ca44d042SBarry Smith EXTERN Viewer VIEWER_AMS_(MPI_Comm); 133*ca44d042SBarry Smith EXTERN int VIEWER_AMS_Destroy(MPI_Comm); 134e7592fafSBarry Smith #define VIEWER_AMS_WORLD VIEWER_AMS_(PETSC_COMM_WORLD) 1352eb8c8abSBarry Smith #endif 136cb5b572fSBarry Smith 137f2b01315SBarry Smith /* 138f2b01315SBarry Smith Viewer utility routines used by PETSc that are not normally used 139f2b01315SBarry Smith by users. 140f2b01315SBarry Smith */ 141*ca44d042SBarry Smith EXTERN int ViewerSocketPutScalar_Private(Viewer,int,int,Scalar*); 142*ca44d042SBarry Smith EXTERN int ViewerSocketPutReal_Private(Viewer,int,int,double*); 143*ca44d042SBarry Smith EXTERN int ViewerSocketPutInt_Private(Viewer,int,int*); 144*ca44d042SBarry Smith EXTERN int ViewerSocketPutSparse_Private(Viewer,int,int,int,Scalar*,int*,int *); 145e7592fafSBarry Smith 146*ca44d042SBarry Smith EXTERN int ViewerDestroyAMS_Private(void); 147f2b01315SBarry Smith 148d132466eSBarry Smith /* 149d132466eSBarry Smith Manages sets of viewers 150d132466eSBarry Smith */ 151d132466eSBarry Smith typedef struct _p_Viewers* Viewers; 152*ca44d042SBarry Smith EXTERN int ViewersCreate(MPI_Comm,Viewers*); 153*ca44d042SBarry Smith EXTERN int ViewersDestroy(Viewers); 154*ca44d042SBarry Smith EXTERN int ViewersGetViewer(Viewers,int,Viewer*); 155d132466eSBarry Smith 156cb5b572fSBarry Smith #endif 157cb5b572fSBarry Smith 158e7592fafSBarry Smith 159e7592fafSBarry Smith 160e7592fafSBarry Smith 161