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 98ba1e511SMatthew Knepley extern int PETSC_VIEWER_COOKIE; 108ba1e511SMatthew Knepley 11b9617806SBarry Smith /*S 12b9617806SBarry Smith PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc) 13b9617806SBarry Smith other PETSc objects 14b9617806SBarry Smith 15b9617806SBarry Smith Level: beginner 16b9617806SBarry Smith 17b9617806SBarry Smith Concepts: viewing 18b9617806SBarry Smith 19b9617806SBarry Smith .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType 20b9617806SBarry Smith S*/ 21b0a32e0cSBarry Smith typedef struct _p_PetscViewer* PetscViewer; 223c119ea2SBarry Smith 233c119ea2SBarry Smith /* 24b0a32e0cSBarry Smith petsc.h must be included AFTER the definition of PetscViewer for ADIC to 253c119ea2SBarry Smith process correctly. 263c119ea2SBarry Smith */ 272eb8c8abSBarry Smith #include "petsc.h" 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" 4344c73c46SMatthew Knepley #define PETSC_VIEWER_VU "vu" 444ebda54eSMatthew Knepley #define PETSC_VIEWER_MATHEMATICA "mathematica" 454ebda54eSMatthew Knepley #define PETSC_VIEWER_SILO "silo" 46*e3eb5169SDinesh Kaushik #define PETSC_VIEWER_NETCDF "netcdf" 4777ed5343SBarry Smith 48b0a32e0cSBarry Smith extern PetscFList PetscViewerList; 49b0a32e0cSBarry Smith EXTERN int PetscViewerRegisterAll(char *); 50b0a32e0cSBarry Smith EXTERN int PetscViewerRegisterDestroy(void); 517b2a1423SBarry Smith 52b0a32e0cSBarry Smith EXTERN int PetscViewerRegister(char*,char*,char*,int(*)(PetscViewer)); 53aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 54b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0) 557b2a1423SBarry Smith #else 56b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d) 577b2a1423SBarry Smith #endif 58b0a32e0cSBarry Smith EXTERN int PetscViewerCreate(MPI_Comm,PetscViewer*); 59b0a32e0cSBarry Smith EXTERN int PetscViewerSetFromOptions(PetscViewer); 607b2a1423SBarry Smith 61b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*); 62b0a32e0cSBarry Smith typedef enum {PETSC_BINARY_RDONLY,PETSC_BINARY_WRONLY,PETSC_BINARY_CREATE} PetscViewerBinaryType; 63b0a32e0cSBarry Smith EXTERN int PetscViewerBinaryOpen(MPI_Comm,const char[],PetscViewerBinaryType,PetscViewer*); 64b0a32e0cSBarry Smith EXTERN int PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*); 65b0a32e0cSBarry Smith EXTERN int PetscViewerStringOpen(MPI_Comm,char[],int,PetscViewer*); 66b0a32e0cSBarry Smith EXTERN int PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*); 67b0a32e0cSBarry Smith EXTERN int PetscViewerAMSSetCommName(PetscViewer,const char[]); 684ebda54eSMatthew Knepley EXTERN int PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *); 694ebda54eSMatthew Knepley EXTERN int PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *); 704b0e389bSBarry Smith 71b0a32e0cSBarry Smith EXTERN int PetscViewerGetType(PetscViewer,PetscViewerType*); 72b0a32e0cSBarry Smith EXTERN int PetscViewerSetType(PetscViewer,PetscViewerType); 73b0a32e0cSBarry Smith EXTERN int PetscViewerDestroy(PetscViewer); 74b0a32e0cSBarry Smith EXTERN int PetscViewerGetSingleton(PetscViewer,PetscViewer*); 75b0a32e0cSBarry Smith EXTERN int PetscViewerRestoreSingleton(PetscViewer,PetscViewer*); 76ae39576cSLois Curfman McInnes 77090de74eSSatish Balay 78b9617806SBarry Smith /*E 79b9617806SBarry Smith PetscViewerFormat - Way a viewer presents the object 80b9617806SBarry Smith 81b9617806SBarry Smith Level: beginner 82b9617806SBarry Smith 83b9617806SBarry Smith .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat() 84b9617806SBarry Smith E*/ 85fb9695e5SSatish Balay typedef enum { 86f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_DEFAULT, 87f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_MATLAB, 884ebda54eSMatthew Knepley PETSC_VIEWER_ASCII_MATHEMATICA, 89f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_IMPL, 90f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_INFO, 91456192e2SBarry Smith PETSC_VIEWER_ASCII_INFO_DETAIL, 92f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_COMMON, 93f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_SYMMODU, 94f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_INDEX, 95f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_DENSE, 96f3ef73ceSBarry Smith PETSC_VIEWER_BINARY_DEFAULT, 97f3ef73ceSBarry Smith PETSC_VIEWER_BINARY_NATIVE, 98f3ef73ceSBarry Smith PETSC_VIEWER_DRAW_BASIC, 99f3ef73ceSBarry Smith PETSC_VIEWER_DRAW_LG, 100f3ef73ceSBarry Smith PETSC_VIEWER_DRAW_CONTOUR, 101f3ef73ceSBarry Smith PETSC_VIEWER_DRAW_PORTS, 102f3ef73ceSBarry Smith PETSC_VIEWER_NATIVE, 1034aedb280SBarry Smith PETSC_VIEWER_NOFORMAT, 1044aedb280SBarry Smith PETSC_VIEWER_ASCII_FACTOR_INFO} PetscViewerFormat; 105090de74eSSatish Balay 106f3ef73ceSBarry Smith EXTERN int PetscViewerSetFormat(PetscViewer,PetscViewerFormat); 107f3ef73ceSBarry Smith EXTERN int PetscViewerPushFormat(PetscViewer,PetscViewerFormat); 108b0a32e0cSBarry Smith EXTERN int PetscViewerPopFormat(PetscViewer); 109f3ef73ceSBarry Smith EXTERN int PetscViewerGetFormat(PetscViewer,PetscViewerFormat*); 110b0a32e0cSBarry Smith EXTERN int PetscViewerFlush(PetscViewer); 1114b0e389bSBarry Smith 11277ed5343SBarry Smith /* 11377ed5343SBarry Smith Operations explicit to a particular class of viewers 11477ed5343SBarry Smith */ 115ed5c6e3eSMatthew Knepley 116ed5c6e3eSMatthew Knepley /*E 117ed5c6e3eSMatthew Knepley PetscViewerFormat - Access mode for a file. 118ed5c6e3eSMatthew Knepley 119ed5c6e3eSMatthew Knepley Level: beginner 120ed5c6e3eSMatthew Knepley 121ed5c6e3eSMatthew Knepley .seealso: PetscViewerASCIISetMode() 122ed5c6e3eSMatthew Knepley E*/ 123ed5c6e3eSMatthew Knepley typedef enum {FILE_MODE_READ, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode; 124ed5c6e3eSMatthew Knepley 125b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIGetPointer(PetscViewer,FILE**); 126ed5c6e3eSMatthew Knepley EXTERN int PetscViewerASCIISetMode(PetscViewer,PetscFileMode); 127f80b7eb0SBarry Smith EXTERN int PetscViewerASCIIPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 128f80b7eb0SBarry Smith EXTERN int PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 129b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIPushTab(PetscViewer); 130b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIPopTab(PetscViewer); 131b0a32e0cSBarry Smith EXTERN int PetscViewerASCIIUseTabs(PetscViewer,PetscTruth); 132b0a32e0cSBarry Smith EXTERN int PetscViewerASCIISetTab(PetscViewer,int); 133b0a32e0cSBarry Smith EXTERN int PetscViewerBinaryGetDescriptor(PetscViewer,int*); 134b0a32e0cSBarry Smith EXTERN int PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **); 135b0a32e0cSBarry Smith EXTERN int PetscViewerBinarySetType(PetscViewer,PetscViewerBinaryType); 136f80b7eb0SBarry Smith EXTERN int PetscViewerStringSPrintf(PetscViewer,char *,...) PETSC_PRINTF_FORMAT_CHECK(2,3); 137b0a32e0cSBarry Smith EXTERN int PetscViewerStringSetString(PetscViewer,char[],int); 138b0a32e0cSBarry Smith EXTERN int PetscViewerDrawClear(PetscViewer); 139b0a32e0cSBarry Smith EXTERN int PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int); 140b0a32e0cSBarry Smith EXTERN int PetscViewerSocketSetConnection(PetscViewer,const char[],int); 141bba1ac68SSatish Balay EXTERN int PetscViewerBinarySkipInfo(PetscViewer); 14208641331SSatish Balay EXTERN int PetscViewerBinaryLoadInfo(PetscViewer); 14308641331SSatish Balay 144c655490fSBarry Smith 145b0a32e0cSBarry Smith EXTERN int PetscViewerSetFilename(PetscViewer,const char[]); 146b0a32e0cSBarry Smith EXTERN int PetscViewerGetFilename(PetscViewer,char**); 14777ed5343SBarry Smith 14844c6da4fSMatthew Knepley EXTERN int PetscPLAPACKInitializePackage(char *); 14965804fbbSSatish Balay EXTERN int PetscPLAPACKFinalizePackage(void); 15044c6da4fSMatthew Knepley 15155dcf840SMatthew Knepley EXTERN int PetscViewerVUGetPointer(PetscViewer, FILE**); 152c4b95c56SMatthew Knepley EXTERN int PetscViewerVUSetMode(PetscViewer, PetscFileMode); 153c4b95c56SMatthew Knepley EXTERN int PetscViewerVUSetVecSeen(PetscViewer, PetscTruth); 154c4b95c56SMatthew Knepley EXTERN int PetscViewerVUGetVecSeen(PetscViewer, PetscTruth *); 155f80b7eb0SBarry Smith EXTERN int PetscViewerVUPrintDeferred(PetscViewer, const char [], ...) PETSC_PRINTF_FORMAT_CHECK(2,3); 156c4b95c56SMatthew Knepley EXTERN int PetscViewerVUFlushDeferred(PetscViewer); 15755dcf840SMatthew Knepley 15844c6da4fSMatthew Knepley EXTERN int PetscViewerMathematicaInitializePackage(char *); 15986e45947SSatish Balay EXTERN int PetscViewerMathematicaFinalizePackage(void); 160918c3ce8SMatthew Knepley EXTERN int PetscViewerMathematicaGetName(PetscViewer, const char **); 1617eb62a3eSMatthew Knepley EXTERN int PetscViewerMathematicaSetName(PetscViewer, const char []); 1627eb62a3eSMatthew Knepley EXTERN int PetscViewerMathematicaClearName(PetscViewer); 1637eb62a3eSMatthew Knepley EXTERN int PetscViewerMathematicaSkipPackets(PetscViewer, int); 1644ebda54eSMatthew Knepley 1657eb62a3eSMatthew Knepley EXTERN int PetscViewerSiloGetName(PetscViewer, char **); 1667eb62a3eSMatthew Knepley EXTERN int PetscViewerSiloSetName(PetscViewer, const char []); 1677eb62a3eSMatthew Knepley EXTERN int PetscViewerSiloClearName(PetscViewer); 1687eb62a3eSMatthew Knepley EXTERN int PetscViewerSiloGetMeshName(PetscViewer, char **); 1697eb62a3eSMatthew Knepley EXTERN int PetscViewerSiloSetMeshName(PetscViewer, const char []); 1707eb62a3eSMatthew Knepley EXTERN int PetscViewerSiloClearMeshName(PetscViewer); 1714ebda54eSMatthew Knepley 172*e3eb5169SDinesh Kaushik typedef enum {PETSC_NETCDF_RDONLY,PETSC_NETCDF_RDWR,PETSC_NETCDF_CREATE} PetscViewerNetcdfType; 173*e3eb5169SDinesh Kaushik EXTERN int PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscViewerNetcdfType,PetscViewer*); 174*e3eb5169SDinesh Kaushik EXTERN int PetscViewerNetcdfGetID(PetscViewer, int *); 175*e3eb5169SDinesh Kaushik 17677ed5343SBarry Smith /* 17777ed5343SBarry Smith These are all the default viewers that do not have 17877ed5343SBarry Smith to be explicitly opened 17977ed5343SBarry Smith */ 180b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_STDOUT_(MPI_Comm); 181b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_STDERR_(MPI_Comm); 182b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_DRAW_(MPI_Comm); 183b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_SOCKET_(MPI_Comm); 184b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_BINARY_(MPI_Comm); 1857eb62a3eSMatthew Knepley EXTERN PetscViewer PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE; 1865311e20fSBarry Smith 187b0a32e0cSBarry Smith #define PETSC_VIEWER_STDOUT_SELF PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF) 188b0a32e0cSBarry Smith #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD) 189b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_SELF PETSC_VIEWER_STDERR_(PETSC_COMM_SELF) 190b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD) 191b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_SELF PETSC_VIEWER_DRAW_(PETSC_COMM_SELF) 192b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_WORLD PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD) 193b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD) 194b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_SELF PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF) 195b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD) 196b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_SELF PETSC_VIEWER_BINARY_(PETSC_COMM_SELF) 1977eb62a3eSMatthew Knepley #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE) 19865ef3172SBarry Smith 19977ed5343SBarry Smith /* 200b0a32e0cSBarry Smith PetscViewer based on the ALICE Memory Snooper 20177ed5343SBarry Smith */ 202aa482453SBarry Smith #if defined(PETSC_HAVE_AMS) 203cb5b572fSBarry Smith #include "ams.h" 204b0a32e0cSBarry Smith EXTERN int PetscViewerAMSGetAMSComm(PetscViewer,AMS_Comm *); 205b0a32e0cSBarry Smith EXTERN int PetscViewerAMSOpen(MPI_Comm,const char[],PetscViewer*); 206b1607693SBarry Smith EXTERN int PetscViewerAMSLock(PetscViewer); 207b0a32e0cSBarry Smith EXTERN PetscViewer PETSC_VIEWER_AMS_(MPI_Comm); 208b0a32e0cSBarry Smith EXTERN int PETSC_VIEWER_AMS_Destroy(MPI_Comm); 209b0a32e0cSBarry Smith #define PETSC_VIEWER_AMS_WORLD PETSC_VIEWER_AMS_(PETSC_COMM_WORLD) 2102eb8c8abSBarry Smith #endif 211cb5b572fSBarry Smith 212f2b01315SBarry Smith /* 213b0a32e0cSBarry Smith PetscViewer utility routines used by PETSc that are not normally used 214f2b01315SBarry Smith by users. 215f2b01315SBarry Smith */ 21687828ca2SBarry Smith EXTERN int PetscViewerSocketPutScalar(PetscViewer,int,int,PetscScalar*); 21787828ca2SBarry Smith EXTERN int PetscViewerSocketPutReal(PetscViewer,int,int,PetscReal*); 218b0a32e0cSBarry Smith EXTERN int PetscViewerSocketPutInt(PetscViewer,int,int*); 21987828ca2SBarry Smith EXTERN int PetscViewerSocketPutSparse_Private(PetscViewer,int,int,int,PetscScalar*,int*,int *); 220b0a32e0cSBarry Smith EXTERN int PetscViewerDestroyAMS_Private(void); 221f2b01315SBarry Smith 222b9617806SBarry Smith /*S 223b9617806SBarry Smith PetscViewers - Abstract collection of PetscViewers 224b9617806SBarry Smith 225b9617806SBarry Smith Level: intermediate 226b9617806SBarry Smith 227b9617806SBarry Smith Concepts: viewing 228b9617806SBarry Smith 229b9617806SBarry Smith .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(), 230b9617806SBarry Smith PetscViewersGetViewer() 231b9617806SBarry Smith S*/ 232b0a32e0cSBarry Smith typedef struct _p_PetscViewers* PetscViewers; 233b0a32e0cSBarry Smith EXTERN int PetscViewersCreate(MPI_Comm,PetscViewers*); 234b0a32e0cSBarry Smith EXTERN int PetscViewersDestroy(PetscViewers); 235b0a32e0cSBarry Smith EXTERN int PetscViewersGetViewer(PetscViewers,int,PetscViewer*); 236d132466eSBarry Smith 237cb5b572fSBarry Smith #endif 238