xref: /petsc/src/sys/classes/viewer/impls/vtk/vtkvimpl.h (revision 7de69702b957b5de648b60762d01f4e5276d32ac) !
16524c165SJacob Faibussowitsch #ifndef _VTKVIMPL_H
25c6c1daeSBarry Smith #define _VTKVIMPL_H
35c6c1daeSBarry Smith 
4af0996ceSBarry Smith #include <petsc/private/viewerimpl.h> /*I   "petscsys.h"   I*/
55c6c1daeSBarry Smith 
65c6c1daeSBarry Smith typedef struct _n_PetscViewerVTKObjectLink *PetscViewerVTKObjectLink;
75c6c1daeSBarry Smith struct _n_PetscViewerVTKObjectLink {
85c6c1daeSBarry Smith   PetscViewerVTKFieldType  ft;
95c6c1daeSBarry Smith   PetscObject              vec;
105c6c1daeSBarry Smith   PetscViewerVTKObjectLink next;
11e630c359SToby Isaac   PetscInt                 field;
125c6c1daeSBarry Smith };
135c6c1daeSBarry Smith 
145c6c1daeSBarry Smith typedef struct {
155c6c1daeSBarry Smith   char                    *filename;
165c6c1daeSBarry Smith   PetscFileMode            btype;
175c6c1daeSBarry Smith   PetscObject              dm;
185c6c1daeSBarry Smith   PetscViewerVTKObjectLink link;
1918e2ec27SBarry Smith   PetscErrorCode (*write)(PetscObject, PetscViewer);
205c6c1daeSBarry Smith } PetscViewer_VTK;
215c6c1daeSBarry Smith 
2294fbd55eSBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerVTKFWrite(PetscViewer, FILE *, const void *, PetscInt, MPI_Datatype);
235c6c1daeSBarry Smith 
245c6c1daeSBarry Smith #if defined(PETSC_HAVE_STDINT_H) /* The VTK format requires a 32-bit integer */
255c6c1daeSBarry Smith typedef int32_t PetscVTKInt;
26*7de69702SBarry Smith #else /* Hope int is 32-bits */
275c6c1daeSBarry Smith typedef int PetscVTKInt;
285c6c1daeSBarry Smith #endif
295c6c1daeSBarry Smith typedef unsigned char PetscVTKType;
305c6c1daeSBarry Smith 
315c6c1daeSBarry Smith #define PETSC_VTK_INT_MAX 2147483647
325c6c1daeSBarry Smith #define PETSC_VTK_INT_MIN -2147483647
335c6c1daeSBarry Smith #if defined(PETSC_USE_64BIT_INDICES)
3408401ef6SPierre Jolivet   #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")
359371c9d4SSatish Balay   #define PetscVTKIntCast(a) \
369371c9d4SSatish Balay     (PetscVTKInt)(a); \
379371c9d4SSatish Balay     PetscVTKIntCheck(a)
385c6c1daeSBarry Smith #else
395c6c1daeSBarry Smith   #define PetscVTKIntCheck(a)
405c6c1daeSBarry Smith   #define PetscVTKIntCast(a) a
415c6c1daeSBarry Smith #endif
425c6c1daeSBarry Smith 
432fb742c9SToby Isaac /* the only problem we've encountered so far is spaces not being acceptable for paraview field names */
44d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode PetscViewerVTKSanitizeName_Internal(char name[], size_t maxlen)
45d71ae5a4SJacob Faibussowitsch {
462fb742c9SToby Isaac   size_t c;
472fb742c9SToby Isaac 
482fb742c9SToby Isaac   PetscFunctionBegin;
492fb742c9SToby Isaac   for (c = 0; c < maxlen; c++) {
502fb742c9SToby Isaac     char a = name[c];
512fb742c9SToby Isaac     if (a == '\0') break;
522fb742c9SToby Isaac     if (a == ' ') name[c] = '_';
532fb742c9SToby Isaac   }
543ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
552fb742c9SToby Isaac }
565c6c1daeSBarry Smith #endif
57