xref: /petsc/src/sys/classes/viewer/impls/vtk/vtkvimpl.h (revision 18e2ec274b9e92144f2ef650b9690aa28f9a6737)
15c6c1daeSBarry Smith #if !defined(_VTKVIMPL_H)
25c6c1daeSBarry Smith #define _VTKVIMPL_H
35c6c1daeSBarry Smith 
45c6c1daeSBarry 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;
115c6c1daeSBarry Smith };
125c6c1daeSBarry Smith 
135c6c1daeSBarry Smith typedef struct {
145c6c1daeSBarry Smith   char                        *filename;
155c6c1daeSBarry Smith   PetscFileMode               btype;
165c6c1daeSBarry Smith   PetscBool                   written;
175c6c1daeSBarry Smith   PetscObject                 dm;
185c6c1daeSBarry Smith   PetscViewerVTKObjectLink    link;
19*18e2ec27SBarry Smith   PetscErrorCode              (*write)(PetscObject,PetscViewer);
205c6c1daeSBarry Smith } PetscViewer_VTK;
215c6c1daeSBarry Smith 
225c6c1daeSBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerVTKFWrite(PetscViewer,FILE*,const void*,PetscInt,PetscDataType);
235c6c1daeSBarry Smith 
245c6c1daeSBarry Smith #if defined(PETSC_HAVE_STDINT_H) /* The VTK format requires a 32-bit integer */
255c6c1daeSBarry Smith typedef int32_t PetscVTKInt;
265c6c1daeSBarry Smith #else                            /* Hope int is 32 bits */
275c6c1daeSBarry Smith typedef int PetscVTKInt;
285c6c1daeSBarry Smith #endif
295c6c1daeSBarry Smith 
305c6c1daeSBarry Smith /* Hack: Our enums are guaranteed to be the same size as normal int. A better fix would be to distinguish PETSC_INT32
315c6c1daeSBarry Smith  * and PETSC_INT64 in the PetscDataType enum. */
325c6c1daeSBarry Smith #define PETSC_INT32 PETSC_ENUM
335c6c1daeSBarry Smith 
345c6c1daeSBarry Smith typedef unsigned char PetscVTKType;
355c6c1daeSBarry Smith #define PETSC_UINT8 PETSC_CHAR
365c6c1daeSBarry Smith 
375c6c1daeSBarry Smith #define PETSC_VTK_INT_MAX  2147483647
385c6c1daeSBarry Smith #define PETSC_VTK_INT_MIN -2147483647
395c6c1daeSBarry Smith #if defined(PETSC_USE_64BIT_INDICES)
405c6c1daeSBarry Smith #  define PetscVTKIntCheck(a)  if ((a) > PETSC_VTK_INT_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for 32-bit VTK binary format")
415c6c1daeSBarry Smith #  define PetscVTKIntCast(a) (PetscVTKInt)(a);PetscVTKIntCheck(a)
425c6c1daeSBarry Smith #else
435c6c1daeSBarry Smith #  define PetscVTKIntCheck(a)
445c6c1daeSBarry Smith #  define PetscVTKIntCast(a) a
455c6c1daeSBarry Smith #endif
465c6c1daeSBarry Smith 
475c6c1daeSBarry Smith #endif
48