xref: /petsc/src/sys/classes/viewer/impls/vtk/vtkvimpl.h (revision 5c6c1daec53e1d9ab0bec9db5309fd8fc7645b8d)
1*5c6c1daeSBarry Smith #if !defined(_VTKVIMPL_H)
2*5c6c1daeSBarry Smith #define _VTKVIMPL_H
3*5c6c1daeSBarry Smith 
4*5c6c1daeSBarry Smith #include <petsc-private/viewerimpl.h>    /*I   "petscsys.h"   I*/
5*5c6c1daeSBarry Smith 
6*5c6c1daeSBarry Smith typedef struct _n_PetscViewerVTKObjectLink *PetscViewerVTKObjectLink;
7*5c6c1daeSBarry Smith struct _n_PetscViewerVTKObjectLink {
8*5c6c1daeSBarry Smith   PetscViewerVTKFieldType  ft;
9*5c6c1daeSBarry Smith   PetscObject              vec;
10*5c6c1daeSBarry Smith   PetscViewerVTKObjectLink next;
11*5c6c1daeSBarry Smith };
12*5c6c1daeSBarry Smith 
13*5c6c1daeSBarry Smith typedef struct {
14*5c6c1daeSBarry Smith   char                        *filename;
15*5c6c1daeSBarry Smith   PetscFileMode               btype;
16*5c6c1daeSBarry Smith   PetscBool                   written;
17*5c6c1daeSBarry Smith   PetscObject                 dm;
18*5c6c1daeSBarry Smith   PetscViewerVTKWriteFunction dmwriteall;
19*5c6c1daeSBarry Smith   PetscViewerVTKObjectLink    link;
20*5c6c1daeSBarry Smith } PetscViewer_VTK;
21*5c6c1daeSBarry Smith 
22*5c6c1daeSBarry Smith PETSC_EXTERN PetscErrorCode PetscViewerVTKFWrite(PetscViewer,FILE*,const void*,PetscInt,PetscDataType);
23*5c6c1daeSBarry Smith 
24*5c6c1daeSBarry Smith #if defined(PETSC_HAVE_STDINT_H) /* The VTK format requires a 32-bit integer */
25*5c6c1daeSBarry Smith typedef int32_t PetscVTKInt;
26*5c6c1daeSBarry Smith #else                            /* Hope int is 32 bits */
27*5c6c1daeSBarry Smith typedef int PetscVTKInt;
28*5c6c1daeSBarry Smith #endif
29*5c6c1daeSBarry Smith 
30*5c6c1daeSBarry Smith /* Hack: Our enums are guaranteed to be the same size as normal int. A better fix would be to distinguish PETSC_INT32
31*5c6c1daeSBarry Smith  * and PETSC_INT64 in the PetscDataType enum. */
32*5c6c1daeSBarry Smith #define PETSC_INT32 PETSC_ENUM
33*5c6c1daeSBarry Smith 
34*5c6c1daeSBarry Smith typedef unsigned char PetscVTKType;
35*5c6c1daeSBarry Smith #define PETSC_UINT8 PETSC_CHAR
36*5c6c1daeSBarry Smith 
37*5c6c1daeSBarry Smith #define PETSC_VTK_INT_MAX  2147483647
38*5c6c1daeSBarry Smith #define PETSC_VTK_INT_MIN -2147483647
39*5c6c1daeSBarry Smith #if defined(PETSC_USE_64BIT_INDICES)
40*5c6c1daeSBarry 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")
41*5c6c1daeSBarry Smith #  define PetscVTKIntCast(a) (PetscVTKInt)(a);PetscVTKIntCheck(a)
42*5c6c1daeSBarry Smith #else
43*5c6c1daeSBarry Smith #  define PetscVTKIntCheck(a)
44*5c6c1daeSBarry Smith #  define PetscVTKIntCast(a) a
45*5c6c1daeSBarry Smith #endif
46*5c6c1daeSBarry Smith 
47*5c6c1daeSBarry Smith #endif
48