2 * Complex example C program to write a
3 * binary data file for Tecplot. This example
6 * 1. Open a data file called "field.plt."
7 * 2. Open a data file called "line.plt."
8 * 3. Assign values for X, Y and P. These will be used
9 * in both the ordered and finite-element data files.
10 * 4. Write out an ordered zone dimensioned 4 x 5 to "field.plt."
11 * 5. Assign values for XL and YL arrays.
12 * 6. Write out data for line plot to "line.plt." Make the data
13 * use double precision.
14 * 7. Write out a finite-element zone to "field.plt."
15 * 8. Write out a text record to "field.plt."
16 * 9. Write out a geometry (circle) record to "field.plt."
27 float X
[5][4], Y
[5][4], P
[5][4];
28 double XL
[50], YL
[50];
30 INTEGER4 Debug
, I
, J
, K
, L
, III
, NPts
, NElm
, DIsDouble
, VIsDouble
, IMax
, JMax
, KMax
;
31 INTEGER4 ICellMax
, JCellMax
, KCellMax
, ZoneType
, Clipping
;
32 INTEGER4 StrandID
, ParentZn
, FieldFileType
, LineFileType
;
33 INTEGER4 SharingZone
[3] = {0, 0, 0};
34 INTEGER4 IsBlock
, NumFaceConnections
, FaceNeighborMode
, ShareConnectivityFromZone
;
36 double XP
, YP
, ZP
, FH
, LineSpacing
, PatternLength
;
37 double BoxMargin
, BoxLineThickness
, TextAngle
;
38 INTEGER4 AttachToZone
, Zone
, Scope
, PositionCoordSys
, FontType
, HeightUnits
;
39 INTEGER4 IsFilled
, GeomType
, LinePattern
, NumEllipsePts
;
40 INTEGER4 Anchor
, BoxType
, BoxColor
, BoxFillColor
, TextColor
, Color
, FillColor
;
41 INTEGER4 ArrowheadStyle
, ArrowheadAttachment
, NumSegments
, NumSegPts
[1];
42 double LineThickness
, ArrowheadSize
, ArrowheadAngle
;
43 float XGeomData
[1], YGeomData
[1], ZGeomData
[1];
44 enum FileType
{ FULL
= 0, GRID
= 1, SOLUTION
= 2 };
52 * Open order.plt and write the header information.
54 I
= TECINI112((char*)"DATASET WITH ONE ORDERED ZONE AND ONE FE-QUAD ZONE OVER 2 TIME STEPS",
62 * Open line.plt and write the header information.
65 I
= TECINI112((char*)"DATASET WITH ONE I-ORDERED ZONE",
74 * Calculate values for the field variables.
76 for (J
= 0; J
< 5; J
++)
77 for (I
= 0; I
< 4; I
++)
79 X
[J
][I
] = (float)(I
+ 1);
80 Y
[J
][I
] = (float)(J
+ 1);
81 P
[J
][I
] = (float)((I
+ 1) * (J
+ 1));
85 * Make sure writing to file #1.
91 * Write the zone header information for the ordered zone.
104 NumFaceConnections
= 0;
105 FaceNeighborMode
= 0;
106 ShareConnectivityFromZone
= 0;
107 I
= TECZNE112((char*)"Ordered Zone 1",
121 NULL
, /* PassiveVarList */
122 NULL
, /* ValueLocation */
123 NULL
, /* ShareVarFromZone */
124 0, /* TotalNumFaceNodes */
125 0, /* NumConnectedBoundaryFaces */
126 0, /* TotalNumBoundaryConnections */
127 &ShareConnectivityFromZone
);
129 * Write out the field data for the ordered zone.
132 I
= TECDAT112(&III
, &X
[0][0], &DIsDouble
);
133 I
= TECDAT112(&III
, &Y
[0][0], &DIsDouble
);
134 I
= TECDAT112(&III
, &P
[0][0], &DIsDouble
);
137 * Calculate values for the I-ordered zone.
140 for (I
= 0; I
< 50; I
++)
143 YL
[I
] = sin((double)(I
+ 1) / 20.0);
146 * Switch to the "line.plt" file (file number 2)
147 * and write out the line plot data.
154 * Write the zone header information for the XY-data.
160 StrandID
= 0; /* StaticZone */
161 I
= TECZNE112((char*)"XY Line plot",
175 0, /* TotalNumFaceNodes */
176 0, /* NumConnectedBoundaryFaces */
177 0, /* TotalNumBoundaryConnections */
178 NULL
, /* PassiveVarList */
179 NULL
, /* ValueLocation */
180 NULL
, /* ShareVarFromZone */
181 &ShareConnectivityFromZone
);
183 * Write out the line plot.
187 I
= TECDAT112(&III
, (float *) & XL
[0], &DIsDouble
);
188 I
= TECDAT112(&III
, (float *) & YL
[0], &DIsDouble
);
191 * Switch back to the field plot file and write out
192 * the finite-element zone.
198 * Move the coordinates so this zone's not on top of the other
200 for (J
= 0; J
< 5; J
++)
201 for (I
= 0; I
< 4; I
++)
203 X
[J
][I
] = (float)(I
+ 6);
204 Y
[J
][I
] = (float)(J
+ 1);
205 P
[J
][I
] = (float)((I
+ 1) * (J
+ 1));
209 * Write the zone header information for the finite-element zone.
211 ZoneType
= 3; /* FEQuad */
212 NPts
= 20; /* Number of points */
213 NElm
= 12; /* Number of elements */
214 KMax
= 0; /* Unused */
217 I
= TECZNE112((char*)"Finite Zone 1",
231 0, /* TotalNumFaceNodes */
232 0, /* NumConnectedBoundaryFaces */
233 0, /* TotalNumBoundaryConnections */
234 NULL
, /* PassiveVarList */
235 NULL
, /* ValueLocation */
236 NULL
, /* ShareVarFromZone */
237 &ShareConnectivityFromZone
);
239 * Write out the field data for the finite-element zone.
245 I
= TECDAT112(&III
, &X
[0][0], &DIsDouble
);
246 I
= TECDAT112(&III
, &Y
[0][0], &DIsDouble
);
247 I
= TECDAT112(&III
, &P
[0][0], &DIsDouble
);
250 * Calculate and then write out the connectivity list.
251 * Note: The NM array references cells starting with
255 for (I
= 1; I
< IMax
; I
++)
256 for (J
= 1; J
< JMax
; J
++)
258 K
= I
+ (J
- 1) * (IMax
- 1);
259 L
= I
+ (J
- 1) * IMax
;
262 NM
[K
-1][2] = L
+ IMax
+ 1;
263 NM
[K
-1][3] = L
+ IMax
;
266 I
= TECNOD112((INTEGER4
*)NM
);
269 * Calculate values for the new solution variable.
271 for (J
= 0; J
< 5; J
++)
272 for (I
= 0; I
< 4; I
++)
274 P
[J
][I
] = (float)(2.0 * (I
+ 1) * (J
+ 1));
278 * Write the zone header information for time step 2
288 SharingZone
[2] = 0; /* solution variable is not shared */
289 ShareConnectivityFromZone
= 0;
291 I
= TECZNE112((char*)"Ordered Zone 2",
305 0, /* TotalNumFaceNodes */
306 0, /* NumConnectedBoundaryFaces */
307 0, /* TotalNumBoundaryConnections */
311 &ShareConnectivityFromZone
);
314 * Write out the solution variable the grid variables are shared.
320 I
= TECDAT112(&III
, &P
[0][0], &DIsDouble
);
323 * Calculate values for the new solution variable.
325 for (J
= 0; J
< 5; J
++)
326 for (I
= 0; I
< 4; I
++)
328 P
[J
][I
] = (float)(3.0 * (I
+ 1) * (J
+ 1));
332 * Write another time step for the FEZone and share from the first
340 SharingZone
[2] = 0; /* solution variable is not shared */
341 ShareConnectivityFromZone
= 2;
342 I
= TECZNE112((char*)"Finite Zone 2",
356 0, /* TotalNumFaceNodes */
357 0, /* NumConnectedBoundaryFaces */
358 0, /* TotalNumBoundaryConnections */
359 NULL
, /* PassiveVarList */
360 NULL
, /* ValueLocation */
362 &ShareConnectivityFromZone
);
365 * Write out the solution variable the grid variables are shared.
371 I
= TECDAT112(&III
, &P
[0][0], &DIsDouble
);
374 * Prepare to write out text record. Text is positioned
375 * at 0.5, 0.5 in frame units and has a height
376 * of 0.05 frame units.
382 Scope
= 1; /* Local */
383 Clipping
= 1; /* Clip to frame */
384 PositionCoordSys
= 1; /* Frame */
385 FontType
= 1; /* Helv Bold */
386 HeightUnits
= 1; /* Frame */
389 BoxType
= 0; /* None */
391 BoxLineThickness
= 0.5;
395 Anchor
= 0; /* Left */
397 TextColor
= 0; /* Black */
423 * Prepare to write out geometry record (circle). Circle is
424 * positioned at 25, 25 (in frame units) and has a radius of
425 * 20 percent. Circle is drawn using a dashed line.
435 GeomType
= 3; /* Circle */
436 LinePattern
= 1; /* Dashed */
441 ArrowheadAttachment
= 0;
443 ArrowheadAngle
= 15.0;
467 &ArrowheadAttachment
,