VPICDefinition.h
Go to the documentation of this file.
1 #ifndef VPICDefinition_h
2 #define VPICDefinition_h
3 
4 #include <vtksys/Configure.h>
5 #include <string>
6 #include <iostream>
7 
8 #include "vtkABI.h"
9 
10 using namespace std;
11 
12 #define BUILD_SHARED_LIBS
13 
14 // Now set up all of the export macros
15 #if defined(BUILD_SHARED_LIBS)
16  #if defined(VPIC_EXPORTS)
17  #define VPIC_EXPORT VTK_ABI_EXPORT
18  #else
19  #define VPIC_EXPORT VTK_ABI_IMPORT
20  #endif
21 #else
22  #define VPIC_EXPORT
23 #endif
24 
25 #define vpicNotUsed(x)
26 
27 
28 #define WORDSIZE 8
29 const int LINESIZE = 1024;
30 
31 const int VPIC_OK = 0;
32 const int VPIC_FAIL = 1;
33 
34 const int NONE = -1;
35 
36 const double MIN_FLOAT = -1e07;
37 const double MAX_FLOAT = 1e07;
38 
39 const int VPIC_FIELD = 1; // Field data file
40 const int VPIC_HYDRO = 2; // Hydro data file
41 
42 const int DIMENSION = 3; // Grid and vector
43 const int TENSOR_DIMENSION = 6; // Tensor
44 const int TENSOR9_DIMENSION = 9; // Tensor
45 
46 const int CONSTANT = 0; // Structure types
47 const int SCALAR = 1;
48 const int VECTOR = 2;
49 const int TENSOR = 3;
50 const int TENSOR9 = 4;
51 
52 const int FLOAT = 0; // Basic data types
53 const int INTEGER = 1;
54 
55 typedef float GRID_T;
56 
57 //
58 // Neighbors are enumerated so that particles can be attached to the correct
59 // neighbor, but these pairs must be preserved for the ParticleExchange.
60 // Every processor should be able to send and receive on every iteration of
61 // the exchange, so if everyone sends RIGHT and receives LEFT it works
62 //
63 // Do not change this pairing order.
64 //
66 {
67  X0, // Left face
68  X1, // Right face
69 
70  Y0, // Bottom face
71  Y1, // Top face
72 
73  Z0, // Front face
74  Z1, // Back face
75 
76  X0_Y0, // Left bottom edge
77  X1_Y1, // Right top edge
78 
79  X0_Y1, // Left top edge
80  X1_Y0, // Right bottom edge
81 
82  Y0_Z0, // Bottom front edge
83  Y1_Z1, // Top back edge
84 
85  Y0_Z1, // Bottom back edge
86  Y1_Z0, // Top front edge
87 
88  Z0_X0, // Front left edge
89  Z1_X1, // Back right edge
90 
91  Z0_X1, // Front right edge
92  Z1_X0, // Back left edge
93 
94  X0_Y0_Z0, // Left bottom front corner
95  X1_Y1_Z1, // Right top back corner
96 
97  X0_Y0_Z1, // Left bottom back corner
98  X1_Y1_Z0, // Right top front corner
99 
100  X0_Y1_Z0, // Left top front corner
101  X1_Y0_Z1, // Right bottom back corner
102 
103  X0_Y1_Z1, // Left top back corner
104  X1_Y0_Z0 // Right bottom front corner
105 };
106 
107 const int NUM_OF_NEIGHBORS = 26;
108 
109 // Read character string from file
110 string readString(FILE* filePtr, int size);
111 
112 // Read number of unsigned integer items from file, byte swapping if needed
113 void readData(
114  bool littleEndian,
115  unsigned short* data,
116  unsigned long dataSize,
117  unsigned long dataCount,
118  FILE* fp);
119 
120 // Read number of integer items from file, byte swapping if needed
121 void readData(
122  bool littleEndian,
123  int* data,
124  unsigned long dataSize,
125  unsigned long dataCount,
126  FILE* fp);
127 
128 // Read number of float items from file, byte swapping if needed
129 void readData(
130  bool littleEndian,
131  float* data,
132  unsigned long dataSize,
133  unsigned long dataCount,
134  FILE* fp);
135 
136 // Read number of float items from file, byte swapping if needed
137 void readData(
138  bool littleEndian,
139  double* data,
140  unsigned long dataSize,
141  unsigned long dataCount,
142  FILE* fp);
143 
144 // Greatest Common Divisor
145 int GCD(int a, int b);
146 
147 // Templated function BinaryWrite
148 template< class outDataType >
149 inline void BinaryWrite(ostream& outStream, const outDataType& outData)
150 {
151  outStream.write(
152  reinterpret_cast<const char*>(&outData), sizeof(outDataType));
153 }
154 
155 // Templated function BinaryRead
156 template< class inHolderType >
157 inline istream& BinaryRead(istream& inStream, inHolderType& inHolder)
158 {
159  return inStream.read(
160  reinterpret_cast<char*>(&inHolder), sizeof(inHolderType));
161 }
162 
163 #endif
float GRID_T
const int FLOAT
const int VPIC_FIELD
const int TENSOR
const int NUM_OF_NEIGHBORS
const int VPIC_HYDRO
const double MAX_FLOAT
const int TENSOR9
istream & BinaryRead(istream &inStream, inHolderType &inHolder)
const double MIN_FLOAT
const int VECTOR
const int INTEGER
const int LINESIZE
const int TENSOR_DIMENSION
NEIGHBOR
const int NONE
const int DIMENSION
const int SCALAR
const int CONSTANT
void readData(bool littleEndian, unsigned short *data, unsigned long dataSize, unsigned long dataCount, FILE *fp)
const int VPIC_OK
int GCD(int a, int b)
const int TENSOR9_DIMENSION
const int VPIC_FAIL
void BinaryWrite(ostream &outStream, const outDataType &outData)
string readString(FILE *filePtr, int size)