1 /* This example illustrates how to create two simple
2 * FE-quadilateral zones and create a face neighbor
3 * connection between the two zones. In order to keep the
4 * example as simple as possible, error checking is not included.
12 /* Initialize the Data File using TECINI. TECINI is required
13 * for all data files. It is used to: open the data file and
14 * initialize the file header information (name the data file,
15 * the variables for the data file, and the file type).
18 /* DOCSTART:faceneighbors_tecini.txt*/
21 INTEGER4 VIsDouble
= 0;
22 INTEGER4 FileType
= 0;
23 INTEGER4 I
= 0; /* Used to track return codes */
25 I
= TECINI112((char*)"Face Neighbors Example", /* Specifies the name
29 (char*)"X Y P", /* Defines the
42 (char*)"FaceNeighbors.plt", /* Specifies the
46 &FileType
, /* The FileType is set to
47 * zero, indicating it is
48 * a full file (containing
49 * both grid and solution
56 /* After TECINI is called, call TECZNE to create one or
57 * more zones for your data file.
59 /* DOCSTART:faceneighbors_teczne1.txt*/
60 INTEGER4 ZoneType
= 3; /* set the zone type to
64 INTEGER4 NumElems
= 2;
65 INTEGER4 NumFaces
= 8;
66 INTEGER4 ICellMax
= 0; /* not used */
67 INTEGER4 JCellMax
= 0; /* not used */
68 INTEGER4 KCellMax
= 0; /* not used */
69 double SolTime
= 360.0;
70 INTEGER4 StrandID
= 0; /* StaticZone */
71 INTEGER4 ParentZn
= 0;
72 INTEGER4 IsBlock
= 1; /* Block */
73 INTEGER4 NFConns
= 1; /* Specify the number of Face
74 * Neighbor Connections in the
75 * Zone. When this value is
76 * greater than zero, TECFACE must
77 * be called prior to creating the
78 * next zone or ending the file.
81 /* Specify the Face Neighbor Mode.
82 * A value of 2 indicated that the face neighbor mode is global
83 * one-to-one. The scope of the face neighbors (local or
84 * global) is with respect to the zones. A value of global
85 * indicates that the face neighbor(s) is/are shared aross zones;
86 * a value of local indicates that the face neighbor(s) are
87 * shared within the current zone. The terms one-to-one and
88 * one-to-many are used to indicate whether the face in question
89 * is shared with one cell or several cells.
90 * For example, if your data is arranged as follows:
92 -----------------------
96 -----------------------
100 -----------------------
101 * The face between 1 & 4 is local-one-to-one. The face between
102 * 5 and (2 & 3) is local one-to-many.
107 INTEGER4 TotalNumFaceNodes
= 1; /* Not used for
109 INTEGER4 NumConnectedBoundaryFaces
= 1; /* Not used for
111 INTEGER4 TotalNumBoundaryConnections
= 1; /* Not used for
113 INTEGER4 ShrConn
= 0;
115 INTEGER4 ValueLocation
[3] = {1, 1, 1}; /* Specify the variable
116 * values at the nodes.
117 * NOTE: Because all of
119 * defined at the nodes,
121 * NULL for this array.
122 * We are providing the
123 * array for illustration
127 I
= TECZNE112((char*)"Zone 1",
142 &NumConnectedBoundaryFaces
,
143 &TotalNumBoundaryConnections
,
150 /* Set up the variable values. The variable values will be
151 * written to the file using TECDAT. Because we are specifying
152 * nodal variables (as specified via the ValueLocation
153 * parameter in TECZNE, each variable is dimensioned by the
154 * number of points (NumPts) in the Zone. You have the option
155 * to specify some variables with nodal values and some with
156 * cell-centered values. Refer to the Binary Function
157 * Reference for details.
160 /* DOCSTART:faceneighbors_tecdat1.txt*/
161 float *X
= new float[NumPts
];
162 float *Y
= new float[NumPts
];
163 float *P
= new float[NumPts
];
165 /* For this example, we will create 2 rectangular cells in Zone
166 * 1. Before defining your variables, you must establish a
167 * consistent node numbering scheme for your data. Once the
168 * node numbers are defined, supply the variable values in the
169 * node numbering order. In this example, node 1 is defined at
170 * X = 0 and Y = 0. As such, the first value supplied for X
171 * (i.e. X[0]) is 0. Similarly, the first value supplied for Y
174 * It is important that you refer to node numbers consistently.
175 * The node numbers will be used later to define the
176 * connectivity for each element.
193 for (INTEGER4 ii
= 0; ii
< NumPts
; ii
++)
194 P
[ii
] = (float)(NumPts
- ii
);
196 INTEGER4 DIsDouble
= 0; /* Set DIsDouble to zero to use
197 * variables in float format.
200 /* Call TECDAT once for each variable */
201 I
= TECDAT112(&NumPts
, &X
[0], &DIsDouble
);
202 I
= TECDAT112(&NumPts
, &Y
[0], &DIsDouble
);
203 I
= TECDAT112(&NumPts
, &P
[0], &DIsDouble
);
206 /* Define the face neighbors connections.
207 * The Connectivity List is used to specify the nodes that
208 * compose each element. When working with nodal variables, the
209 * numbering of the nodes is implicitly defined when the
210 * variables are declared. The first value of each variable is
211 * for node one, the second value for node two, and so on.
213 * Because this zone contains two quadilateral elements, we must
214 * supply 8 values in the connectivity list. The first four
215 * values define the nodes that form element 1. Similarly, the
216 * second four values define the nodes that form element 2.
219 /* DOCSTART:faceneighbors_tecnod1.txt*/
220 INTEGER4 ConnList
[8] = {1, 3, 4, 2,
223 I
= TECNOD112(ConnList
);
226 /* TIP! It is important to provide the node list in either a
227 * clockwise or counter-clockwise order. Otherwise, your
228 * elements will be misformed. For example, if the first two
229 * numbers in the above connectivity list, the zone would
233 /* Now that TECNOD has been called, the creation of Zone 1
234 * is complete. However, in this example, we will define a
235 * face neighbor between Zone 1 and Zone 2 (to be created
236 * later in the example). Face Neighbor connections are used
237 * to define connections that are not created via the
238 * connectivity list. For example, local face neighbors may
239 * need to be defined when a zone wraps itself and global face
240 * neighbors may need to be defined to smooth edges across
241 * zones. Face Neighbors are used when deriving variables and
244 * In this example, we are creating a face neighbor connection
245 * between cell 2 in Zone 1 and cell 1 in Zone 2. The
246 * information required when specifying face neighbors
247 * depends upon the type of connection.
249 * In this case, we must supply (in this order):
250 * - the cell number in the current zone that contains the
251 * - the number of the face in that cell that contains the
253 * - the number of the other zone to which the face is
255 * - the number of the cell in the other zone to which the
257 * The face numbering for cell-based finite elements is
258 * defined using the picture displayed in the Data Format
259 * Guide. In this example, face 2 in cell 2 in the current
260 * zone is connected to cell 1 in zone 2.
263 /* DOCSTART:faceneighbors_tecface1.txt*/
264 INTEGER4 FaceConn
[4] = {2, 2, 2, 1};
265 I
= TECFACE112(FaceConn
);
268 /* The creation of Zone 1 is complete. We are ready to create
269 * Zone 2. For simplicity, Zone 2 is a copy of Zone 1 shifted
270 * along the X-axis. As such, many of the variables used to
271 * create Zone 1 are re-used here.
273 /* DOCSTART:faceneighbors_teczne2.txt*/
274 /* Call TECZNE to create Zone 2 */
275 I
= TECZNE112((char*)"Zone 2",
290 &NumConnectedBoundaryFaces
,
291 &TotalNumBoundaryConnections
,
298 /* Define the variables for Zone 2. Because Zone 2 is a copy
299 * of Zone 1, shifted along the X-axis, we can share the Y
300 * variable definition used to Zone. We will also create a
301 * second pressure variable for Zone 2 (P2).
304 /* DOCSTART:faceneighbors_tecdat2.txt*/
305 float *X2
= new float[NumPts
];
306 float *P2
= new float[NumPts
];
308 for (INTEGER4 ii
= 0; ii
< NumPts
; ii
++)
311 P2
[ii
] = 2 * (float)ii
;
314 I
= TECDAT112(&NumPts
, &X2
[0], &DIsDouble
);
315 I
= TECDAT112(&NumPts
, &Y
[0], &DIsDouble
);
316 I
= TECDAT112(&NumPts
, &P2
[0], &DIsDouble
);
325 /* As with Zone 1, we must define the connectivity list for
326 * Zone 2. Because, the node numbering restarts at one for each
327 * new zone and the nodal arrangement is identical between the
328 * two zones, we may reuse the connectivity list from Zone 1.
331 /* DOCSTART:faceneighbors_tecnod2.txt*/
332 I
= TECNOD112(ConnList
);
335 /* We will now specify the face neighbor connection with
336 * respect to our new current zone of Zone 2.
339 /* DOCSTART:faceneighbors_tecface2.txt*/
340 INTEGER4 FaceConn2
[4] = {1, 4, 1, 2}; /* cell 1, face 4 in
342 * neighbor to cell 2 in
345 I
= TECFACE112(FaceConn2
);
348 /* Call TECEND to close the file */
349 /* DOCSTART:faceneighbors_tecend.txt*/