foam to Tecplot360 converter
[OpenFOAM-1.6.x.git] / applications / utilities / postProcessing / dataConversion / foamToTecplot360 / tecio / tecsrc / dataset.cpp
blobfd35a87dcf20358649b4e6d518e28bdefa70c401
1 /*
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.
17 * Tecplot, Inc.
18 * 3535 Factoria Blvd, Ste. 550
19 * Bellevue, WA 98006, USA
20 * Phone: +1 425 653 1200
21 * http://www.tecplot.com/
24 #include "stdafx.h"
25 #include "MASTER.h"
26 #define TECPLOTENGINEMODULE
29 ******************************************************************
30 ******************************************************************
31 ******* ********
32 ****** (C) 1988-2008 Tecplot, Inc. *******
33 ******* ********
34 ******************************************************************
35 ******************************************************************
38 #define DATASETMODULE
39 #include "GLOBAL.h"
40 #include "TASSERT.h"
41 #include "Q_UNICODE.h"
42 #include "STRUTIL.h"
43 #include "AUXDATA.h"
44 #include "ARRLIST.h"
45 #include "STRLIST.h"
46 #include "ALLOC.h"
47 #include "SET.h"
48 #include "DATASET.h"
49 #include "FILESTREAM.h"
51 #if defined TECPLOTKERNEL
52 /* CORE SOURCE CODE REMOVED */
53 #endif
54 #include "DATASET0.h"
57 #include <float.h>
59 #if defined TECPLOTKERNEL
60 /* CORE SOURCE CODE REMOVED */
61 #endif
63 #if defined TECPLOTKERNEL
64 /* CORE SOURCE CODE REMOVED */
65 #if !defined ENGINE /* TODO(RMS)-H 12/12/2005: ENGINE: refactor to use just the Interrupted flag as-is */
66 #else
67 #endif
68 #endif
70 #if defined TECPLOTKERNEL
71 /* CORE SOURCE CODE REMOVED */
72 #if !defined USE_MACROS_FOR_FUNCTIONS
73 #endif
74 #if !defined USE_MACROS_FOR_FUNCTIONS
75 #endif
76 #endif /* TECPLOTKERNEL */
78 /**
79 * Cleanout the contents of the zone spec item but leaves the zone spec item.
80 * This effectively leaves the zone spec structure in the same state as calling
81 * ZoneSpecAlloc initially.
83 * param ZoneSpec
84 * Zone spec item to cleanup.
86 void CleanoutZoneSpec(ZoneSpec_s *ZoneSpec)
88 REQUIRE(VALID_REF(ZoneSpec));
90 if (ZoneSpec->Name != NULL)
91 FREE_ARRAY(ZoneSpec->Name, "ZoneSpec name");
92 if (ZoneSpec->AuxData != NULL)
93 AuxDataDealloc(&ZoneSpec->AuxData);
94 SetZoneSpecDefaults(ZoneSpec);
98 /**
100 void ZoneSpecDealloc(ZoneSpec_s **ZoneSpec)
102 REQUIRE(VALID_REF(ZoneSpec));
103 REQUIRE(VALID_REF(*ZoneSpec) || *ZoneSpec == NULL);
105 if (*ZoneSpec != NULL)
107 CleanoutZoneSpec(*ZoneSpec);
109 FREE_ITEM(*ZoneSpec, "ZoneSpec structure");
110 *ZoneSpec = NULL;
113 ENSURE(*ZoneSpec == NULL);
118 Boolean_t ZoneSpecItemDestructor(void *ItemRef,
119 ArbParam_t ClientData)
121 ZoneSpec_s **ZoneSpecRef = (ZoneSpec_s **)ItemRef;
123 REQUIRE(VALID_REF(ZoneSpecRef));
124 REQUIRE(VALID_REF(*ZoneSpecRef) || *ZoneSpecRef == NULL);
126 if (*ZoneSpecRef != NULL)
127 ZoneSpecDealloc(ZoneSpecRef);
129 ENSURE(*ZoneSpecRef == NULL);
130 return TRUE;
135 void SetZoneSpecDefaults(ZoneSpec_s *ZoneSpec)
137 REQUIRE(VALID_REF(ZoneSpec));
138 ZoneSpec->Name = NULL;
139 ZoneSpec->UniqueID = INVALID_UNIQUE_ID;
140 ZoneSpec->ParentZone = BAD_SET_VALUE;
141 ZoneSpec->StrandID = STRAND_ID_STATIC;
142 ZoneSpec->SolutionTime = 0.0;
143 ZoneSpec->NumPtsI = 0;
144 ZoneSpec->NumPtsJ = 0;
145 ZoneSpec->NumPtsK = 0;
146 ZoneSpec->ICellDim = 0; // ...currently not used
147 ZoneSpec->JCellDim = 0; // ...currently not used
148 ZoneSpec->KCellDim = 0; // ...currently not used
149 ZoneSpec->Type = ZoneType_Ordered;
150 ZoneSpec->ZoneLoadInfo.PresetZoneColor = NoColor_C;
151 ZoneSpec->ZoneLoadInfo.IsInBlockFormat = TRUE;
152 ZoneSpec->AuxData = NULL;
153 ZoneSpec->BuildZoneOptInfo = TRUE;
155 /* classic data only */
156 ZoneSpec->FNMode = FaceNeighborMode_LocalOneToOne;
157 ZoneSpec->FNAreCellFaceNbrsSupplied = FALSE;
159 /* polytope data only */
160 ZoneSpec->NumFaceNodes = 0;
161 ZoneSpec->NumFaceBndryFaces = 0;
162 ZoneSpec->NumFaceBndryItems = 0;
166 #if defined TECPLOTKERNEL
167 /* CORE SOURCE CODE REMOVED */
168 #endif /* TECPLOTKERNEL */
172 void ZoneSpecExcludeBndryConnsFromMetrics(ZoneSpec_s* ZoneSpec)
174 REQUIRE(VALID_REF(ZoneSpec));
176 /* classic data face connectivity fixup (leave FNMode as-is) */
177 ZoneSpec->FNAreCellFaceNbrsSupplied = FALSE; // ...if we invalidate boundary connections CellFaceNbrs must now be auto-generated
179 /* polytope data face connectivity fixup */
180 ZoneSpec->NumFaceBndryFaces = 0;
181 ZoneSpec->NumFaceBndryItems = 0;
186 ZoneSpec_s *ZoneSpecAlloc(void)
188 ZoneSpec_s *Result;
190 Result = (ZoneSpec_s *)ALLOC_ITEM(ZoneSpec_s, "ZoneSpec structure");
191 if (Result != NULL)
192 SetZoneSpecDefaults(Result);
194 ENSURE(Result == NULL || VALID_REF(Result));
195 return Result;
198 #if defined TECPLOTKERNEL
199 /* CORE SOURCE CODE REMOVED */
200 #endif
202 #if defined TECPLOTKERNEL
203 /* CORE SOURCE CODE REMOVED */
204 #endif
206 #if defined TECPLOTKERNEL
207 /* CORE SOURCE CODE REMOVED */
208 #endif
212 #if defined TECPLOTKERNEL
213 /* CORE SOURCE CODE REMOVED */
214 #endif
217 * Adjusts the capacity request as necessary to minimize memory reallocations
218 * for large lists. The adjusted capacity will be at least as big as requested
219 * however it may be larger if it is determined that the space requirement is
220 * growing faster.
222 * param ZoneOrVarArrayList
223 * Array list requesting the change in capacity.
224 * param CurrentCapacity
225 * Current capacity of the array list.
226 * param RequestedCapacity
227 * Capacity request or zero for default size.
228 * param ClientData
229 * Any client data needed for the adjustment.
231 * return
232 * Adjusted capacity that is at least as large as the request or zero if
233 * unable to satisfy the requested capacity.
235 LgIndex_t ZoneOrVarListAdjustCapacityRequest(ArrayList_pa ZoneOrVarArrayList,
236 LgIndex_t CurrentCapacity,
237 LgIndex_t RequestedCapacity,
238 ArbParam_t ClientData)
240 LgIndex_t Result;
242 REQUIRE(ArrayListIsValid(ZoneOrVarArrayList));
243 REQUIRE((RequestedCapacity == 0 && CurrentCapacity == 0) ||
244 RequestedCapacity > CurrentCapacity);
245 REQUIRE(CurrentCapacity <= MaxNumZonesOrVars);
247 if (RequestedCapacity <= MaxNumZonesOrVars)
249 if (RequestedCapacity != 0 && CurrentCapacity == 0)
251 /* first allocation; assume the request is the desired capacityy */
252 Result = RequestedCapacity;
254 else
256 const LgIndex_t DEFAULT_CAPACITY = 32;
257 LgIndex_t BlockSize = MAX(DEFAULT_CAPACITY, CurrentCapacity / 2);
258 if (RequestedCapacity == 0)
259 Result = DEFAULT_CAPACITY;
260 else
261 Result = ((RequestedCapacity - 1) / BlockSize + 1) * BlockSize;
263 /* put a cap on the maximum */
264 if (Result > MaxNumZonesOrVars)
265 Result = MaxNumZonesOrVars;
268 else
269 Result = 0; /* request exceeded maximum; unable to satisfy request */
271 ENSURE(Result == 0 || Result >= RequestedCapacity);
272 ENSURE(Result <= MaxNumZonesOrVars);
273 return Result;
277 #if defined TECPLOTKERNEL
278 /* CORE SOURCE CODE REMOVED */
279 #if !defined USE_MACROS_FOR_FUNCTIONS
280 #endif
281 # if defined DEBUGUNIQUE
282 # endif
283 #endif /* TECPLOTKERNEL */