2 * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM
4 * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide.
6 * Tecplot hereby grants OpenCFD limited authority to distribute without
7 * alteration the source code to the Tecplot Input/Output library, known
8 * as TecIO, as part of its distribution of OpenFOAM and the
9 * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby
10 * granted access to the TecIO source code, and may redistribute it for the
11 * purpose of maintaining the converter. However, no authority is granted
12 * to alter the TecIO source code in any form or manner.
14 * This limited grant of distribution does not supersede Tecplot, Inc.'s
15 * copyright in TecIO. Contact Tecplot, Inc. for further information.
18 * 3535 Factoria Blvd, Ste. 550
19 * Bellevue, WA 98006, USA
20 * Phone: +1 425 653 1200
21 * http://www.tecplot.com/
27 #if defined DATASET0MODULE
34 ******************************************************************
35 ******************************************************************
37 ****** (C) 1988-2008 Tecplot, Inc. *******
39 ******************************************************************
40 ******************************************************************
51 EXTERN
void OutOfMemoryMsg(void);
54 * Turn on DEBUG_FIELDVALUES by default in any build with assertions on
55 * (including checked builds), but allow turning this off with
56 * NO_DEBUG_FIELDVALUES
58 #if !defined NO_ASSERTS && !defined NO_DEBUG_FIELDVALUES && !defined DEBUG_FIELDVALUES
59 #define DEBUG_FIELDVALUES
62 /* FieldData_a is intentionally not defined to further
63 * deter usage of this private structure */
66 void *Data
; /* ...placed first in the structure for fastest access */
67 # if defined TECPLOTKERNEL
68 /* CORE SOURCE CODE REMOVED */
70 void *GetValueCallback
[1]; /* ...this field is for TecIO only */
71 void *SetValueCallback
[1]; /* ...this field is for TecIO only */
76 ValueLocation_e ValueLocation
;
78 LgIndex_t VarShareRefCount
;
80 # if defined TECPLOTKERNEL /* TecIO doesn't require these features yet. */
81 /* CORE SOURCE CODE REMOVED */
87 * * NOTE: "FieldData_pa" here is an "abstract type".
88 * * Any routines dealing with the internals workings
89 * * of FieldData_pa must be in the same file as these
93 #if defined USE_MACROS_FOR_FUNCTIONS
94 #define USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
98 * These are low-level (private) FD manipulation functions. In
99 * most cases, you should use some higher-level function. These
100 * macros are supplied for the dataset functions to use.
102 #if defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
103 #define GetFieldDataType GetFieldDataType_MACRO
104 #define GetFieldDataGetFunction GetFieldDataGetFunction_MACRO
105 #define GetFieldDataSetFunction GetFieldDataSetFunction_MACRO
106 #define GetFieldDataNumValues GetFieldDataNumValues_MACRO
107 #define GetFieldDataValueLocation GetFieldDataValueLocation_MACRO
108 #define IsFieldDataDirectAccessAllowed IsFieldDataDirectAccessAllowed_MACRO
110 #define GetFieldDataType GetFieldDataType_FUNC
111 #define GetFieldDataGetFunction GetFieldDataGetFunction_FUNC
112 #define GetFieldDataSetFunction GetFieldDataSetFunction_FUNC
113 #define GetFieldDataNumValues GetFieldDataNumValues_FUNC
114 #define GetFieldDataValueLocation GetFieldDataValueLocation_FUNC
115 #define IsFieldDataDirectAccessAllowed IsFieldDataDirectAccessAllowed_FUNC
118 #define GetFieldDataType_MACRO(FieldData) ((FieldData)->Type)
119 #if defined TECPLOTKERNEL
120 /* CORE SOURCE CODE REMOVED */
121 #else /* ...for TecIO only */
122 #define GetFieldDataGetFunction_MACRO(FieldData) ((FieldValueGetFunction_pf)(FieldData)->GetValueCallback[0])
123 #define GetFieldDataSetFunction_MACRO(FieldData) ((FieldValueSetFunction_pf)(FieldData)->SetValueCallback[0])
125 #define GetFieldDataNumValues_MACRO(FieldData) ((FieldData)->NumValues)
126 #define GetFieldDataValueLocation_MACRO(FieldData) ((FieldData)->ValueLocation)
128 EXTERN
double STDCALL
GetFieldValueForFloat(const FieldData_pa fd
, LgIndex_t pt
);
129 EXTERN
double STDCALL
GetFieldValueForDouble(const FieldData_pa fd
, LgIndex_t pt
);
130 EXTERN
double STDCALL
GetFieldValueForInt32(const FieldData_pa fd
, LgIndex_t pt
);
131 EXTERN
double STDCALL
GetFieldValueForInt16(const FieldData_pa fd
, LgIndex_t pt
);
132 EXTERN
double STDCALL
GetFieldValueForByte(const FieldData_pa fd
, LgIndex_t pt
);
133 EXTERN
double STDCALL
GetFieldValueForBit(const FieldData_pa fd
, LgIndex_t pt
);
135 #if defined TECPLOTKERNEL
136 /* CORE SOURCE CODE REMOVED */
138 #define IsFieldDataDirectAccessAllowed_MACRO(FieldData) ((FieldData)->Data != NULL)
141 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
142 EXTERN FieldDataType_e
GetFieldDataType_FUNC(FieldData_pa FieldData
);
143 EXTERN FieldValueGetFunction_pf
GetFieldDataGetFunction_FUNC(FieldData_pa FieldData
);
144 EXTERN FieldValueSetFunction_pf
GetFieldDataSetFunction_FUNC(FieldData_pa FieldData
);
145 EXTERN LgIndex_t
GetFieldDataNumValues_FUNC(FieldData_pa FieldData
);
146 EXTERN ValueLocation_e
GetFieldDataValueLocation_FUNC(FieldData_pa FieldData
);
147 EXTERN Boolean_t
IsFieldDataDirectAccessAllowed_FUNC(FieldData_pa FieldData
);
152 * Use separate types for reversed byte data than unreversed data so we
153 * have better compiler checking.
155 typedef UInt32_t FloatRev_t
;
156 typedef UInt64_t DoubleRev_t
;
157 typedef UInt16_t Int16Rev_t
;
158 typedef UInt32_t Int32Rev_t
;
159 typedef UInt64_t Int64Rev_t
;
163 * Note: there are so many GetFieldData*Ptr functions because we
164 * want a bunch of error checking. The Type and TypeRev check
165 * for that type. The Byte, 2Byte, etc. just make sure it is
167 * GetFieldDataVoidPtr checks nothing, and thus should only be
168 * used with extreme caution (that is, checking the alignment
169 * and byte order by hand).
171 #if defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
172 #define GetFieldDataFloatPtr GetFieldDataFloatPtr_MACRO
173 #define GetFieldDataFloatRevPtr GetFieldDataFloatRevPtr_MACRO
174 #define GetFieldDataDoublePtr GetFieldDataDoublePtr_MACRO
175 #define GetFieldDataDoubleRevPtr GetFieldDataDoubleRevPtr_MACRO
176 #define GetFieldDataInt64Ptr GetFieldDataInt64Ptr_MACRO
177 #define GetFieldDataInt64RevPtr GetFieldDataInt64RevPtr_MACRO
178 #define GetFieldDataInt32Ptr GetFieldDataInt32Ptr_MACRO
179 #define GetFieldDataInt32RevPtr GetFieldDataInt32RevPtr_MACRO
180 #define GetFieldDataInt16Ptr GetFieldDataInt16Ptr_MACRO
181 #define GetFieldDataInt16RevPtr GetFieldDataInt16RevPtr_MACRO
182 #define GetFieldDataBytePtr GetFieldDataBytePtr_MACRO
183 #define GetFieldData2BytePtr GetFieldData2BytePtr_MACRO
184 #define GetFieldData4BytePtr GetFieldData4BytePtr_MACRO
185 #define GetFieldData8BytePtr GetFieldData8BytePtr_MACRO
186 #define GetFieldDataVoidPtr GetFieldDataVoidPtr_MACRO /*danger:see above*/
188 #define GetFieldDataFloatPtr GetFieldDataFloatPtr_FUNC
189 #define GetFieldDataFloatRevPtr GetFieldDataFloatRevPtr_FUNC
190 #define GetFieldDataDoublePtr GetFieldDataDoublePtr_FUNC
191 #define GetFieldDataDoubleRevPtr GetFieldDataDoubleRevPtr_FUNC
192 #define GetFieldDataInt64Ptr GetFieldDataInt64Ptr_FUNC
193 #define GetFieldDataInt64RevPtr GetFieldDataInt64RevPtr_FUNC
194 #define GetFieldDataInt32Ptr GetFieldDataInt32Ptr_FUNC
195 #define GetFieldDataInt32RevPtr GetFieldDataInt32RevPtr_FUNC
196 #define GetFieldDataInt16Ptr GetFieldDataInt16Ptr_FUNC
197 #define GetFieldDataInt16RevPtr GetFieldDataInt16RevPtr_FUNC
198 #define GetFieldDataBytePtr GetFieldDataBytePtr_FUNC
199 #define GetFieldData2BytePtr GetFieldData2BytePtr_FUNC
200 #define GetFieldData4BytePtr GetFieldData4BytePtr_FUNC
201 #define GetFieldData8BytePtr GetFieldData8BytePtr_FUNC
202 #define GetFieldDataVoidPtr GetFieldDataVoidPtr_FUNC /*danger:see above*/
205 #define GetFieldDataFloatPtr_MACRO(FieldData) ((float *)((FieldData)->Data))
206 #define GetFieldDataFloatRevPtr_MACRO(FieldData) ((FloatRev_t *)((FieldData)->Data))
207 #define GetFieldDataDoublePtr_MACRO(FieldData) ((double *)((FieldData)->Data))
208 #define GetFieldDataDoubleRevPtr_MACRO(FieldData) ((DoubleRev_t *)((FieldData)->Data))
209 #define GetFieldDataInt64Ptr_MACRO(FieldData) ((Int64_t *)((FieldData)->Data))
210 #define GetFieldDataInt64RevPtr_MACRO(FieldData) ((Int64Rev_t *)((FieldData)->Data))
211 #define GetFieldDataInt32Ptr_MACRO(FieldData) ((Int32_t *)((FieldData)->Data))
212 #define GetFieldDataInt32RevPtr_MACRO(FieldData) ((Int32Rev_t *)((FieldData)->Data))
213 #define GetFieldDataInt16Ptr_MACRO(FieldData) ((Int16_t *)((FieldData)->Data))
214 #define GetFieldDataInt16RevPtr_MACRO(FieldData) ((Int16Rev_t *)((FieldData)->Data))
215 #define GetFieldDataBytePtr_MACRO(FieldData) ((Byte_t *)((FieldData)->Data))
216 #define GetFieldData2BytePtr_MACRO(FieldData) ((UInt16_t *)((FieldData)->Data))
217 #define GetFieldData4BytePtr_MACRO(FieldData) ((UInt32_t *)((FieldData)->Data))
218 #define GetFieldData8BytePtr_MACRO(FieldData) ((UInt64_t *)((FieldData)->Data))
219 #define GetFieldDataVoidPtr_MACRO(FieldData) ((void *)((FieldData)->Data)) /*danger:see above*/
221 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
222 EXTERN
float *GetFieldDataFloatPtr_FUNC(FieldData_pa fd
);
223 EXTERN FloatRev_t
*GetFieldDataFloatRevPtr_FUNC(FieldData_pa fd
);
224 EXTERN
double *GetFieldDataDoublePtr_FUNC(FieldData_pa fd
);
225 EXTERN DoubleRev_t
*GetFieldDataDoubleRevPtr_FUNC(FieldData_pa fd
);
226 EXTERN Int64_t
*GetFieldDataInt64Ptr_FUNC(FieldData_pa fd
);
227 EXTERN Int64Rev_t
*GetFieldDataInt64RevPtr_FUNC(FieldData_pa fd
);
228 EXTERN Int32_t
*GetFieldDataInt32Ptr_FUNC(FieldData_pa fd
);
229 EXTERN Int32Rev_t
*GetFieldDataInt32RevPtr_FUNC(FieldData_pa fd
);
230 EXTERN Int16_t
*GetFieldDataInt16Ptr_FUNC(FieldData_pa fd
);
231 EXTERN Int16Rev_t
*GetFieldDataInt16RevPtr_FUNC(FieldData_pa fd
);
232 EXTERN Byte_t
*GetFieldDataBytePtr_FUNC(FieldData_pa fd
);
233 EXTERN UInt16_t
*GetFieldData2BytePtr_FUNC(FieldData_pa fd
);
234 EXTERN UInt32_t
*GetFieldData4BytePtr_FUNC(FieldData_pa fd
);
235 EXTERN UInt64_t
*GetFieldData8BytePtr_FUNC(FieldData_pa fd
);
236 EXTERN
void *GetFieldDataVoidPtr_FUNC(FieldData_pa fd
); /*danger:see above*/
241 EXTERN FieldData_pa
AllocScratchNodalFieldDataPtr(LgIndex_t NumValues
,
242 FieldDataType_e Type
,
243 Boolean_t ShowErrMsg
);
247 EXTERN
void DeallocScratchNodalFieldDataPtr(FieldData_pa
*ScratchFieldData
);
250 * Assume that indexrange has already been converted to the actual indices.
252 EXTERN
void CalcFieldDataMinMaxUsingRange(FieldData_pa field_data
,
255 LgIndex_t startindex
,
256 IndexRange_s
*indexrange
);
258 #if defined TECPLOTKERNEL
259 /* CORE SOURCE CODE REMOVED */
262 #if defined TECPLOTKERNEL
263 /* CORE SOURCE CODE REMOVED */
266 #if defined TECPLOTKERNEL
267 /* CORE SOURCE CODE REMOVED */
270 #if defined TECPLOTKERNEL
271 /* CORE SOURCE CODE REMOVED */
276 EXTERN
void CopyTypedValueArray(FieldDataType_e ValueType
,
283 EXTERN
void SwapBytesInTypedValueArray(FieldDataType_e ValueType
,
289 EXTERN
void SwapBytesInUnalignedTypedValueArray(FieldDataType_e ValueType
,
297 * Copies values from "src" to "dst". "src" or "dst" may
298 * be differing types. Either or both may be V3D data pointers.
300 EXTERN
void CopyFieldDataRange(FieldData_pa dst
,
304 LgIndex_t src_end
); /* -1 means last point */
307 * Copy all values in field data
309 EXTERN
void CopyFieldData(FieldData_pa dst
,
313 * Like CopyFieldData except for single value.
315 EXTERN
void CopyFieldValue(FieldData_pa dst
,
321 #if defined TECPLOTKERNEL
322 /* CORE SOURCE CODE REMOVED */
325 #if defined TECPLOTKERNEL
326 /* CORE SOURCE CODE REMOVED */
329 #if defined TECPLOTKERNEL
330 /* CORE SOURCE CODE REMOVED */
333 #if defined TECPLOTKERNEL
334 /* CORE SOURCE CODE REMOVED */
338 * Sets all values in the field data pointer "field_data"
341 EXTERN
void SetFieldDataPtrToAllZeros(FieldData_pa field_data
);
344 * GetFieldValue macro
346 #if !defined GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION && \
347 !defined GET_FIELD_VALUE_BY_FLOAT_ONLY_MACRO && \
348 !defined GET_FIELD_VALUE_BY_DOUBLE_ONLY_MACRO && \
349 !defined GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO
350 #if !defined NO_ASSERTS || defined DEBUG_FIELDVALUES
351 #define GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION
353 #define GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO
357 #if defined GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION
358 #define GetFieldValue(fd,pt) ((GetFieldDataGetFunction(fd))((fd),(pt)))
359 #elif defined GET_FIELD_VALUE_BY_FLOAT_ONLY_MACRO
360 #define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForFloat \
361 ?GetFieldDataFloatPtr(fd)[(pt)] \
362 :(GetFieldDataGetFunction(fd))((fd),(pt)))
363 #elif defined GET_FIELD_VALUE_BY_DOUBLE_ONLY_MACRO
364 #define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForDouble \
365 ?GetFieldDataDoublePtr(fd)[(pt)] \
366 :(GetFieldDataGetFunction(fd))((fd),(pt)))
367 #elif defined GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO
368 #define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForFloat \
369 ?GetFieldDataFloatPtr(fd)[(pt)] \
370 :GetFieldDataGetFunction(fd)==GetFieldValueForDouble \
371 ?GetFieldDataDoublePtr(fd)[(pt)] \
372 :(GetFieldDataGetFunction(fd))((fd),(pt)))
374 #error "Need to define one of FIELD_VALUE_MACRO constants"
379 * SetFieldValue macro
381 #define SetFieldValue(fd,pt,val) ((GetFieldDataSetFunction(fd))((fd),(pt),(val)))
384 #if defined TECPLOTKERNEL
385 /* CORE SOURCE CODE REMOVED */
386 #endif /* TECPLOTKERNEL */
389 #define USEFUNCTIONSFORNODEVALUES
392 #if defined TECPLOTKERNEL
393 /* CORE SOURCE CODE REMOVED */
394 #if !defined NO_ASSERTS
396 #endif /* TECPLOTKERNEL */
398 #if defined TECPLOTKERNEL
399 /* CORE SOURCE CODE REMOVED */
400 #endif /* TECPLOTKERNEL */
402 #if defined TECPLOTKERNEL
403 /* CORE SOURCE CODE REMOVED */