foam to Tecplot360 converter
[OpenFOAM-1.6.x.git] / applications / utilities / postProcessing / dataConversion / foamToTecplot360 / tecio / examples / pyramid / pyramid.cpp
blob864bb754bad228d233bd89fa81509de08d60abcf
1 /* This example creates a zone with a single polyhedral cell. */
3 /* DOCSTART:pyramid.txt*/
4 #include "TECIO.h"
5 #include "MASTER.h" /* for defintion of NULL */
7 int main()
9 /* Call TECINI112 */
10 INTEGER4 FileType = 0; /* 0 for full file */
11 INTEGER4 Debug = 0;
12 INTEGER4 VIsDouble = 1;
13 INTEGER4 I = 0; /* use to check return codes */
15 I = TECINI112((char*)"Pyramid", /* Data Set Title */
16 (char*)"X Y Z", /* Variable List */
17 (char*)"pyramid.plt", /* File Name */
18 (char*)".", /* Scratch Directory */
19 &(FileType),
20 &(Debug),
21 &(VIsDouble));
24 /* Call TECZNE112 */
25 INTEGER4 ZoneType = 7; /* 7 for FEPolyhedron */
26 INTEGER4 NumNodes = 5; /* number of unique nodes */
27 INTEGER4 NumElems = 1; /* number of elements */
28 INTEGER4 NumFaces = 5; /* number of unique faces */
30 INTEGER4 ICellMax = 0; /* Not Used, set to zero */
31 INTEGER4 JCellMax = 0; /* Not Used, set to zero */
32 INTEGER4 KCellMax = 0; /* Not Used, set to zero */
34 double SolTime = 12.65; /* solution time */
35 INTEGER4 StrandID = 0; /* static zone */
36 INTEGER4 ParentZone = 0; /* no parent zone */
38 INTEGER4 IsBlock = 1; /* block format */
40 INTEGER4 NFConns = 0; /* not used for FEPolyhedron
41 * zones
43 INTEGER4 FNMode = 0; /* not used for FEPolyhedron
44 * zones
47 INTEGER4 *PassiveVarArray = NULL;
48 INTEGER4 *ValueLocArray = NULL;
49 INTEGER4 *VarShareArray = NULL;
51 INTEGER4 ShrConn = 0;
53 /* The number of face nodes in the zone. This example creates
54 * a zone with a single pyramidal cell. This cell has four
55 * triangular faces and one rectangular face, yielding a total
56 * of 16 face nodes.
58 INTEGER4 NumFaceNodes = 16;
59 INTEGER4 NumBConns = 0; /* No Boundary Connections */
60 INTEGER4 NumBItems = 0; /* No Boundary Items */
62 I = TECZNE112((char*)"Polyhedral Zone (Octahedron)",
63 &ZoneType,
64 &NumNodes,
65 &NumElems,
66 &NumFaces,
67 &ICellMax,
68 &JCellMax,
69 &KCellMax,
70 &SolTime,
71 &StrandID,
72 &ParentZone,
73 &IsBlock,
74 &NFConns,
75 &FNMode,
76 &NumFaceNodes,
77 &NumBConns,
78 &NumBItems,
79 PassiveVarArray,
80 ValueLocArray,
81 VarShareArray,
82 &ShrConn);
84 /* Initialize arrays of nodal data */
85 double *X = new double[NumNodes];
86 double *Y = new double[NumNodes];
87 double *Z = new double[NumNodes];
89 X[0] = 0;
90 Y[0] = 0;
91 Z[0] = 0;
93 X[1] = 1;
94 Y[1] = 1;
95 Z[1] = 2;
97 X[2] = 2;
98 Y[2] = 0;
99 Z[2] = 0;
101 X[3] = 2;
102 Y[3] = 2;
103 Z[3] = 0;
105 X[4] = 0;
106 Y[4] = 2;
107 Z[4] = 0;
109 /* Write the data (using TECDAT112) */
110 INTEGER4 DIsDouble = 1; /* One for double precision */
111 I = TECDAT112(&NumNodes, X, &DIsDouble);
112 I = TECDAT112(&NumNodes, Y, &DIsDouble);
113 I = TECDAT112(&NumNodes, Z, &DIsDouble);
115 delete X;
116 delete Y;
117 delete Z;
119 /* Define the Face Nodes.
121 * The FaceNodes array is used to indicate which nodes define
122 * which face. As mentioned earlier, the number of the nodes is
123 * implicitly defined by the order in which the nodal data is
124 * provided. The first value of each nodal variable describes
125 * node 1, the second value describes node 2, and so on.
127 * The face numbering is implicitly defined. Because there are
128 * two nodes in each face, the first two nodes provided define
129 * face 1, the next two define face 2 and so on. If there was
130 * a variable number of nodes used to define the faces, the
131 * array would be more complicated.
134 INTEGER4 *FaceNodeCounts = new INTEGER4[NumFaces];
135 /* The first four faces are triangular, i.e. have three nodes.
136 * The fifth face is rectangular, i.e. has four nodes. */
137 FaceNodeCounts[0] = 3;
138 FaceNodeCounts[1] = 3;
139 FaceNodeCounts[2] = 3;
140 FaceNodeCounts[3] = 3;
141 FaceNodeCounts[4] = 4;
143 INTEGER4 *FaceNodes = new INTEGER4[NumFaceNodes];
144 /* Face Nodes for Face 1 */
145 FaceNodes[0] = 1;
146 FaceNodes[1] = 2;
147 FaceNodes[2] = 3;
149 /* Face Nodes for Face 2 */
150 FaceNodes[3] = 3;
151 FaceNodes[4] = 2;
152 FaceNodes[5] = 4;
154 /* Face Nodes for Face 3 */
155 FaceNodes[6] = 5;
156 FaceNodes[7] = 2;
157 FaceNodes[8] = 4;
159 /* Face Nodes for Face 4 */
160 FaceNodes[9] = 1;
161 FaceNodes[10] = 2;
162 FaceNodes[11] = 5;
164 /* Face Nodes for Face 5 */
165 FaceNodes[12] = 1;
166 FaceNodes[13] = 5;
167 FaceNodes[14] = 4;
168 FaceNodes[15] = 3;
170 /* Define the right and left elements of each face.
172 * The last step for writing out the polyhedral data is to
173 * define the right and left neighboring elements for each
174 * face. The neighboring elements can be determined using the
175 * right-hand rule. For each face, place your right-hand along
176 * the face which your fingers pointing the direction of
177 * incrementing node numbers (i.e. from node 1 to node 2).
178 * Your right thumb will point towards the right element; the
179 * element on the other side of your hand is the left element.
181 * The number zero is used to indicate that there isn't an
182 * element on that side of the face.
184 * Because of the way we numbered the nodes and faces, the
185 * right element for every face is the element itself
186 * (element 1) and the left element is "no-neighboring element"
187 * (element 0).
190 INTEGER4 *FaceLeftElems = new INTEGER4[NumFaces];
191 FaceLeftElems[0] = 1;
192 FaceLeftElems[1] = 1;
193 FaceLeftElems[2] = 0;
194 FaceLeftElems[3] = 0;
195 FaceLeftElems[4] = 0;
197 INTEGER4 *FaceRightElems = new INTEGER4[NumFaces];
198 FaceRightElems[0] = 0;
199 FaceRightElems[1] = 0;
200 FaceRightElems[2] = 1;
201 FaceRightElems[3] = 1;
202 FaceRightElems[4] = 1;
204 /* Write the face map (created above) using TECPOLY112. */
205 I = TECPOLY112(FaceNodeCounts, /* The face node counts array */
206 FaceNodes, /* The face nodes array */
207 FaceLeftElems, /* The left elements array */
208 FaceRightElems, /* The right elements array */
209 NULL, /* No boundary connection counts */
210 NULL, /* No boundary connection elements */
211 NULL); /* No boundary connection zones */
213 delete FaceNodeCounts;
214 delete FaceNodes;
215 delete FaceLeftElems;
216 delete FaceRightElems;
218 I = TECEND112();
219 return 0;
222 /* DOCEND */