PageRenderTime 73ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/tecxxx.cpp

https://github.com/Ingenierias2003/OpenFOAM-1.7.x
C++ | 4812 lines | 4687 code | 48 blank | 77 comment | 98 complexity | 5fe49e9e034ec3c2048bcba2da04635a MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM
  3. *
  4. * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide.
  5. *
  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.
  13. *
  14. * This limited grant of distribution does not supersede Tecplot, Inc.'s
  15. * copyright in TecIO. Contact Tecplot, Inc. for further information.
  16. *
  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/
  22. *
  23. */
  24. #include "stdafx.h"
  25. #include "MASTER.h"
  26. #define TECPLOTENGINEMODULE
  27. /*
  28. ******************************************************************
  29. ******************************************************************
  30. ******* ********
  31. ****** (C) 1988-2008 Tecplot, Inc. *******
  32. ******* ********
  33. ******************************************************************
  34. ******************************************************************
  35. */
  36. /* Source file revision $Revision: 7627 $ */
  37. #include "GLOBAL.h"
  38. #include "TASSERT.h"
  39. #include "Q_UNICODE.h"
  40. #include "SYSTEM.h"
  41. #include "FILESTREAM.h"
  42. #if defined TECPLOTKERNEL
  43. /* CORE SOURCE CODE REMOVED */
  44. #endif
  45. #include "DATAIO4.h"
  46. #include "DATASET0.h"
  47. #include "TECXXX.h"
  48. #include "DATAUTIL.h"
  49. #include "ALLOC.h"
  50. #include <vector>
  51. #if !defined MAKEARCHIVE
  52. #include "AUXDATA.h"
  53. #endif /* MAKEARCHIVE */
  54. #if defined MSWIN
  55. #include <io.h>
  56. #endif
  57. #if defined UNIXX
  58. #include <stdio.h>
  59. #include <sys/types.h>
  60. #include <sys/stat.h>
  61. #endif
  62. #if defined TECPLOTKERNEL
  63. /* CORE SOURCE CODE REMOVED */
  64. #endif
  65. using namespace std;
  66. #if defined MAKEARCHIVE
  67. #if defined MSWIN && defined _DEBUG
  68. /* For debug .dll builds, send debug info to debug window. */
  69. #define PRINT0(s) do { OutputDebugString(s); } while (0)
  70. #define PRINT1(s,a1) do { char buffer[512]; sprintf(buffer,s,a1); OutputDebugString(buffer); } while (0)
  71. #define PRINT2(s,a1,a2) do { char buffer[512]; sprintf(buffer,s,a1,a2); OutputDebugString(buffer); } while (0)
  72. #else
  73. /* For all other builds (including release .dll), send debug info to stdout. */
  74. #define PRINT0(s) printf(s)
  75. #define PRINT1(s,a1) printf(s,a1)
  76. #define PRINT2(s,a1,a2) printf(s,a1,a2)
  77. #endif
  78. #else
  79. #if defined MSWIN
  80. /* For nonarchive, Windows, don't send debug info. */
  81. #define PRINT0(s) ((void)0)
  82. #define PRINT1(s,a1) ((void)0)
  83. #define PRINT2(s,a1,a2) ((void)0)
  84. #else
  85. /* For nonarchive, nonwindows, send debug info to stdout. */
  86. #define PRINT0(s) printf(s)
  87. #define PRINT1(s,a1) printf(s,a1)
  88. #define PRINT2(s,a1,a2) printf(s,a1,a2)
  89. #endif
  90. #endif
  91. typedef char *FNameType;
  92. typedef FILE *FilePtr;
  93. #define MaxNumFiles 10
  94. #define MAX_DUPLIST_VARS 50 /* maybe crank up in the future */
  95. #define BYTES_PER_CHUNK 4096
  96. #define TECIO_NO_NEIGHBORING_ELEM 0
  97. #define TECIO_NO_NEIGHBORING_ZONE 0
  98. #if defined MAKEARCHIVE
  99. static LgIndex_t DebugLevel[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  100. #endif
  101. static INTEGER4 IsOpen[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  102. static INTEGER4 NumErrs[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  103. static INTEGER4 NumVars[MaxNumFiles];
  104. static FNameType DestFName[MaxNumFiles] = {NULL, NULL, NULL, NULL, NULL,
  105. NULL, NULL, NULL, NULL, NULL
  106. };
  107. static FNameType BlckFName[MaxNumFiles] = {NULL, NULL, NULL, NULL, NULL,
  108. NULL, NULL, NULL, NULL, NULL
  109. };
  110. static FileStream_s* BlckFile[MaxNumFiles];
  111. static FileStream_s* HeadFile[MaxNumFiles];
  112. static vector<FileOffset_t> MinMaxOffset[MaxNumFiles]; /* vector dimensioned by num zones */
  113. static vector<double> VarMinValue[MaxNumFiles]; /* vector dimensioned by num vars */
  114. static vector<double> VarMaxValue[MaxNumFiles]; /* vector dimensioned by num vars */
  115. static INTEGER4 DoWriteForeign = FALSE; /* ...default is to write native */
  116. static INTEGER4 IsWritingNative[MaxNumFiles];
  117. static INTEGER4 IsBlock[MaxNumFiles];
  118. static INTEGER4 ZoneType[MaxNumFiles];
  119. static LgIndex_t IMax[MaxNumFiles]; /* ones based indices */
  120. static LgIndex_t JMax[MaxNumFiles]; /* ones based indices */
  121. static LgIndex_t KMax[MaxNumFiles]; /* ones based indices */
  122. static vector<LgIndex_t> TotalNumFaceNodes[MaxNumFiles]; /* vector dimensioned by num zones */
  123. static LgIndex_t TotalNumFaceBndryFaces[MaxNumFiles];
  124. static LgIndex_t TotalNumFaceBndryConns[MaxNumFiles];
  125. static LgIndex_t ICellMax[MaxNumFiles];
  126. static LgIndex_t JCellMax[MaxNumFiles];
  127. static LgIndex_t KCellMax[MaxNumFiles];
  128. static vector<INTEGER4> NumFaceConnections[MaxNumFiles]; /* vector dimensioned by num zones */
  129. static INTEGER4 FaceNeighborMode[MaxNumFiles];
  130. static vector<INTEGER4> FaceNeighborsOrMapWritten[MaxNumFiles]; /* vector dimensioned by num zones */
  131. static INTEGER4 NumIndices[MaxNumFiles];
  132. static LgIndex_t NumDataValuesWritten[MaxNumFiles];
  133. static LgIndex_t NumOrderedCCDataValuesWritten[MaxNumFiles]; /* CC data only */
  134. static LgIndex_t NumDataValuesToWrite[MaxNumFiles];
  135. static vector<LgIndex_t> NumRunningVarValues[MaxNumFiles]; /* vector dimensioned by num vars */
  136. static vector<Boolean_t> IsSharedVar[MaxNumFiles]; /* vector dimensioned by num vars */
  137. static vector<Boolean_t> IsPassiveVar[MaxNumFiles]; /* vector dimensioned by num vars */
  138. static INTEGER4 CurZone[MaxNumFiles]; /* zero based zone numbers */
  139. static INTEGER4 CurVar[MaxNumFiles]; /* zero based var numbers */
  140. static INTEGER4 FieldDataType;
  141. static INTEGER4 CurFile = -1;
  142. static vector<Boolean_t> IsCellCentered[MaxNumFiles]; /* vector dimensioned by num vars */
  143. static Boolean_t HasFECONNECT[MaxNumFiles];
  144. static INTEGER4 FileTypes[MaxNumFiles];
  145. static vector<INTEGER4> NumConnectivityNodes[MaxNumFiles]; /* vector dimensioned by num zones */
  146. static vector<Boolean_t> ConnectivityWritten[MaxNumFiles]; /* vector dimensioned by num zones */
  147. /*
  148. * From preplot.cpp:
  149. *
  150. * ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE,
  151. * 3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK,
  152. * 6=FEPOLYGON,7=FEPOLYHEDRON
  153. */
  154. #define ORDERED 0
  155. #define FELINESEG 1
  156. #define FETRIANGLE 2
  157. #define FEQUADRILATERAL 3
  158. #define FETETRAHEDRON 4
  159. #define FEBRICK 5
  160. #define FEPOLYGON 6
  161. #define FEPOLYHEDRON 7
  162. /*
  163. * FileType 0=FULLFILE,1=GRIDFILE,2=SOLUTIONFILE
  164. */
  165. #define FULLFILE 0
  166. #define GRIDFILE 1
  167. #define SOLUTIONFILE 2
  168. #if defined MAKEARCHIVE
  169. static char const* ZoneTypes[] =
  170. {
  171. "ORDERED",
  172. "FELINESEG",
  173. "FETRIANGLE",
  174. "FEQUADRILATERAL",
  175. "FETETRAHEDRON",
  176. "FEBRICK",
  177. "FEPOLYGON",
  178. "FEPOLYHEDRON"
  179. };
  180. #endif /* MAKEARCHIVE */
  181. static void WriteErr(const char *routine_name)
  182. {
  183. #if defined MAKEARCHIVE
  184. PRINT2("Err: (%s) Write failure on file %d.\n", routine_name, CurFile + 1);
  185. #endif
  186. NumErrs[CurFile]++;
  187. }
  188. static LgIndex_t TecXXXZoneNum = 0;
  189. Boolean_t ParseDupList(LgIndex_t **ShareVarFromZone,
  190. LgIndex_t *ShareConnectivityFromZone,
  191. const char *DupList)
  192. {
  193. Boolean_t IsOk = TRUE;
  194. REQUIRE(VALID_REF(ShareVarFromZone) && *ShareVarFromZone == NULL);
  195. REQUIRE(VALID_REF(ShareConnectivityFromZone));
  196. REQUIRE(VALID_REF(DupList));
  197. while (IsOk && *DupList)
  198. {
  199. /* skip leading spaces */
  200. while (*DupList && *DupList == ' ')
  201. DupList++;
  202. /* is this the FECONNECT keyword? */
  203. if (*DupList && !strncmp(DupList, "FECONNECT", 9))
  204. *ShareConnectivityFromZone = TecXXXZoneNum;
  205. else if (*DupList && !isdigit(*DupList))
  206. IsOk = FALSE; /* syntax error */
  207. else if (*DupList)
  208. {
  209. char *NotUsed = NULL;
  210. EntIndex_t WhichVar = strtol(DupList, &NotUsed, 10);
  211. EntIndex_t numVarsForFile = NumVars[CurFile];
  212. if (0 < WhichVar && WhichVar < numVarsForFile)
  213. {
  214. if (!(*ShareVarFromZone))
  215. {
  216. *ShareVarFromZone = ALLOC_ARRAY(numVarsForFile, LgIndex_t, "Variable sharing list");
  217. if (*ShareVarFromZone)
  218. memset(*ShareVarFromZone, (char)0, numVarsForFile * sizeof(LgIndex_t));
  219. }
  220. if (*ShareVarFromZone)
  221. (*ShareVarFromZone)[WhichVar - 1] = TecXXXZoneNum;
  222. else
  223. IsOk = FALSE;
  224. }
  225. else
  226. {
  227. /* Invalid var num */
  228. IsOk = FALSE;
  229. }
  230. }
  231. /*
  232. * Skip to the comma. This
  233. * will also allow the syntax error
  234. * of more than one consecutive comma
  235. */
  236. while (*DupList && *DupList != ',')
  237. DupList++;
  238. /* skip past the comma (can handle the syntax error of more than 1 comma) */
  239. while (*DupList && *DupList == ',')
  240. DupList++;
  241. }
  242. return IsOk;
  243. }
  244. /**
  245. */
  246. static FileStream_s *OpenFileStream(const char *FilePath,
  247. const char *AccessMode,
  248. Boolean_t IsByteOrderNative)
  249. {
  250. REQUIRE(VALID_REF(FilePath));
  251. REQUIRE(VALID_REF(AccessMode));
  252. FileStream_s *Result = NULL;
  253. FILE *File = TP_FOPEN(FilePath, AccessMode);
  254. if (File != NULL)
  255. {
  256. Result = FileStreamAlloc(File, IsByteOrderNative);
  257. if (Result == NULL)
  258. TP_FCLOSE(File);
  259. }
  260. ENSURE((VALID_REF(Result) && VALID_REF(Result->File)) || Result == NULL);
  261. return Result;
  262. }
  263. /**
  264. */
  265. static void CloseFileStream(FileStream_s **FileStream)
  266. {
  267. REQUIRE(VALID_REF(FileStream));
  268. REQUIRE(VALID_REF(*FileStream) || *FileStream == NULL);
  269. if (*FileStream != NULL)
  270. {
  271. TP_FCLOSE((*FileStream)->File);
  272. FileStreamDealloc(FileStream);
  273. }
  274. ENSURE(*FileStream == NULL);
  275. }
  276. /**
  277. * Get the best terminator (separator) character to use for the string. First
  278. * precedence goes to the new line then the command and finally by default the
  279. * space. NOTE: We use a do loop to allow it to be used as a single statement.
  280. */
  281. #define GET_BEST_TERMINATOR_CHAR(CompoundStr, TerminatorChar) \
  282. do \
  283. { \
  284. if (strchr((CompoundStr), '\n') != NULL) \
  285. (TerminatorChar) = '\n'; \
  286. else if (strchr((CompoundStr), ',') != NULL) \
  287. (TerminatorChar) = ','; \
  288. else \
  289. (TerminatorChar) = ' '; \
  290. } while (0)
  291. /**
  292. * TECINIXXX
  293. */
  294. INTEGER4 LIBCALL TECINI112(char *Title,
  295. char *Variables,
  296. char *FName,
  297. char *ScratchDir,
  298. INTEGER4 *FileType,
  299. INTEGER4 *Debug,
  300. INTEGER4 *VIsDouble)
  301. {
  302. size_t L;
  303. int I;
  304. char RName[80];
  305. char *CPtr;
  306. int NewFile = -1;
  307. /*
  308. * Note that users should not mix TECXXX, TEC100XXX, and TEC110XXX calls, but
  309. * just in case, initialize the TecXXXZoneNum variable. It may not help, but
  310. * it doesn't hurt...
  311. */
  312. TecXXXZoneNum = 0;
  313. #if defined MAKEARCHIVE
  314. InitInputSpecs();
  315. #endif
  316. for (I = 0; (I < MaxNumFiles) && (NewFile == -1); I++)
  317. {
  318. if (!IsOpen[I])
  319. NewFile = I;
  320. }
  321. if (NewFile == -1)
  322. {
  323. #if defined MAKEARCHIVE
  324. PRINT1("Err: (TECINI112) Too many files (%d) opened for printing.\n", NewFile);
  325. #endif
  326. return (-1);
  327. }
  328. if (CurFile == -1)
  329. CurFile = 0;
  330. #if defined MAKEARCHIVE
  331. DebugLevel[NewFile] = *Debug;
  332. #endif
  333. /* check sizes for array sized by number of variables */
  334. CHECK(VarMinValue[NewFile].empty());
  335. CHECK(VarMaxValue[NewFile].empty());
  336. CHECK(NumRunningVarValues[NewFile].empty());
  337. CHECK(IsSharedVar[NewFile].empty());
  338. CHECK(IsPassiveVar[NewFile].empty());
  339. CHECK(IsCellCentered[NewFile].empty());
  340. /* check sizes for array sized by number of zones */
  341. CHECK(MinMaxOffset[NewFile].empty());
  342. CHECK(TotalNumFaceNodes[NewFile].empty());
  343. CHECK(NumFaceConnections[NewFile].empty());
  344. CHECK(FaceNeighborsOrMapWritten[NewFile].empty());
  345. CHECK(NumConnectivityNodes[NewFile].empty());
  346. CHECK(ConnectivityWritten[NewFile].empty());
  347. CurZone[NewFile] = -1;
  348. L = 0;
  349. if (FName != NULL)
  350. L = strlen(FName);
  351. if (L == 0)
  352. {
  353. #if defined MAKEARCHIVE
  354. PRINT1("Err: (TECINI112) Bad file name for file %d.\n", NewFile);
  355. #endif
  356. return (-1);
  357. }
  358. DestFName[NewFile] = ALLOC_ARRAY(L + 1, char, "data set fname");
  359. strcpy(DestFName[NewFile], FName);
  360. #if defined (DOS)
  361. {
  362. sprintf(RName, "BLCKFILE.%03d", (int)(NewFile + 1));
  363. }
  364. #else
  365. {
  366. sprintf(RName, "tp%1dXXXXXX", NewFile + 1);
  367. }
  368. #endif
  369. L = strlen(RName);
  370. if (ScratchDir != NULL)
  371. L += strlen(ScratchDir) + 1; /* +1 for the slash delimeter */
  372. BlckFName[NewFile] = ALLOC_ARRAY(L + 1, char, "data set fname");
  373. if (ScratchDir != NULL)
  374. {
  375. strcpy(BlckFName[NewFile], ScratchDir);
  376. #if defined DOS || defined MSWIN
  377. {
  378. strcat(BlckFName[NewFile], "\\");
  379. }
  380. #else
  381. {
  382. strcat(BlckFName[NewFile], "/");
  383. }
  384. #endif
  385. }
  386. else
  387. BlckFName[NewFile][0] = '\0';
  388. strcat(BlckFName[NewFile], RName);
  389. CHECK(strlen(BlckFName[NewFile]) <= L);
  390. #if defined MSWIN
  391. {
  392. _mktemp(BlckFName[NewFile]);
  393. }
  394. #elif defined UNIXX
  395. {
  396. /*
  397. * POSIX compiant behavior is to make
  398. * sure umask is set correctly first.
  399. */
  400. mode_t OrigUmask = umask(0022); /* ...should produce rw------- */
  401. int FileDesc = mkstemp(BlckFName[NewFile]);
  402. if (FileDesc != -1)
  403. close(FileDesc);
  404. umask(OrigUmask);
  405. }
  406. #endif
  407. #if defined MAKEARCHIVE
  408. if (DebugLevel[NewFile])
  409. {
  410. PRINT2("Scratch File #%d: %s\n", NewFile + 1, BlckFName[NewFile]);
  411. PRINT2("Dest File #%d: %s\n", NewFile + 1, DestFName[NewFile]);
  412. }
  413. #endif
  414. IsWritingNative[NewFile] = !DoWriteForeign;
  415. #if defined TECPLOTKERNEL
  416. /* CORE SOURCE CODE REMOVED */
  417. #endif
  418. HeadFile[NewFile] = OpenFileStream(DestFName[NewFile], "wb", IsWritingNative[NewFile]);
  419. BlckFile[NewFile] = OpenFileStream(BlckFName[NewFile], "wb", IsWritingNative[NewFile]);
  420. if (BlckFile[NewFile] == NULL)
  421. {
  422. #if defined MAKEARCHIVE
  423. PRINT0("Err: (TECINI112) Cannot open scratch file for output.\n");
  424. PRINT0(" Check permissions in scratch directory.\n");
  425. #endif
  426. NumErrs[NewFile]++;
  427. return (-1);
  428. }
  429. if (HeadFile[NewFile] == NULL)
  430. {
  431. #if defined MAKEARCHIVE
  432. PRINT0("Err: (TECINI112) Cannot open plot file. Check permissions.\n");
  433. #endif
  434. NumErrs[NewFile]++;
  435. return (-1);
  436. }
  437. writeBinaryVersionNumber(*HeadFile[NewFile],
  438. TecplotBinaryFileVersion);
  439. WriteBinaryMagic(HeadFile[NewFile]);
  440. /* Write file type */
  441. if (*FileType >= FULLFILE && *FileType <= SOLUTIONFILE)
  442. FileTypes[NewFile] = *FileType;
  443. else
  444. {
  445. #if defined MAKEARCHIVE
  446. PRINT0("Err: (TECINI112) Bad filetype argument. Check documentation.\n");
  447. #endif
  448. NumErrs[NewFile]++;
  449. return (-1);
  450. }
  451. CHECK(TecplotBinaryFileVersion == 112);
  452. if (!WriteBinaryInt32(HeadFile[NewFile], (LgIndex_t)FileTypes[NewFile]))
  453. {
  454. WriteErr("TECINI112");
  455. return (-1);
  456. }
  457. if (!DumpDatafileString(HeadFile[NewFile],
  458. Title,
  459. TRUE))
  460. {
  461. WriteErr("TECINI112");
  462. return (-1);
  463. }
  464. NumVars[NewFile] = 0;
  465. CPtr = Variables;
  466. /*
  467. * Three possible variable name separators are accepted with the following
  468. * precidence: newline, comma, and space.
  469. */
  470. {
  471. char terminator;
  472. GET_BEST_TERMINATOR_CHAR(CPtr, terminator);
  473. while (*CPtr)
  474. {
  475. /* strip leading spaces */
  476. while (*CPtr && *CPtr == ' ')
  477. CPtr++;
  478. if (*CPtr)
  479. {
  480. NumVars[NewFile]++;
  481. /* skip to terminating character */
  482. while (*CPtr && *CPtr != terminator)
  483. CPtr++;
  484. /* skip past terminating character */
  485. if (*CPtr)
  486. CPtr++;
  487. }
  488. }
  489. }
  490. #if 0
  491. /* A grid file can have no variables in it as long as there is a connectivity list */
  492. if (NumVars[NewFile] == 0 && FileTypes[NewFile] != GRIDFILE)
  493. {
  494. #if defined MAKEARCHIVE
  495. PRINT0("Err: (TECINI110) No variable names were defined.\n");
  496. #endif
  497. NumErrs[NewFile]++;
  498. return (-1);
  499. }
  500. #endif
  501. #if defined MAKEARCHIVE
  502. if (DebugLevel[NewFile])
  503. PRINT1("NumVars=%d\n", NumVars[NewFile]);
  504. #endif
  505. /* make sure var-sized arrays are big enough for all vars */
  506. try
  507. {
  508. VarMinValue[NewFile].resize(NumVars[NewFile]);
  509. VarMaxValue[NewFile].resize(NumVars[NewFile]);
  510. NumRunningVarValues[NewFile].resize(NumVars[NewFile]);
  511. IsSharedVar[NewFile].resize(NumVars[NewFile]);
  512. IsPassiveVar[NewFile].resize(NumVars[NewFile]);
  513. IsCellCentered[NewFile].resize(NumVars[NewFile]);
  514. }
  515. catch (std::bad_alloc const&)
  516. {
  517. #if defined MAKEARCHIVE
  518. PRINT0("Err: (TECINI112) Memory allocation error.\n");
  519. #endif
  520. NumErrs[NewFile]++;
  521. return (-1);
  522. }
  523. if (!WriteBinaryInt32(HeadFile[NewFile], (LgIndex_t)NumVars[NewFile]))
  524. {
  525. WriteErr("TECINI110");
  526. return (-1);
  527. }
  528. CPtr = Variables;
  529. {
  530. char terminator;
  531. char TString[MaxChrsVarName+1];
  532. int I;
  533. GET_BEST_TERMINATOR_CHAR(CPtr, terminator);
  534. while (*CPtr)
  535. {
  536. /* skip leading space characters */
  537. while (*CPtr && *CPtr == ' ')
  538. CPtr++;
  539. if (*CPtr)
  540. {
  541. I = 0;
  542. /* skip to terminator */
  543. while (*CPtr && *CPtr != terminator)
  544. {
  545. TString[I++] = *CPtr++;
  546. }
  547. /* skip past terminator */
  548. if (*CPtr)
  549. CPtr++;
  550. /* strip trailing spaces */
  551. I--;
  552. while (I >= 0 && TString[I] == ' ')
  553. I--;
  554. TString[I+1] = '\0';
  555. if (!DumpDatafileString(HeadFile[NewFile], TString, TRUE))
  556. {
  557. WriteErr("TECINI110");
  558. return (-1);
  559. }
  560. }
  561. }
  562. }
  563. IsOpen[NewFile] = 1;
  564. if (*VIsDouble)
  565. FieldDataType = FieldDataType_Double;
  566. else
  567. FieldDataType = FieldDataType_Float;
  568. return (0);
  569. }
  570. INTEGER4 LIBCALL TECINI111(char *Title,
  571. char *Variables,
  572. char *FName,
  573. char *ScratchDir,
  574. INTEGER4 *FileType,
  575. INTEGER4 *Debug,
  576. INTEGER4 *VIsDouble)
  577. {
  578. return TECINI112(Title,
  579. Variables,
  580. FName,
  581. ScratchDir,
  582. FileType,
  583. Debug,
  584. VIsDouble);
  585. }
  586. INTEGER4 LIBCALL TECINI110(char *Title,
  587. char *Variables,
  588. char *FName,
  589. char *ScratchDir,
  590. INTEGER4 *Debug,
  591. INTEGER4 *VIsDouble)
  592. {
  593. INTEGER4 FType = FULLFILE;
  594. TecXXXZoneNum = 0;
  595. return TECINI112(Title,
  596. Variables,
  597. FName,
  598. ScratchDir,
  599. &FType,
  600. Debug,
  601. VIsDouble);
  602. }
  603. INTEGER4 LIBCALL TECINI100(char *Title,
  604. char *Variables,
  605. char *FName,
  606. char *ScratchDir,
  607. INTEGER4 *Debug,
  608. INTEGER4 *VIsDouble)
  609. {
  610. INTEGER4 FType = FULLFILE;
  611. TecXXXZoneNum = 0;
  612. return TECINI112(Title,
  613. Variables,
  614. FName,
  615. ScratchDir,
  616. &FType,
  617. Debug,
  618. VIsDouble);
  619. }
  620. INTEGER4 LIBCALL TECINI(char *Title,
  621. char *Variables,
  622. char *FName,
  623. char *ScratchDir,
  624. INTEGER4 *Debug,
  625. INTEGER4 *VIsDouble)
  626. {
  627. INTEGER4 FType = FULLFILE;
  628. TecXXXZoneNum = 0;
  629. return TECINI112(Title,
  630. Variables,
  631. FName,
  632. ScratchDir,
  633. &FType,
  634. Debug,
  635. VIsDouble);
  636. }
  637. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  638. LIBFUNCTION INTEGER4 LIBCALL tecini112_(char *Title,
  639. char *Variables,
  640. char *FName,
  641. char *ScratchDir,
  642. INTEGER4 *FileType,
  643. INTEGER4 *Debug,
  644. INTEGER4 *VIsDouble)
  645. {
  646. return TECINI112(Title, Variables, FName, ScratchDir, FileType, Debug, VIsDouble);
  647. }
  648. LIBFUNCTION INTEGER4 LIBCALL tecini111_(char *Title,
  649. char *Variables,
  650. char *FName,
  651. char *ScratchDir,
  652. INTEGER4 *FileType,
  653. INTEGER4 *Debug,
  654. INTEGER4 *VIsDouble)
  655. {
  656. return TECINI112(Title, Variables, FName, ScratchDir, FileType, Debug, VIsDouble);
  657. }
  658. LIBFUNCTION INTEGER4 LIBCALL tecini110_(char *Title,
  659. char *Variables,
  660. char *FName,
  661. char *ScratchDir,
  662. INTEGER4 *Debug,
  663. INTEGER4 *VIsDouble)
  664. {
  665. INTEGER4 FType = FULLFILE;
  666. return TECINI112(Title, Variables, FName, ScratchDir, &FType, Debug, VIsDouble);
  667. }
  668. LIBFUNCTION INTEGER4 LIBCALL tecini100_(char *Title,
  669. char *Variables,
  670. char *FName,
  671. char *ScratchDir,
  672. INTEGER4 *Debug,
  673. INTEGER4 *VIsDouble)
  674. {
  675. INTEGER4 FType = FULLFILE;
  676. return TECINI112(Title, Variables, FName, ScratchDir, &FType, Debug, VIsDouble);
  677. }
  678. LIBFUNCTION INTEGER4 LIBCALL tecini_(char *Title,
  679. char *Variables,
  680. char *FName,
  681. char *ScratchDir,
  682. INTEGER4 *Debug,
  683. INTEGER4 *VIsDouble)
  684. {
  685. INTEGER4 FType = FULLFILE;
  686. return TECINI112(Title,
  687. Variables,
  688. FName,
  689. ScratchDir,
  690. &FType,
  691. Debug,
  692. VIsDouble);
  693. }
  694. #endif
  695. static int CheckData(const char *routine_name)
  696. {
  697. if (NumDataValuesToWrite[CurFile] != NumDataValuesWritten[CurFile])
  698. {
  699. #if defined MAKEARCHIVE
  700. PRINT2("Err: (%s) Wrong number of data values in file %d:\n", routine_name, CurFile + 1);
  701. PRINT2(" %d data values for Zone %d were processed,\n", NumDataValuesWritten[CurFile], CurZone[CurFile] + 1);
  702. PRINT1(" %d data values were expected.\n", NumDataValuesToWrite[CurFile]);
  703. #endif
  704. NumErrs[CurFile]++;
  705. return (-1);
  706. }
  707. return (0);
  708. }
  709. static int CheckFile(const char *routine_name)
  710. {
  711. if ((CurFile == -1) || (!IsOpen[CurFile]))
  712. {
  713. #if defined MAKEARCHIVE
  714. PRINT2("Err: (%s) Attempt to use invalid file (%d).\n",
  715. routine_name, CurFile + 1);
  716. #endif
  717. return (-1);
  718. }
  719. return (0);
  720. }
  721. /**
  722. * Advances CurVar[CurFile] to the next non-shared active variable. TECDATXXX
  723. * clients should not supply values for shared or passive variables.
  724. */
  725. static void AdvanceToNextVarWithValues(void)
  726. {
  727. /* search for the next variable with values */
  728. do
  729. {
  730. CurVar[CurFile]++;
  731. }
  732. while (CurVar[CurFile] < NumVars[CurFile] &&
  733. (IsSharedVar[CurFile][CurVar[CurFile]] ||
  734. IsPassiveVar[CurFile][CurVar[CurFile]]));
  735. }
  736. /**
  737. * TECZNEXXX
  738. */
  739. INTEGER4 LIBCALL TECZNE112(char *ZnTitle,
  740. INTEGER4 *ZnType,
  741. INTEGER4 *IMxOrNumPts,
  742. INTEGER4 *JMxOrNumElements,
  743. INTEGER4 *KMxOrNumFaces,
  744. INTEGER4 *ICellMx,
  745. INTEGER4 *JCellMx,
  746. INTEGER4 *KCellMx,
  747. double *SolutionTime,
  748. INTEGER4 *StrandID,
  749. INTEGER4 *ParentZone,
  750. INTEGER4 *IsBlk,
  751. INTEGER4 *NumFaceConn,
  752. INTEGER4 *FNMode,
  753. INTEGER4 *NumFaceNodes,
  754. INTEGER4 *NumFaceBndryFaces,
  755. INTEGER4 *NumFaceBndryConns,
  756. INTEGER4 *PassiveVarList,
  757. INTEGER4 *ValueLocation,
  758. INTEGER4 *ShareVarFromZone,
  759. INTEGER4 *ShareConnectivityFromZone)
  760. {
  761. int I;
  762. int IsOk = 1;
  763. if (CheckFile("TECZNE112") < 0)
  764. return (-1);
  765. if (CurZone[CurFile] > -1)
  766. {
  767. if (CheckData("TECZNE112") < 0)
  768. return (-1);
  769. }
  770. if (NumVars[CurFile] == 0)
  771. {
  772. WriteErr("TECZNE112");
  773. #if defined MAKEARCHIVE
  774. PRINT1("Err: (TECZNE112) Cannot write out zones if numvars is equal to zero (file %d).\n",
  775. CurFile + 1);
  776. #endif
  777. return (-1);
  778. }
  779. if (CurZone[CurFile] > MaxNumZonesOrVars - 2) /* -1 based */
  780. {
  781. WriteErr("TECZNE112");
  782. #if defined MAKEARCHIVE
  783. PRINT2("Err: (TECZNE112) Exceeded max number of zones (%d) in file %d.\n",
  784. MaxNumZonesOrVars, CurFile + 1);
  785. #endif
  786. return (-1);
  787. }
  788. if (*StrandID < -1)
  789. {
  790. #if defined MAKEARCHIVE
  791. PRINT2("Err: (TECZNE112) Invalid StrandID supplied for file %d, zone %d.\n",
  792. CurFile + 1, CurZone[CurFile] + 1 + 1);
  793. #endif
  794. return (-1);
  795. }
  796. if (*ParentZone < 0)
  797. {
  798. #if defined MAKEARCHIVE
  799. PRINT2("Err: (TECZNE112) Invalid ParentZone supplied for file %d, zone %d.\n",
  800. CurFile + 1, CurZone[CurFile] + 1 + 1);
  801. #endif
  802. return (-1);
  803. }
  804. /*
  805. * This is a temporary error. Point format should no longer be written to the file
  806. * and should instead be converted to block format before being written. Since the
  807. * conversion has not yet been implemented, it is an error to use point data.
  808. * TODO (JN): Remove this error when point to block conversion has been implemented.
  809. */
  810. if (*IsBlk != 1)
  811. {
  812. #if defined MAKEARCHIVE
  813. PRINT2("Err: (TECZNE112) Point data is not currently allowed. "
  814. " Please use block format for file %d, zone %d.\n",
  815. CurFile + 1, CurZone[CurFile] + 1 + 1);
  816. #endif
  817. return (-1);
  818. }
  819. NumDataValuesWritten[CurFile] = 0;
  820. NumOrderedCCDataValuesWritten[CurFile] = 0;
  821. CurZone[CurFile]++;
  822. /* Resize zone-dimensioned arrays (CurZone[] is 0-based) */
  823. try
  824. {
  825. MinMaxOffset[CurFile].resize(CurZone[CurFile] + 1);
  826. TotalNumFaceNodes[CurFile].resize(CurZone[CurFile] + 1);
  827. NumFaceConnections[CurFile].resize(CurZone[CurFile] + 1);
  828. FaceNeighborsOrMapWritten[CurFile].resize(CurZone[CurFile] + 1);
  829. NumConnectivityNodes[CurFile].resize(CurZone[CurFile] + 1);
  830. ConnectivityWritten[CurFile].resize(CurZone[CurFile] + 1);
  831. }
  832. catch (std::bad_alloc const&)
  833. {
  834. #if defined MAKEARCHIVE
  835. PRINT0("Err: (TECZNE112) Memory allocation error.\n");
  836. #endif
  837. NumErrs[CurFile]++;
  838. return (-1);
  839. }
  840. ZoneType[CurFile] = *ZnType;
  841. IMax[CurFile] = *IMxOrNumPts;
  842. JMax[CurFile] = *JMxOrNumElements;
  843. KMax[CurFile] = *KMxOrNumFaces;
  844. ICellMax[CurFile] = *ICellMx;
  845. JCellMax[CurFile] = *JCellMx;
  846. KCellMax[CurFile] = *KCellMx;
  847. /* Set the flags that connectivity, face neighbors or face map hasn't been written for the zone yet. */
  848. FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = FALSE;
  849. ConnectivityWritten[CurFile][CurZone[CurFile]] = FALSE;
  850. if (ZoneType[CurFile] == ZoneType_FEPolygon ||
  851. ZoneType[CurFile] == ZoneType_FEPolyhedron)
  852. {
  853. NumFaceConnections[CurFile][CurZone[CurFile]] = 0; /* ...not used for polytope data */
  854. FaceNeighborMode[CurFile] = 0; /* ...not used for polytope data */
  855. NumConnectivityNodes[CurFile][CurZone[CurFile]] = 0; /* ...not used for polytope data */
  856. IsBlock[CurFile] = TRUE; /* ...polytope data is always block */
  857. TotalNumFaceNodes[CurFile][CurZone[CurFile]] = *NumFaceNodes;
  858. TotalNumFaceBndryFaces[CurFile] = *NumFaceBndryFaces;
  859. TotalNumFaceBndryConns[CurFile] = *NumFaceBndryConns;
  860. }
  861. else /* ...classic data */
  862. {
  863. IsBlock[CurFile] = *IsBlk;
  864. NumFaceConnections[CurFile][CurZone[CurFile]] = *NumFaceConn;
  865. FaceNeighborMode[CurFile] = *FNMode;
  866. TotalNumFaceNodes[CurFile][CurZone[CurFile]] = 0; /* ...not used for classic data */
  867. TotalNumFaceBndryFaces[CurFile] = 0; /* ...not used for classic data */
  868. TotalNumFaceBndryConns[CurFile] = 0; /* ...not used for classic data */
  869. }
  870. WriteBinaryReal(HeadFile[CurFile],
  871. (double)ZoneMarker,
  872. FieldDataType_Float);
  873. if (!DumpDatafileString(HeadFile[CurFile],
  874. ZnTitle,
  875. TRUE))
  876. {
  877. WriteErr("TECZNE112");
  878. return (-1);
  879. }
  880. if ((ShareVarFromZone && *ShareConnectivityFromZone) &&
  881. CurZone[CurFile] == 0)
  882. {
  883. /* can't have a duplist if there's nothing to duplicate */
  884. IsOk = 0;
  885. }
  886. if (IsOk == 0)
  887. {
  888. #if defined MAKEARCHIVE
  889. PRINT1("Err: (TECZNE112) Bad zone format for file %d.\n", CurFile + 1);
  890. #endif
  891. NumErrs[CurFile]++;
  892. return (-1);
  893. }
  894. switch (ZoneType[CurFile])
  895. {
  896. case ORDERED:
  897. NumIndices[CurFile] = 0;
  898. break;
  899. case FELINESEG:
  900. NumIndices[CurFile] = 2;
  901. break;
  902. case FETRIANGLE:
  903. NumIndices[CurFile] = 3;
  904. break;
  905. case FEQUADRILATERAL:
  906. NumIndices[CurFile] = 4;
  907. break;
  908. case FETETRAHEDRON:
  909. NumIndices[CurFile] = 4;
  910. break;
  911. case FEBRICK:
  912. NumIndices[CurFile] = 8;
  913. break;
  914. }
  915. /* ...not used for poly or ordered data and don't count sharing or solution files. */
  916. if (ZoneType[CurFile] != ZoneType_FEPolygon &&
  917. ZoneType[CurFile] != ZoneType_FEPolyhedron &&
  918. *ShareConnectivityFromZone == 0 &&
  919. FileTypes[CurFile] != SOLUTIONFILE)
  920. NumConnectivityNodes[CurFile][CurZone[CurFile]] = NumIndices[CurFile] * JMax[CurFile];
  921. /*
  922. * We do not check any return values until the end. If these calls fail,
  923. * WriteFieldDataType below should fail as well.
  924. */
  925. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(*ParentZone) - 1); /* ...ParentZone is zero based for binary file */
  926. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(*StrandID) - 1); /* ...StrandID is zero based for binary file */
  927. WriteBinaryReal(HeadFile[CurFile], *SolutionTime, FieldDataType_Double);
  928. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t) - 1); /* No Zone Color Assignment */
  929. WriteBinaryInt32(HeadFile[CurFile], ZoneType[CurFile]);
  930. NumDataValuesToWrite[CurFile] = 0;
  931. for (I = 0; I < NumVars[CurFile]; I++)
  932. {
  933. IsSharedVar[CurFile][I] = (ShareVarFromZone != NULL && ShareVarFromZone[I] != 0); /* ...shared? */
  934. IsPassiveVar[CurFile][I] = (PassiveVarList != NULL && PassiveVarList[I] == 1); /* ...passive? */
  935. }
  936. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(ValueLocation != NULL ? 1 : 0)); /* ...are var locations specified? */
  937. if (ValueLocation)
  938. {
  939. for (I = 0; I < NumVars[CurFile]; I++)
  940. {
  941. int VIndex;
  942. LgIndex_t NumNodes;
  943. LgIndex_t NumCells;
  944. if (ZoneType[CurFile] == ORDERED)
  945. {
  946. NumNodes = IMax[CurFile] * JMax[CurFile] * KMax[CurFile];
  947. NumCells = (MAX(IMax[CurFile] - 1, 1) *
  948. MAX(JMax[CurFile] - 1, 1) *
  949. MAX(KMax[CurFile] - 1, 1));
  950. }
  951. else
  952. {
  953. NumNodes = IMax[CurFile];
  954. NumCells = JMax[CurFile];
  955. }
  956. if (IsSharedVar[CurFile][I])
  957. VIndex = ShareVarFromZone[I] - 1;
  958. else
  959. VIndex = I;
  960. if (VIndex == 0)
  961. NumRunningVarValues[CurFile][I] = 0;
  962. else
  963. NumRunningVarValues[CurFile][VIndex] = NumRunningVarValues[CurFile][VIndex-1];
  964. IsCellCentered[CurFile][VIndex] = (ValueLocation[I] == ValueLocation_CellCentered);
  965. if (ValueLocation[I] == ValueLocation_CellCentered)
  966. {
  967. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)1);
  968. if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
  969. {
  970. NumDataValuesToWrite[CurFile] += NumCells;
  971. NumRunningVarValues[CurFile][VIndex] += NumCells;
  972. }
  973. }
  974. else if (ValueLocation[I] == ValueLocation_Nodal)
  975. {
  976. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0);
  977. if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
  978. {
  979. NumDataValuesToWrite[CurFile] += NumNodes;
  980. NumRunningVarValues[CurFile][VIndex] += NumNodes;
  981. }
  982. }
  983. else
  984. {
  985. #if defined MAKEARCHIVE
  986. PRINT2("Err: (TECZNE112) Bad zone value location for file %d, variable %d.\n", CurFile + 1, I + 1);
  987. #endif
  988. NumErrs[CurFile]++;
  989. return(-1);
  990. }
  991. }
  992. }
  993. else
  994. {
  995. LgIndex_t NumNodes;
  996. if (ZoneType[CurFile] == ORDERED)
  997. {
  998. NumNodes = IMax[CurFile] * JMax[CurFile] * KMax[CurFile];
  999. }
  1000. else
  1001. {
  1002. NumNodes = IMax[CurFile];
  1003. }
  1004. for (I = 0; I < NumVars[CurFile]; I++)
  1005. {
  1006. int VIndex;
  1007. if (IsSharedVar[CurFile][I])
  1008. VIndex = ShareVarFromZone[I] - 1;
  1009. else
  1010. VIndex = I;
  1011. if (VIndex == 0)
  1012. NumRunningVarValues[CurFile][I] = 0;
  1013. else
  1014. NumRunningVarValues[CurFile][VIndex] = NumRunningVarValues[CurFile][VIndex-1];
  1015. IsCellCentered[CurFile][VIndex] = FALSE;
  1016. if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
  1017. {
  1018. NumDataValuesToWrite[CurFile] += NumNodes;
  1019. NumRunningVarValues[CurFile][VIndex] += NumNodes;
  1020. }
  1021. }
  1022. }
  1023. /*
  1024. * As of binary version 108 Tecplot introduced
  1025. * the ability to output its auto-generated face
  1026. * neighbor array in its raw form. For now
  1027. * TecIO will always decline to perform this
  1028. * step and instead fall back to the delivering
  1029. * one neighbor at a time.
  1030. */
  1031. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); /* IsRawFNAvailable */
  1032. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)NumFaceConnections[CurFile][CurZone[CurFile]]);
  1033. if (NumFaceConnections[CurFile][CurZone[CurFile]] > 0)
  1034. {
  1035. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)FaceNeighborMode[CurFile]);
  1036. if (ZoneType[CurFile] != ORDERED)
  1037. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); /* FEFaceNeighborsComplete */
  1038. }
  1039. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)IMax[CurFile]);
  1040. if (ZoneType[CurFile] == FEPOLYGON ||
  1041. ZoneType[CurFile] == FEPOLYHEDRON)
  1042. {
  1043. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KMax[CurFile]);
  1044. /*
  1045. * As of binary version 111 these items moved from the data section to
  1046. * the header.
  1047. */
  1048. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceNodes[CurFile][CurZone[CurFile]]);
  1049. if (TotalNumFaceBndryFaces[CurFile] > 0)
  1050. {
  1051. /* Each boundary face must have >= 1 boundary connection. */
  1052. if (TotalNumFaceBndryConns[CurFile] < TotalNumFaceBndryFaces[CurFile])
  1053. {
  1054. #if defined MAKEARCHIVE
  1055. PRINT1("Err: (TECZNE112) There must be at least 1 boundary connection for each boundary face in zone %d.\n",
  1056. CurZone[CurFile] + 1);
  1057. PRINT2(" %d boundary faces and %d boundary connections were specified.\n",
  1058. TotalNumFaceBndryFaces[CurFile], TotalNumFaceBndryConns[CurFile]);
  1059. #endif
  1060. NumErrs[CurFile]++;
  1061. return(-1);
  1062. }
  1063. /*
  1064. * As a convenience for the ASCII format, TecUtil, and TECIO layers if any
  1065. * boundary connections exists we automatically add a no-neighboring
  1066. * connection as the first item so that they can user 0 for no-neighboring
  1067. * element in the element list regardless if they have boundary connections
  1068. * or not.
  1069. */
  1070. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryFaces[CurFile] + 1); /* ...add a boundary face for no neighboring element as a convenience */
  1071. }
  1072. else
  1073. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryFaces[CurFile]);
  1074. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryConns[CurFile]);
  1075. }
  1076. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)JMax[CurFile]);
  1077. if (ZoneType[CurFile] == ORDERED)
  1078. {
  1079. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KMax[CurFile]);
  1080. }
  1081. else
  1082. {
  1083. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)ICellMax[CurFile]);
  1084. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)JCellMax[CurFile]);
  1085. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KCellMax[CurFile]);
  1086. }
  1087. /*
  1088. * Aux data. This has to be over-written by the aux data writing routine.
  1089. * Because it currently at the end of the header section we don't need to
  1090. * keep track of the position for seeking back to it.
  1091. */
  1092. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0);
  1093. WriteBinaryReal(BlckFile[CurFile],
  1094. (double)ZoneMarker,
  1095. FieldDataType_Float);
  1096. for (I = 0; I < NumVars[CurFile]; I++)
  1097. {
  1098. if (!WriteFieldDataType(BlckFile[CurFile],
  1099. (FieldDataType_e)FieldDataType,
  1100. TRUE))
  1101. {
  1102. WriteErr("TECZNE112");
  1103. return (-1);
  1104. }
  1105. }
  1106. /* Passive variable identification */
  1107. if (PassiveVarList)
  1108. {
  1109. WriteBinaryInt32(BlckFile[CurFile], 1);
  1110. for (I = 0; I < NumVars[CurFile]; I++)
  1111. WriteBinaryInt32(BlckFile[CurFile], PassiveVarList[I]);
  1112. }
  1113. else
  1114. WriteBinaryInt32(BlckFile[CurFile], 0);
  1115. /* get the CurVar[CurFile] on the first active variable */
  1116. CurVar[CurFile] = -1;
  1117. AdvanceToNextVarWithValues();
  1118. /* Variable & Connectivity Sharing */
  1119. if (ShareVarFromZone)
  1120. {
  1121. WriteBinaryInt32(BlckFile[CurFile], 1);
  1122. for (I = 0; I < NumVars[CurFile]; I++)
  1123. WriteBinaryInt32(BlckFile[CurFile], ShareVarFromZone[I] - 1);
  1124. }
  1125. else
  1126. WriteBinaryInt32(BlckFile[CurFile], 0);
  1127. WriteBinaryInt32(BlckFile[CurFile], *ShareConnectivityFromZone - 1);
  1128. /*
  1129. * Create place holders or the variable min/max value. We will come back
  1130. * later after writing the data portion with the real min/max values. In the
  1131. * mean time, keep track of the starting point so we can seek back to this
  1132. * place.
  1133. */
  1134. MinMaxOffset[CurFile][CurZone[CurFile]] = (FileOffset_t)TP_FTELL(BlckFile[CurFile]->File);
  1135. for (I = 0; I < NumVars[CurFile]; I++)
  1136. {
  1137. /* initialize to unset values */
  1138. VarMinValue[CurFile][I] = LARGEDOUBLE;
  1139. VarMaxValue[CurFile][I] = -LARGEDOUBLE;
  1140. if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
  1141. {
  1142. WriteBinaryReal(BlckFile[CurFile], 0.0, FieldDataType_Double);
  1143. WriteBinaryReal(BlckFile[CurFile], 0.0, FieldDataType_Double);
  1144. }
  1145. }
  1146. #if defined MAKEARCHIVE
  1147. if (DebugLevel[CurFile])
  1148. {
  1149. PRINT1("Writing Zone %d:\n", CurZone[CurFile] + 1);
  1150. PRINT1(" Title = %s\n", ZnTitle);
  1151. PRINT1(" Type = %s\n", ZoneTypes[ZoneType[CurFile]]);
  1152. PRINT1(" IMax = %d\n", IMax[CurFile]);
  1153. PRINT1(" JMax = %d\n", JMax[CurFile]);
  1154. PRINT1(" KMax = %d\n", KMax[CurFile]);
  1155. if (ShareVarFromZone)
  1156. {
  1157. char DupList[1024] = "";
  1158. for (I = 0; I < NumVars[CurFile]; I++)
  1159. {
  1160. if (I > 0)
  1161. strcat(DupList, ",");
  1162. sprintf(&DupList[strlen(DupList)], "%d", ShareVarFromZone[I]);
  1163. }
  1164. PRINT1(" DupList = %s\n", DupList);
  1165. }
  1166. }
  1167. #endif
  1168. return (0);
  1169. }
  1170. INTEGER4 LIBCALL TECZNE111(char *ZnTitle,
  1171. INTEGER4 *ZnType,
  1172. INTEGER4 *IMxOrNumPts,
  1173. INTEGER4 *JMxOrNumElements,
  1174. INTEGER4 *KMxOrNumFaces,
  1175. INTEGER4 *ICellMx,
  1176. INTEGER4 *JCellMx,
  1177. INTEGER4 *KCellMx,
  1178. double *SolutionTime,
  1179. INTEGER4 *StrandID,
  1180. INTEGER4 *ParentZone,
  1181. INTEGER4 *IsBlk,
  1182. INTEGER4 *NumFaceConn,
  1183. INTEGER4 *FNMode,
  1184. INTEGER4 *NumFaceNodes,
  1185. INTEGER4 *NumFaceBndryFaces,
  1186. INTEGER4 *NumFaceBndryConns,
  1187. INTEGER4 *PassiveVarList,
  1188. INTEGER4 *ValueLocation,
  1189. INTEGER4 *ShareVarFromZone,
  1190. INTEGER4 *ShareConnectivityFromZone)
  1191. {
  1192. return TECZNE112(ZnTitle,
  1193. ZnType,
  1194. IMxOrNumPts,
  1195. JMxOrNumElements,
  1196. KMxOrNumFaces,
  1197. ICellMx,
  1198. JCellMx,
  1199. KCellMx,
  1200. SolutionTime,
  1201. StrandID,
  1202. ParentZone,
  1203. IsBlk,
  1204. NumFaceConn,
  1205. FNMode,
  1206. NumFaceNodes,
  1207. NumFaceBndryFaces,
  1208. NumFaceBndryConns,
  1209. PassiveVarList,
  1210. ValueLocation,
  1211. ShareVarFromZone,
  1212. ShareConnectivityFromZone);
  1213. }
  1214. INTEGER4 LIBCALL TECZNE110(char *ZnTitle,
  1215. INTEGER4 *ZnType,
  1216. INTEGER4 *IMxOrNumPts,
  1217. INTEGER4 *JMxOrNumElements,
  1218. INTEGER4 *KMx,
  1219. INTEGER4 *ICellMx,
  1220. INTEGER4 *JCellMx,
  1221. INTEGER4 *KCellMx,
  1222. double *SolutionTime,
  1223. INTEGER4 *StrandID,
  1224. INTEGER4 *ParentZone,
  1225. INTEGER4 *IsBlk,
  1226. INTEGER4 *NumFaceConn,
  1227. INTEGER4 *FNMode,
  1228. INTEGER4 *PassiveVarList,
  1229. INTEGER4 *ValueLocation,
  1230. INTEGER4 *ShareVarFromZone,
  1231. INTEGER4 *ShareConnectivityFromZone)
  1232. {
  1233. INTEGER4 NumFaceNodes = 0;
  1234. INTEGER4 NumFaceBndryFaces = 0;
  1235. INTEGER4 NumFaceBndryConns = 0;
  1236. return TECZNE112(ZnTitle,
  1237. ZnType,
  1238. IMxOrNumPts,
  1239. JMxOrNumElements,
  1240. KMx,
  1241. ICellMx,
  1242. JCellMx,
  1243. KCellMx,
  1244. SolutionTime,
  1245. StrandID,
  1246. ParentZone,
  1247. IsBlk,
  1248. NumFaceConn,
  1249. FNMode,
  1250. &NumFaceNodes,
  1251. &NumFaceBndryFaces,
  1252. &NumFaceBndryConns,
  1253. PassiveVarList,
  1254. ValueLocation,
  1255. ShareVarFromZone,
  1256. ShareConnectivityFromZone);
  1257. }
  1258. INTEGER4 LIBCALL TECZNE100(char *ZnTitle,
  1259. INTEGER4 *ZnType,
  1260. INTEGER4 *IMxOrNumPts,
  1261. INTEGER4 *JMxOrNumElements,
  1262. INTEGER4 *KMx,
  1263. INTEGER4 *ICellMx,
  1264. INTEGER4 *JCellMx,
  1265. INTEGER4 *KCellMx,
  1266. INTEGER4 *IsBlk,
  1267. INTEGER4 *NumFaceConn,
  1268. INTEGER4 *FNMode,
  1269. INTEGER4 *ValueLocation,
  1270. INTEGER4 *ShareVarFromZone,
  1271. INTEGER4 *ShareConnectivityFromZone)
  1272. {
  1273. double SolutionTime = 0.0;
  1274. INTEGER4 StrandID = STRAND_ID_STATIC + 1; /* TECXXX is ones based for StrandID */
  1275. INTEGER4 ParentZone = BAD_SET_VALUE + 1; /* TECXXX is ones based for ParentZone */
  1276. INTEGER4 NumFaceNodes = 0;
  1277. INTEGER4 NumFaceBndryFaces = 0;
  1278. INTEGER4 NumFaceBndryConns = 0;
  1279. return TECZNE112(ZnTitle,
  1280. ZnType,
  1281. IMxOrNumPts,
  1282. JMxOrNumElements,
  1283. KMx,
  1284. ICellMx,
  1285. JCellMx,
  1286. KCellMx,
  1287. &SolutionTime,
  1288. &StrandID,
  1289. &ParentZone,
  1290. IsBlk,
  1291. NumFaceConn,
  1292. FNMode,
  1293. &NumFaceNodes,
  1294. &NumFaceBndryFaces,
  1295. &NumFaceBndryConns,
  1296. NULL, /* PassiveVarList */
  1297. ValueLocation,
  1298. ShareVarFromZone,
  1299. ShareConnectivityFromZone);
  1300. }
  1301. #if !defined INDEX_16_BIT // not supported in this test-only mode
  1302. INTEGER4 LIBCALL TECZNE(char *ZoneTitle,
  1303. INTEGER4 *IMx,
  1304. INTEGER4 *JMx,
  1305. INTEGER4 *KMx,
  1306. char *ZFormat,
  1307. char *DupList)
  1308. {
  1309. LgIndex_t ZoneType;
  1310. LgIndex_t IsBlock;
  1311. LgIndex_t *ShareVarFromZone = NULL;
  1312. LgIndex_t ShareConnectivityFromZone;
  1313. LgIndex_t Result = 0;
  1314. if (ZFormat == NULL)
  1315. Result = -1;
  1316. else if (!strcmp(ZFormat, "BLOCK"))
  1317. {
  1318. IsBlock = 1;
  1319. ZoneType = ZoneType_Ordered;
  1320. }
  1321. else if (!strcmp(ZFormat, "FEBLOCK"))
  1322. {
  1323. IsBlock = 1;
  1324. switch (*KMx)
  1325. {
  1326. /*
  1327. * From preplot.c:
  1328. *
  1329. * ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE,
  1330. * 3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK
  1331. */
  1332. case 0: /* Triangular. */
  1333. ZoneType = 2;
  1334. break;
  1335. case 1: /* Quadrilateral */

Large files files are truncated, but you can click here to view the full file