184cb2905SBarry Smith /* 2b0a32e0cSBarry Smith PetscViewers are objects where other objects can be looked at or stored. 384cb2905SBarry Smith */ 43c119ea2SBarry Smith 50a835dfdSSatish Balay #if !defined(__PETSCVIEWER_H) 60a835dfdSSatish Balay #define __PETSCVIEWER_H 7dfbe8321SBarry Smith 8*6420c192SJed Brown #include <petscsys.h> 9*6420c192SJed Brown 10e9fa29b7SSatish Balay #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus) 11e9fa29b7SSatish Balay extern "C" { 12e9fa29b7SSatish Balay #endif 132eb8c8abSBarry Smith 14b9617806SBarry Smith /*S 15b9617806SBarry Smith PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc) 16b9617806SBarry Smith other PETSc objects 17b9617806SBarry Smith 18b9617806SBarry Smith Level: beginner 19b9617806SBarry Smith 20b9617806SBarry Smith Concepts: viewing 21b9617806SBarry Smith 22b9617806SBarry Smith .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType 23b9617806SBarry Smith S*/ 24b0a32e0cSBarry Smith typedef struct _p_PetscViewer* PetscViewer; 253c119ea2SBarry Smith 26e9fa29b7SSatish Balay #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus) 27e9fa29b7SSatish Balay } 28e9fa29b7SSatish Balay #endif 29e9fa29b7SSatish Balay 30014dd563SJed Brown PETSC_EXTERN PetscClassId PETSC_VIEWER_CLASSID; 31e9fa29b7SSatish Balay 3276bdecfbSBarry Smith /*J 33b9617806SBarry Smith PetscViewerType - String with the name of a PETSc PETScViewer 34b9617806SBarry Smith 35b9617806SBarry Smith Level: beginner 36b9617806SBarry Smith 37b9617806SBarry Smith .seealso: PetscViewerSetType(), PetscViewer 3876bdecfbSBarry Smith J*/ 3919fd82e9SBarry Smith typedef const char* PetscViewerType; 402692d6eeSBarry Smith #define PETSCVIEWERSOCKET "socket" 412692d6eeSBarry Smith #define PETSCVIEWERASCII "ascii" 422692d6eeSBarry Smith #define PETSCVIEWERBINARY "binary" 432692d6eeSBarry Smith #define PETSCVIEWERSTRING "string" 442692d6eeSBarry Smith #define PETSCVIEWERDRAW "draw" 452692d6eeSBarry Smith #define PETSCVIEWERVU "vu" 462692d6eeSBarry Smith #define PETSCVIEWERMATHEMATICA "mathematica" 472692d6eeSBarry Smith #define PETSCVIEWERNETCDF "netcdf" 482692d6eeSBarry Smith #define PETSCVIEWERHDF5 "hdf5" 494061b8bfSJed Brown #define PETSCVIEWERVTK "vtk" 502692d6eeSBarry Smith #define PETSCVIEWERMATLAB "matlab" 51b3506946SBarry Smith #define PETSCVIEWERAMS "ams" 5277ed5343SBarry Smith 53140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList PetscViewerList; 54014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRegisterAll(const char *); 55014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRegisterDestroy(void); 56014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerInitializePackage(const char[]); 577b2a1423SBarry Smith 58014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRegister(const char*,const char*,const char*,PetscErrorCode (*)(PetscViewer)); 5930de9b25SBarry Smith 6030de9b25SBarry Smith /*MC 6192c97de8SJed Brown PetscViewerRegisterDynamic - Adds a viewer 6230de9b25SBarry Smith 63f2ba6396SBarry Smith Synopsis 64f2ba6396SBarry Smith #include "petscviewer.h" 651890ba74SBarry Smith PetscErrorCode PetscViewerRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(PetscViewer)) 6630de9b25SBarry Smith 6730de9b25SBarry Smith Not Collective 6830de9b25SBarry Smith 6930de9b25SBarry Smith Input Parameters: 7092c97de8SJed Brown + name_solver - name of a new user-defined viewer 7192c97de8SJed Brown . path - path (either absolute or relative) the library containing this viewer 7230de9b25SBarry Smith . name_create - name of routine to create method context 7330de9b25SBarry Smith - routine_create - routine to create method context 7430de9b25SBarry Smith 7530de9b25SBarry Smith Level: developer 7630de9b25SBarry Smith 7730de9b25SBarry Smith Notes: 7892c97de8SJed Brown PetscViewerRegisterDynamic() may be called multiple times to add several user-defined viewers. 7930de9b25SBarry Smith 8030de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (routine_create) 8130de9b25SBarry Smith is ignored. 8230de9b25SBarry Smith 8330de9b25SBarry Smith Sample usage: 8430de9b25SBarry Smith .vb 8530de9b25SBarry Smith PetscViewerRegisterDynamic("my_viewer_type",/home/username/my_lib/lib/libO/solaris/mylib.a, 8630de9b25SBarry Smith "MyViewerCreate",MyViewerCreate); 8730de9b25SBarry Smith .ve 8830de9b25SBarry Smith 8930de9b25SBarry Smith Then, your solver can be chosen with the procedural interface via 9092c97de8SJed Brown $ PetscViewerSetType(viewer,"my_viewer_type") 9130de9b25SBarry Smith or at runtime via the option 9230de9b25SBarry Smith $ -viewer_type my_viewer_type 9330de9b25SBarry Smith 9430de9b25SBarry Smith Concepts: registering^Viewers 9530de9b25SBarry Smith 9630de9b25SBarry Smith .seealso: PetscViewerRegisterAll(), PetscViewerRegisterDestroy() 9730de9b25SBarry Smith M*/ 98aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 99b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0) 1007b2a1423SBarry Smith #else 101b0a32e0cSBarry Smith #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d) 1027b2a1423SBarry Smith #endif 10330de9b25SBarry Smith 104014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerCreate(MPI_Comm,PetscViewer*); 105014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetFromOptions(PetscViewer); 106014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpenWithFILE(MPI_Comm,FILE*,PetscViewer*); 1077b2a1423SBarry Smith 108014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*); 109014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISetFILE(PetscViewer,FILE*); 110014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 111014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetFlowControl(PetscViewer,PetscInt*); 112014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetFlowControl(PetscViewer,PetscInt); 113014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetMPIIO(PetscViewer); 114014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIO(PetscViewer,PetscBool *); 1150fc9d207SBarry Smith #if defined(PETSC_HAVE_MPIIO) 116014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIODescriptor(PetscViewer,MPI_File*); 117014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIOOffset(PetscViewer,MPI_Offset*); 118014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryAddMPIIOOffset(PetscViewer,MPI_Offset); 119951e3c8eSBarry Smith #endif 12039802e9eSBarry Smith 121014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*); 122014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerStringOpen(MPI_Comm,char[],PetscInt,PetscViewer*); 123014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*); 124014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *); 125014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *); 126014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 1274b0e389bSBarry Smith 12819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerGetType(PetscViewer,PetscViewerType*); 12919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerSetType(PetscViewer,PetscViewerType); 130014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDestroy(PetscViewer*); 131014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetSingleton(PetscViewer,PetscViewer*); 132014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRestoreSingleton(PetscViewer,PetscViewer*); 133014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetSubcomm(PetscViewer,MPI_Comm,PetscViewer*); 134014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerRestoreSubcomm(PetscViewer,MPI_Comm,PetscViewer*); 135ae39576cSLois Curfman McInnes 136014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetUp(PetscViewer); 137014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerView(PetscViewer,PetscViewer); 138f69a0ea3SMatthew Knepley 139014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer,const char[]); 140014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer,const char[]); 141014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer,const char*[]); 142090de74eSSatish Balay 143b9617806SBarry Smith /*E 144b9617806SBarry Smith PetscViewerFormat - Way a viewer presents the object 145b9617806SBarry Smith 146b9617806SBarry Smith Level: beginner 147b9617806SBarry Smith 148cfaaf4edSHong Zhang The values below are also listed in finclude/petscviewer.h. If another values is added below it 149cfaaf4edSHong Zhang must also be added there. 150cfaaf4edSHong Zhang 151b9617806SBarry Smith .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat() 152b9617806SBarry Smith E*/ 153fb9695e5SSatish Balay typedef enum { 154117016b1SBarry Smith PETSC_VIEWER_DEFAULT, 155f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_MATLAB, 1564ebda54eSMatthew Knepley PETSC_VIEWER_ASCII_MATHEMATICA, 157f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_IMPL, 158f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_INFO, 159456192e2SBarry Smith PETSC_VIEWER_ASCII_INFO_DETAIL, 160f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_COMMON, 161f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_SYMMODU, 162f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_INDEX, 163f3ef73ceSBarry Smith PETSC_VIEWER_ASCII_DENSE, 1643c215bfdSMatthew Knepley PETSC_VIEWER_ASCII_MATRIXMARKET, 165a505fa5bSMatthew Knepley PETSC_VIEWER_ASCII_VTK, 166b85befe5SMatthew Knepley PETSC_VIEWER_ASCII_VTK_CELL, 167b6d733afSMatthew Knepley PETSC_VIEWER_ASCII_VTK_COORDS, 168493617b5SMatthew Knepley PETSC_VIEWER_ASCII_PCICE, 169cfaaf4edSHong Zhang PETSC_VIEWER_ASCII_PYTHON, 170cfaaf4edSHong Zhang PETSC_VIEWER_ASCII_FACTOR_INFO, 17167ad5babSMatthew G Knepley PETSC_VIEWER_ASCII_LATEX, 172f3ef73ceSBarry Smith PETSC_VIEWER_DRAW_BASIC, 173f3ef73ceSBarry Smith PETSC_VIEWER_DRAW_LG, 174f3ef73ceSBarry Smith PETSC_VIEWER_DRAW_CONTOUR, 175f3ef73ceSBarry Smith PETSC_VIEWER_DRAW_PORTS, 1764061b8bfSJed Brown PETSC_VIEWER_VTK_VTS, 177b263465dSJed Brown PETSC_VIEWER_VTK_VTU, 178a261c58fSBarry Smith PETSC_VIEWER_BINARY_MATLAB, 179f3ef73ceSBarry Smith PETSC_VIEWER_NATIVE, 180cfaaf4edSHong Zhang PETSC_VIEWER_NOFORMAT 181cfaaf4edSHong Zhang } PetscViewerFormat; 182014dd563SJed Brown PETSC_EXTERN const char *const PetscViewerFormats[]; 183090de74eSSatish Balay 184014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSetFormat(PetscViewer,PetscViewerFormat); 185014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerPushFormat(PetscViewer,PetscViewerFormat); 186014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerPopFormat(PetscViewer); 187014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerGetFormat(PetscViewer,PetscViewerFormat*); 188014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFlush(PetscViewer); 1894b0e389bSBarry Smith 190cffb1e40SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetViewer(MPI_Comm,const char[],const char[],PetscViewer*,PetscViewerFormat*,PetscBool*); 191cffb1e40SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsViewer(const char[],const char[],const char[],PetscViewer*,PetscViewerFormat *,PetscBool *); 1922bf49c77SBarry Smith 19377ed5343SBarry Smith /* 19477ed5343SBarry Smith Operations explicit to a particular class of viewers 19577ed5343SBarry Smith */ 196ed5c6e3eSMatthew Knepley 197014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetPointer(PetscViewer,FILE**); 198014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileGetMode(PetscViewer,PetscFileMode*); 199014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileSetMode(PetscViewer,PetscFileMode); 200014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIPrintf(PetscViewer,const char[],...); 201014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...); 202014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedAllow(PetscViewer,PetscBool); 203014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIPushTab(PetscViewer); 204014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIPopTab(PetscViewer); 205014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIUseTabs(PetscViewer,PetscBool ); 206014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISetTab(PetscViewer,PetscInt); 207014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetTab(PetscViewer,PetscInt*); 208014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIAddTab(PetscViewer,PetscInt); 209014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIISubtractTab(PetscViewer,PetscInt); 210014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetDescriptor(PetscViewer,int*); 211014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **); 212014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryRead(PetscViewer,void*,PetscInt,PetscDataType); 213014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryWrite(PetscViewer,void*,PetscInt,PetscDataType,PetscBool ); 214014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerStringSPrintf(PetscViewer,const char[],...); 215014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerStringSetString(PetscViewer,char[],PetscInt); 216014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawClear(PetscViewer); 217014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetHold(PetscViewer,PetscBool); 218014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawGetHold(PetscViewer,PetscBool*); 219014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetPause(PetscViewer,PetscReal); 220014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawGetPause(PetscViewer,PetscReal*); 221014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int); 222014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawResize(PetscViewer,int,int); 223014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawSetBounds(PetscViewer,PetscInt,const PetscReal*); 224014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerDrawGetBounds(PetscViewer,PetscInt*,const PetscReal**); 225014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSocketSetConnection(PetscViewer,const char[],int); 226014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySkipInfo(PetscViewer); 227014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipOptions(PetscViewer,PetscBool ); 228014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipOptions(PetscViewer,PetscBool *); 229014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipHeader(PetscViewer,PetscBool); 230014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipHeader(PetscViewer,PetscBool*); 231014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryReadStringArray(PetscViewer,char***); 232014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryWriteStringArray(PetscViewer,char**); 233c655490fSBarry Smith 234014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileSetName(PetscViewer,const char[]); 235014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerFileGetName(PetscViewer,const char**); 23677ed5343SBarry Smith 237014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUGetPointer(PetscViewer, FILE**); 238014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUSetVecSeen(PetscViewer, PetscBool ); 239014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUGetVecSeen(PetscViewer, PetscBool *); 240014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUPrintDeferred(PetscViewer, const char [], ...); 241014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVUFlushDeferred(PetscViewer); 24255dcf840SMatthew Knepley 243014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaInitializePackage(const char[]); 244014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaFinalizePackage(void); 245014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetName(PetscViewer, const char **); 246014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSetName(PetscViewer, const char []); 247014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaClearName(PetscViewer); 248014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSkipPackets(PetscViewer, int); 2494ebda54eSMatthew Knepley 250014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloGetName(PetscViewer, char **); 251014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloSetName(PetscViewer, const char []); 252014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloClearName(PetscViewer); 253014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloGetMeshName(PetscViewer, char **); 254014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloSetMeshName(PetscViewer, const char []); 255014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerSiloClearMeshName(PetscViewer); 2564ebda54eSMatthew Knepley 257014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 258014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerNetcdfGetID(PetscViewer, int *); 259e3eb5169SDinesh Kaushik 260acba2ac6SBarry Smith #ifdef PETSC_HAVE_HDF5 261acba2ac6SBarry Smith #include <hdf5.h> 262acba2ac6SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetFileId(PetscViewer,hid_t*); 263acba2ac6SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerHDF5OpenGroup(PetscViewer, hid_t *, hid_t *); 264acba2ac6SBarry Smith 265acba2ac6SBarry Smith /* On 32 bit systems HDF5 is limited by size of integer, because hsize_t is defined as size_t */ 266acba2ac6SBarry Smith #define PETSC_HDF5_INT_MAX 2147483647 267acba2ac6SBarry Smith #define PETSC_HDF5_INT_MIN -2147483647 268acba2ac6SBarry Smith 269acba2ac6SBarry Smith #undef __FUNCT__ 270acba2ac6SBarry Smith #define __FUNCT__ "PetscHDF5IntCast" 271acba2ac6SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscHDF5IntCast(PetscInt a,hsize_t *b) 272acba2ac6SBarry Smith { 273acba2ac6SBarry Smith PetscFunctionBegin; 274acba2ac6SBarry Smith #if defined(PETSC_USE_64BIT_INDICES) && (PETSC_SIZEOF_SIZE_T == 4) 275acba2ac6SBarry Smith if ((a) > PETSC_HDF5_INT_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for HDF5"); 276acba2ac6SBarry Smith #endif 277acba2ac6SBarry Smith *b = (hsize_t)(a); 278acba2ac6SBarry Smith PetscFunctionReturn(0); 279acba2ac6SBarry Smith } 280acba2ac6SBarry Smith #endif 281acba2ac6SBarry Smith 282014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerHDF5WriteSDS(PetscViewer,float *,int,int *,int); 28300ccbe27SDinesh Kaushik 284014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerHDF5Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 285014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerHDF5PushGroup(PetscViewer,const char *); 286014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerHDF5PopGroup(PetscViewer); 287014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetGroup(PetscViewer, const char **); 288014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerHDF5IncrementTimestep(PetscViewer); 289014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerHDF5SetTimestep(PetscViewer,PetscInt); 290014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetTimestep(PetscViewer,PetscInt*); 2918e72c77eSMatthew Knepley 292893c9c94SMatthew G Knepley typedef enum {PETSC_VTK_POINT_FIELD, PETSC_VTK_POINT_VECTOR_FIELD, PETSC_VTK_CELL_FIELD, PETSC_VTK_CELL_VECTOR_FIELD} PetscViewerVTKFieldType; 29318e2ec27SBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerVTKAddField(PetscViewer,PetscObject,PetscErrorCode (*PetscViewerVTKWriteFunction)(PetscObject,PetscViewer),PetscViewerVTKFieldType,PetscObject); 294014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerVTKOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 2954061b8bfSJed Brown 29677ed5343SBarry Smith /* 29777ed5343SBarry Smith These are all the default viewers that do not have 29877ed5343SBarry Smith to be explicitly opened 29977ed5343SBarry Smith */ 300014dd563SJed Brown PETSC_EXTERN PetscViewer PETSC_VIEWER_STDOUT_(MPI_Comm); 301014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*); 302014dd563SJed Brown PETSC_EXTERN PetscViewer PETSC_VIEWER_STDERR_(MPI_Comm); 303014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*); 304014dd563SJed Brown PETSC_EXTERN PetscViewer PETSC_VIEWER_DRAW_(MPI_Comm); 305014dd563SJed Brown PETSC_EXTERN PetscViewer PETSC_VIEWER_SOCKET_(MPI_Comm); 306014dd563SJed Brown PETSC_EXTERN PetscViewer PETSC_VIEWER_BINARY_(MPI_Comm); 307014dd563SJed Brown PETSC_EXTERN PetscViewer PETSC_VIEWER_MATLAB_(MPI_Comm); 308014dd563SJed Brown PETSC_EXTERN PetscViewer PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE; 3095311e20fSBarry Smith 310b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_SELF PETSC_VIEWER_STDERR_(PETSC_COMM_SELF) 311b0a32e0cSBarry Smith #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD) 31230de9b25SBarry Smith 31330de9b25SBarry Smith /*MC 31430de9b25SBarry Smith PETSC_VIEWER_STDOUT_WORLD - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD) 31530de9b25SBarry Smith 31630de9b25SBarry Smith Level: beginner 31730de9b25SBarry Smith M*/ 31830de9b25SBarry Smith #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD) 31930de9b25SBarry Smith 32030de9b25SBarry Smith /*MC 32130de9b25SBarry Smith PETSC_VIEWER_STDOUT_SELF - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF) 32230de9b25SBarry Smith 32330de9b25SBarry Smith Level: beginner 32430de9b25SBarry Smith M*/ 32530de9b25SBarry Smith #define PETSC_VIEWER_STDOUT_SELF PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF) 32630de9b25SBarry Smith 32730de9b25SBarry Smith /*MC 32830de9b25SBarry Smith PETSC_VIEWER_DRAW_WORLD - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD) 32930de9b25SBarry Smith 33030de9b25SBarry Smith Level: intermediate 33130de9b25SBarry Smith M*/ 332b0a32e0cSBarry Smith #define PETSC_VIEWER_DRAW_WORLD PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD) 33330de9b25SBarry Smith 33430de9b25SBarry Smith /*MC 33530de9b25SBarry Smith PETSC_VIEWER_DRAW_SELF - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF) 33630de9b25SBarry Smith 33730de9b25SBarry Smith Level: intermediate 33830de9b25SBarry Smith M*/ 33930de9b25SBarry Smith #define PETSC_VIEWER_DRAW_SELF PETSC_VIEWER_DRAW_(PETSC_COMM_SELF) 34030de9b25SBarry Smith 34130de9b25SBarry Smith /*MC 34230de9b25SBarry Smith PETSC_VIEWER_SOCKET_WORLD - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD) 34330de9b25SBarry Smith 34430de9b25SBarry Smith Level: intermediate 34530de9b25SBarry Smith M*/ 346b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD) 34730de9b25SBarry Smith 34830de9b25SBarry Smith /*MC 34930de9b25SBarry Smith PETSC_VIEWER_SOCKET_SELF - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF) 35030de9b25SBarry Smith 35130de9b25SBarry Smith Level: intermediate 35230de9b25SBarry Smith M*/ 353b0a32e0cSBarry Smith #define PETSC_VIEWER_SOCKET_SELF PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF) 35430de9b25SBarry Smith 35530de9b25SBarry Smith /*MC 35630de9b25SBarry Smith PETSC_VIEWER_BINARY_WORLD - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD) 35730de9b25SBarry Smith 35830de9b25SBarry Smith Level: intermediate 35930de9b25SBarry Smith M*/ 360b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD) 36130de9b25SBarry Smith 36230de9b25SBarry Smith /*MC 36330de9b25SBarry Smith PETSC_VIEWER_BINARY_SELF - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF) 36430de9b25SBarry Smith 36530de9b25SBarry Smith Level: intermediate 36630de9b25SBarry Smith M*/ 367b0a32e0cSBarry Smith #define PETSC_VIEWER_BINARY_SELF PETSC_VIEWER_BINARY_(PETSC_COMM_SELF) 36830de9b25SBarry Smith 369cbb32127SBarry Smith /*MC 370cbb32127SBarry Smith PETSC_VIEWER_MATLAB_WORLD - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD) 371cbb32127SBarry Smith 372cbb32127SBarry Smith Level: intermediate 373cbb32127SBarry Smith M*/ 374cbb32127SBarry Smith #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD) 375cbb32127SBarry Smith 376cbb32127SBarry Smith /*MC 377cbb32127SBarry Smith PETSC_VIEWER_MATLAB_SELF - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF) 378cbb32127SBarry Smith 379cbb32127SBarry Smith Level: intermediate 380cbb32127SBarry Smith M*/ 381cbb32127SBarry Smith #define PETSC_VIEWER_MATLAB_SELF PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF) 382cbb32127SBarry Smith 3837eb62a3eSMatthew Knepley #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE) 38465ef3172SBarry Smith 385639ff905SBarry Smith #undef __FUNCT__ 386639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlStart" 387639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStart(PetscViewer viewer,PetscInt *mcnt,PetscInt *cnt) 388639ff905SBarry Smith { 389639ff905SBarry Smith PetscErrorCode ierr; 390639ff905SBarry Smith PetscFunctionBegin; 391639ff905SBarry Smith ierr = PetscViewerBinaryGetFlowControl(viewer,mcnt);CHKERRQ(ierr); 392639ff905SBarry Smith ierr = PetscViewerBinaryGetFlowControl(viewer,cnt);CHKERRQ(ierr); 393639ff905SBarry Smith PetscFunctionReturn(0); 394e03d165dSBarry Smith } 395639ff905SBarry Smith 396639ff905SBarry Smith #undef __FUNCT__ 397639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlStepMaster" 398639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStepMaster(PetscViewer viewer,PetscInt i,PetscInt *mcnt,PetscInt cnt) 399639ff905SBarry Smith { 400639ff905SBarry Smith PetscErrorCode ierr; 401639ff905SBarry Smith MPI_Comm comm; 402639ff905SBarry Smith 403639ff905SBarry Smith PetscFunctionBegin; 404639ff905SBarry Smith ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr); 405639ff905SBarry Smith if (i >= *mcnt) { 406639ff905SBarry Smith *mcnt += cnt; 407639ff905SBarry Smith ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr); 408639ff905SBarry Smith } 409639ff905SBarry Smith PetscFunctionReturn(0); 410639ff905SBarry Smith } 411639ff905SBarry Smith 412639ff905SBarry Smith #undef __FUNCT__ 413639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlEndMaster" 414639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlEndMaster(PetscViewer viewer,PetscInt *mcnt) 415639ff905SBarry Smith { 416639ff905SBarry Smith PetscErrorCode ierr; 417639ff905SBarry Smith MPI_Comm comm; 418639ff905SBarry Smith PetscFunctionBegin; 419639ff905SBarry Smith ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr); 420639ff905SBarry Smith *mcnt = 0; 421639ff905SBarry Smith ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr); 422639ff905SBarry Smith PetscFunctionReturn(0); 423639ff905SBarry Smith } 424639ff905SBarry Smith 425639ff905SBarry Smith #undef __FUNCT__ 426639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlStepWorker" 427639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStepWorker(PetscViewer viewer,PetscMPIInt rank,PetscInt *mcnt) 428639ff905SBarry Smith { 429639ff905SBarry Smith PetscErrorCode ierr; 430639ff905SBarry Smith MPI_Comm comm; 431639ff905SBarry Smith PetscFunctionBegin; 432639ff905SBarry Smith ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr); 433639ff905SBarry Smith while (PETSC_TRUE) { 434639ff905SBarry Smith if (rank < *mcnt) break; 435639ff905SBarry Smith ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr); 436639ff905SBarry Smith } 437639ff905SBarry Smith PetscFunctionReturn(0); 438639ff905SBarry Smith } 439639ff905SBarry Smith 440639ff905SBarry Smith #undef __FUNCT__ 441639ff905SBarry Smith #define __FUNCT__ "PetscViewerFlowControlEndWorker" 442639ff905SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlEndWorker(PetscViewer viewer,PetscInt *mcnt) 443639ff905SBarry Smith { 444639ff905SBarry Smith PetscErrorCode ierr; 445639ff905SBarry Smith MPI_Comm comm; 446639ff905SBarry Smith PetscFunctionBegin; 447639ff905SBarry Smith ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr); 448639ff905SBarry Smith while (PETSC_TRUE) { 449639ff905SBarry Smith ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr); 450639ff905SBarry Smith if (!*mcnt) break; 451639ff905SBarry Smith } 452639ff905SBarry Smith PetscFunctionReturn(0); 453fca9dd48SBarry Smith } 454e03d165dSBarry Smith 45577ed5343SBarry Smith /* 456a5057860SBarry Smith PetscViewer writes to MATLAB .mat file 457cbb32127SBarry Smith */ 458014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutArray(PetscViewer,int,int,const PetscScalar*,const char*); 459014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,const char*); 460014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutVariable(PetscViewer,const char*,void*); 461cbb32127SBarry Smith 462b9617806SBarry Smith /*S 4631890ba74SBarry Smith PetscViewers - Abstract collection of PetscViewers. It is just an expandable array of viewers. 464b9617806SBarry Smith 465b9617806SBarry Smith Level: intermediate 466b9617806SBarry Smith 467b9617806SBarry Smith Concepts: viewing 468b9617806SBarry Smith 469b9617806SBarry Smith .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(), 470b9617806SBarry Smith PetscViewersGetViewer() 471b9617806SBarry Smith S*/ 47295fbd943SSatish Balay typedef struct _n_PetscViewers* PetscViewers; 473014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewersCreate(MPI_Comm,PetscViewers*); 474014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewersDestroy(PetscViewers*); 475014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*); 476d132466eSBarry Smith 477b3506946SBarry Smith #if defined(PETSC_HAVE_AMS) 478b3506946SBarry Smith #include <ams.h> 479014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSSetCommName(PetscViewer,const char[]); 480014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSGetAMSComm(PetscViewer,AMS_Comm *); 481014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSOpen(MPI_Comm,const char[],PetscViewer*); 482014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerAMSLock(PetscViewer); 483014dd563SJed Brown PETSC_EXTERN PetscViewer PETSC_VIEWER_AMS_(MPI_Comm); 484014dd563SJed Brown PETSC_EXTERN PetscErrorCode PETSC_VIEWER_AMS_Destroy(MPI_Comm); 485b3506946SBarry Smith #define PETSC_VIEWER_AMS_WORLD PETSC_VIEWER_AMS_(PETSC_COMM_WORLD) 486b3506946SBarry Smith #endif 487b3506946SBarry Smith 488cb5b572fSBarry Smith #endif 489