foam to Tecplot360 converter
[OpenFOAM-1.6.x.git] / applications / utilities / postProcessing / dataConversion / foamToTecplot360 / tecio / examples / faceneighbors / faceneighbors.cpp
blob30b949e3f8e3d85d8bcaf9192e637344005e97c5
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.
5 */
7 #include "TECIO.h"
8 #include "MASTER.h"
10 int main()
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*/
20 INTEGER4 Debug = 1;
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
26 * of the entire
27 * dataset
29 (char*)"X Y P", /* Defines the
30 * variables for the
31 * data file. Each
32 * zone must contain
33 * each of the vars
34 * listed. The order
35 * of the variables in
36 * the list is used to
37 * define the variable
38 * number (e.g. X is
39 * Var 1.)
42 (char*)"FaceNeighbors.plt", /* Specifies the
43 * file name.
45 (char*)".",
46 &FileType, /* The FileType is set to
47 * zero, indicating it is
48 * a full file (containing
49 * both grid and solution
50 * data).
52 &Debug,
53 &VIsDouble);
54 /* DOCEND */
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
61 * FEQuadrilateral
63 INTEGER4 NumPts = 6;
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 -----------------------
93 | | | |
94 | 1 | 2 | 3 |
95 | | | |
96 -----------------------
97 | | |
98 | 4 | 5 |
99 | | |
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.
105 INTEGER4 FNMode = 2;
107 INTEGER4 TotalNumFaceNodes = 1; /* Not used for
108 * FEQuad zones*/
109 INTEGER4 NumConnectedBoundaryFaces = 1; /* Not used for
110 * FEQuad zones*/
111 INTEGER4 TotalNumBoundaryConnections = 1; /* Not used for
112 * FEQuad zones*/
113 INTEGER4 ShrConn = 0;
115 INTEGER4 ValueLocation[3] = {1, 1, 1}; /* Specify the variable
116 * values at the nodes.
117 * NOTE: Because all of
118 * the variables are
119 * defined at the nodes,
120 * we can just pass
121 * NULL for this array.
122 * We are providing the
123 * array for illustration
124 * purposes.
127 I = TECZNE112((char*)"Zone 1",
128 &ZoneType,
129 &NumPts,
130 &NumElems,
131 &NumFaces,
132 &ICellMax,
133 &JCellMax,
134 &KCellMax,
135 &SolTime,
136 &StrandID,
137 &ParentZn,
138 &IsBlock,
139 &NFConns,
140 &FNMode,
141 &TotalNumFaceNodes,
142 &NumConnectedBoundaryFaces,
143 &TotalNumBoundaryConnections,
144 NULL,
145 ValueLocation,
146 NULL,
147 &ShrConn);
148 /* DOCEND */
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
172 * is 0.
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.
179 X[0] = 0;
180 X[1] = 0;
181 X[2] = 1;
182 X[3] = 1;
183 X[4] = 2;
184 X[5] = 2;
186 Y[0] = 0;
187 Y[1] = 1;
188 Y[2] = 0;
189 Y[3] = 1;
190 Y[4] = 0;
191 Y[5] = 1;
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);
204 /* DOCEND */
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,
221 3, 5, 6, 4
223 I = TECNOD112(ConnList);
224 /* DOCEND */
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
230 * appear as follows:
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
242 * drawing contours.
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
252 * face neighbor
253 * - the number of the other zone to which the face is
254 * connected
255 * - the number of the cell in the other zone to which the
256 * face is connected
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);
266 /* DOCEND */
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",
276 &ZoneType,
277 &NumPts,
278 &NumElems,
279 &NumFaces,
280 &ICellMax,
281 &JCellMax,
282 &KCellMax,
283 &SolTime,
284 &StrandID,
285 &ParentZn,
286 &IsBlock,
287 &NFConns,
288 &FNMode,
289 &TotalNumFaceNodes,
290 &NumConnectedBoundaryFaces,
291 &TotalNumBoundaryConnections,
292 NULL,
293 ValueLocation,
294 NULL,
295 &ShrConn);
296 /* DOCEND */
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++)
310 X2[ii] = X[ii] + 2;
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);
318 delete X;
319 delete Y;
320 delete P;
321 delete X2;
322 delete P2;
323 /* DOCEND */
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);
333 /* DOCEND */
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
341 * current zone is a
342 * neighbor to cell 2 in
343 * zone 1.
345 I = TECFACE112(FaceConn2);
346 /* DOCEND */
348 /* Call TECEND to close the file */
349 /* DOCSTART:faceneighbors_tecend.txt*/
350 I = TECEND112();
351 /* DOCEND */
353 return 0;