1: #ifndef _VTKVIMPL_H 2: #define _VTKVIMPL_H 4: #include <petsc/private/viewerimpl.h> 6: typedef struct _n_PetscViewerVTKObjectLink *PetscViewerVTKObjectLink; 7: struct _n_PetscViewerVTKObjectLink { 8: PetscViewerVTKFieldType ft; 9: PetscObject vec; 10: PetscViewerVTKObjectLink next; 11: PetscInt field; 12: }; 14: typedef struct { 15: char *filename; 16: PetscFileMode btype; 17: PetscObject dm; 18: PetscViewerVTKObjectLink link; 19: PetscErrorCode (*write)(PetscObject, PetscViewer); 20: } PetscViewer_VTK; 22: PETSC_EXTERN PetscErrorCode PetscViewerVTKFWrite(PetscViewer, FILE *, const void *, PetscInt, MPI_Datatype); 24: #if defined(PETSC_HAVE_STDINT_H) /* The VTK format requires a 32-bit integer */ 25: typedef int32_t PetscVTKInt; 26: #else /* Hope int is 32-bits */ 27: typedef int PetscVTKInt; 28: #endif 29: typedef unsigned char PetscVTKType; 31: #define PETSC_VTK_INT_MAX 2147483647 32: #define PETSC_VTK_INT_MIN -2147483647 33: #if defined(PETSC_USE_64BIT_INDICES) 34: #define PetscVTKIntCheck(a) PetscCheck((a) <= PETSC_VTK_INT_MAX, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Array too long for 32-bit VTK binary format") 35: #define PetscVTKIntCast(a) \ 36: (PetscVTKInt)(a); \ 37: PetscVTKIntCheck(a) 38: #else 39: #define PetscVTKIntCheck(a) 40: #define PetscVTKIntCast(a) a 41: #endif 43: /* the only problem we've encountered so far is spaces not being acceptable for paraview field names */ 44: static inline PetscErrorCode PetscViewerVTKSanitizeName_Internal(char name[], size_t maxlen) 45: { 46: size_t c; 48: PetscFunctionBegin; 49: for (c = 0; c < maxlen; c++) { 50: char a = name[c]; 51: if (a == '\0') break; 52: if (a == ' ') name[c] = '_'; 53: } 54: PetscFunctionReturn(PETSC_SUCCESS); 55: } 56: #endif