1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "objectRegistry.H"
28 #include "tecplotWriter.H"
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 // Construct from components
34 Foam::tecplotWriter::tecplotWriter(const Time& runTime)
40 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
42 void Foam::tecplotWriter::writeInit
45 const string& varNames,
46 const fileName& fName,
47 INTEGER4 tecplotFileType
53 << " varNames:" << varNames
54 << " to file:" << fName
55 << " of type:" << tecplotFileType
58 INTEGER4 IsDouble = 0; //float
59 INTEGER4 Debug = 0; //nodebug
64 const_cast<char*>(name.c_str()), /* Data Set Title */
65 const_cast<char*>(varNames.c_str()), /* Variable List */
66 const_cast<char*>(fName.c_str()), /* File Name */
67 const_cast<char*>(runTime_.path().c_str()), /* Scratch Directory */
74 // FatalErrorIn("tecplotWriter::writeInit(..) const")
75 // << "Error in TECINI112." << exit(FatalError);
80 void Foam::tecplotWriter::writePolyhedralZone
85 const List<INTEGER4>& varLocArray,
90 INTEGER4 NumNodes = mesh.nPoints(); /* number of unique nodes */
91 INTEGER4 NumElems = mesh.nCells(); /* number of elements */
92 INTEGER4 NumFaces = mesh.nFaces(); /* number of unique faces */
94 INTEGER4 ICellMax = 0; /* Not Used, set to zero */
95 INTEGER4 JCellMax = 0; /* Not Used, set to zero */
96 INTEGER4 KCellMax = 0; /* Not Used, set to zero */
98 double SolTime = runTime_.value(); /* solution time */
99 INTEGER4 ParentZone = 0; /* no parent zone */
101 INTEGER4 IsBlock = 1; /* block format */
103 INTEGER4 NFConns = 0; /* not used for FEPolyhedron
106 INTEGER4 FNMode = 0; /* not used for FEPolyhedron
109 Pout<< "zoneName:" << zoneName
110 //<< " varLocArray:" << varLocArray
111 << " solTime:" << SolTime
116 INTEGER4 *PassiveVarArray = NULL;
117 INTEGER4 *VarShareArray = NULL;
118 INTEGER4 ShrConn = 0;
120 INTEGER4 NumBConns = 0; /* No Boundary Connections */
121 INTEGER4 NumBItems = 0; /* No Boundary Items */
123 INTEGER4 ZoneType = ZoneType_FEPolyhedron;
129 const_cast<char*>(zoneName.c_str()),
147 const_cast<INTEGER4*>(varLocArray.begin()),
153 // FatalErrorIn("tecplotWriter::writePolyhedralZone(..) const")
154 // << "Error in TECZNE112." << exit(FatalError);
159 void Foam::tecplotWriter::writePolygonalZone
161 const word& zoneName,
163 const indirectPrimitivePatch& pp,
164 const List<INTEGER4>& varLocArray
168 INTEGER4 NumNodes = pp.nPoints(); /* number of unique nodes */
169 INTEGER4 NumElems = pp.size(); /* number of elements */
170 INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */
172 INTEGER4 ICellMax = 0; /* Not Used, set to zero */
173 INTEGER4 JCellMax = 0; /* Not Used, set to zero */
174 INTEGER4 KCellMax = 0; /* Not Used, set to zero */
176 double SolTime = runTime_.value(); /* solution time */
177 INTEGER4 ParentZone = 0; /* no parent zone */
179 INTEGER4 IsBlock = 1; /* block format */
181 INTEGER4 NFConns = 0; /* not used for FEPolyhedron
184 INTEGER4 FNMode = 0; /* not used for FEPolyhedron
187 INTEGER4 NumFaceNodes = 2*pp.nEdges();
189 Pout<< "zoneName:" << zoneName
190 << " strandID:" << strandID
191 //<< " varLocArray:" << varLocArray
192 << " solTime:" << SolTime
196 INTEGER4 *PassiveVarArray = NULL;
197 INTEGER4 *VarShareArray = NULL;
198 INTEGER4 ShrConn = 0;
200 INTEGER4 NumBConns = 0; /* No Boundary Connections */
201 INTEGER4 NumBItems = 0; /* No Boundary Items */
203 INTEGER4 ZoneType = ZoneType_FEPolygon;
209 const_cast<char*>(zoneName.c_str()),
227 const_cast<INTEGER4*>(varLocArray.begin()),
233 // FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
234 // << "Error in TECZNE112." << exit(FatalError);
239 void Foam::tecplotWriter::writeOrderedZone
241 const word& zoneName,
244 const List<INTEGER4>& varLocArray
248 INTEGER4 IMax = n; /* number of unique nodes */
249 INTEGER4 JMax = 1; /* number of elements */
250 INTEGER4 KMax = 1; /* number of unique faces */
252 INTEGER4 ICellMax = 0; /* Not Used, set to zero */
253 INTEGER4 JCellMax = 0; /* Not Used, set to zero */
254 INTEGER4 KCellMax = 0; /* Not Used, set to zero */
256 double SolTime = runTime_.value(); /* solution time */
257 INTEGER4 ParentZone = 0; /* no parent zone */
259 INTEGER4 IsBlock = 1; /* block format */
261 INTEGER4 NFConns = 0; /* not used for FEPolyhedron
264 INTEGER4 FNMode = 0; /* not used for FEPolyhedron
267 INTEGER4 NumFaceNodes = 1;
268 INTEGER4 NumBConns = 1; /* No Boundary Connections */
269 INTEGER4 NumBItems = 1; /* No Boundary Items */
271 Pout<< "zoneName:" << zoneName
272 << " strandID:" << strandID
273 //<< " varLocArray:" << varLocArray
274 << " solTime:" << SolTime
278 INTEGER4 *PassiveVarArray = NULL;
279 INTEGER4 *VarShareArray = NULL;
280 INTEGER4 ShrConn = 0;
283 INTEGER4 ZoneType = ZoneType_Ordered;
289 const_cast<char*>(zoneName.c_str()),
307 const_cast<INTEGER4*>(varLocArray.begin()),
313 // FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
314 // << "Error in TECZNE112." << exit(FatalError);
319 void Foam::tecplotWriter::writeConnectivity(const fvMesh& mesh) const
321 List<INTEGER4> FaceNodeCounts(mesh.nFaces());
323 forAll(mesh.faces(), faceI)
325 const face& f = mesh.faces()[faceI];
326 FaceNodeCounts[faceI] = INTEGER4(f.size());
330 INTEGER4 nFaceNodes = 0;
331 forAll(mesh.faces(), faceI)
333 nFaceNodes += mesh.faces()[faceI].size();
337 List<INTEGER4> FaceNodes(nFaceNodes);
339 forAll(mesh.faces(), faceI)
341 const face& f = mesh.faces()[faceI];
344 FaceNodes[nodeI++] = INTEGER4(f[fp]+1);
349 List<INTEGER4> FaceLeftElems(mesh.nFaces());
350 forAll(mesh.faceOwner(), faceI)
352 FaceLeftElems[faceI] = mesh.faceOwner()[faceI]+1;
355 List<INTEGER4> FaceRightElems(mesh.nFaces());
356 forAll(mesh.faceNeighbour(), faceI)
358 FaceRightElems[faceI] = mesh.faceNeighbour()[faceI]+1;
362 label faceI = mesh.nInternalFaces();
363 faceI < mesh.nFaces();
367 FaceRightElems[faceI] = 0;
374 FaceNodeCounts.begin(), /* The face node counts array */
375 FaceNodes.begin(), /* The face nodes array */
376 FaceLeftElems.begin(), /* The left elements array */
377 FaceRightElems.begin(), /* The right elements array */
378 NULL, /* No boundary connection counts */
379 NULL, /* No boundary connection elements */
380 NULL /* No boundary connection zones */
384 // FatalErrorIn("tecplotWriter::writeConnectivity(const fvMesh&) const")
385 // << "Error in TECPOLY112." << exit(FatalError);
390 void Foam::tecplotWriter::writeConnectivity
392 const indirectPrimitivePatch& pp
395 INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */
396 INTEGER4 NumFaceNodes = 2*pp.nEdges();
398 // All faces (=edges) have 2 nodes
399 List<INTEGER4> FaceNodeCounts(NumFaces, 2);
401 List<INTEGER4> FaceNodes(NumFaceNodes);
403 forAll(pp.edges(), edgeI)
405 edge e = pp.edges()[edgeI];
411 FaceNodes[nodeI++] = INTEGER4(e[0]+1);
412 FaceNodes[nodeI++] = INTEGER4(e[1]+1);
415 /* Define the right and left elements of each face.
417 * The last step for writing out the polyhedral data is to
418 * define the right and left neighboring elements for each
419 * face. The neighboring elements can be determined using the
420 * right-hand rule. For each face, place your right-hand along
421 * the face which your fingers pointing the direction of
422 * incrementing node numbers (i.e. from node 1 to node 2).
423 * Your right thumb will point towards the right element; the
424 * element on the other side of your hand is the left element.
426 * The number zero is used to indicate that there isn't an
427 * element on that side of the face.
429 * Because of the way we numbered the nodes and faces, the
430 * right element for every face is the element itself
431 * (element 1) and the left element is "no-neighboring element"
435 List<INTEGER4> FaceLeftElems(NumFaces);
436 List<INTEGER4> FaceRightElems(NumFaces);
438 const labelListList& edgeFaces = pp.edgeFaces();
439 forAll(edgeFaces, edgeI)
441 const labelList& eFaces = edgeFaces[edgeI];
443 if (eFaces.size() == 1)
445 FaceLeftElems[edgeI] = 0;
446 FaceRightElems[edgeI] = eFaces[0]+1;
448 else if (eFaces.size() == 2)
450 edge e = pp.edges()[edgeI];
456 const face& f0 = pp.localFaces()[eFaces[0]];
458 // The face that uses the vertices of e in increasing order
461 label fp = findIndex(f0, e[0]);
462 bool f0IsLeft = (f0.nextLabel(fp) == e[1]);
466 FaceLeftElems[edgeI] = eFaces[0]+1;
467 FaceRightElems[edgeI] = eFaces[1]+1;
471 FaceLeftElems[edgeI] = eFaces[1]+1;
472 FaceRightElems[edgeI] = eFaces[0]+1;
477 // non-manifold. Treat as if open.
478 FaceLeftElems[edgeI] = 0;
479 FaceRightElems[edgeI] = eFaces[0]+1;
483 /* Write the face map (created above) using TECPOLY112. */
488 FaceNodeCounts.begin(), /* The face node counts array */
489 FaceNodes.begin(), /* The face nodes array */
490 FaceLeftElems.begin(), /* The left elements array */
491 FaceRightElems.begin(), /* The right elements array */
492 NULL, /* No boundary connection counts */
493 NULL, /* No boundary connection elements */
494 NULL /* No boundary connection zones */
498 // FatalErrorIn("tecplotWriter::writeConnectivity(..) const")
499 // << "Error in TECPOLY112." << exit(FatalError);
504 void Foam::tecplotWriter::writeEnd() const
506 Pout<< "writeEnd" << endl;
510 // FatalErrorIn("tecplotWriter::writeEnd() const")
511 // << "Error in TECEND112." << exit(FatalError);
517 // ************************************************************************* //