1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "tecplotWriter.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 // Construct from components
32 Foam::tecplotWriter::tecplotWriter(const Time& runTime)
38 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
40 void Foam::tecplotWriter::writeInit
43 const string& varNames,
44 const fileName& fName,
45 INTEGER4 tecplotFileType
51 << " varNames:" << varNames
52 << " to file:" << fName
53 << " of type:" << tecplotFileType
56 INTEGER4 IsDouble = 0; //float
57 INTEGER4 Debug = 0; //nodebug
62 const_cast<char*>(name.c_str()), /* Data Set Title */
63 const_cast<char*>(varNames.c_str()), /* Variable List */
64 const_cast<char*>(fName.c_str()), /* File Name */
65 const_cast<char*>(runTime_.path().c_str()), /* Scratch Directory */
72 // FatalErrorIn("tecplotWriter::writeInit(..) const")
73 // << "Error in TECINI112." << exit(FatalError);
78 void Foam::tecplotWriter::writePolyhedralZone
83 const List<INTEGER4>& varLocArray,
88 INTEGER4 NumNodes = mesh.nPoints(); /* number of unique nodes */
89 INTEGER4 NumElems = mesh.nCells(); /* number of elements */
90 INTEGER4 NumFaces = mesh.nFaces(); /* number of unique faces */
92 INTEGER4 ICellMax = 0; /* Not Used, set to zero */
93 INTEGER4 JCellMax = 0; /* Not Used, set to zero */
94 INTEGER4 KCellMax = 0; /* Not Used, set to zero */
96 double SolTime = runTime_.value(); /* solution time */
97 INTEGER4 ParentZone = 0; /* no parent zone */
99 INTEGER4 IsBlock = 1; /* block format */
101 INTEGER4 NFConns = 0; /* not used for FEPolyhedron
104 INTEGER4 FNMode = 0; /* not used for FEPolyhedron
107 Pout<< "zoneName:" << zoneName
108 //<< " varLocArray:" << varLocArray
109 << " solTime:" << SolTime
114 INTEGER4 *PassiveVarArray = NULL;
115 INTEGER4 *VarShareArray = NULL;
116 INTEGER4 ShrConn = 0;
118 INTEGER4 NumBConns = 0; /* No Boundary Connections */
119 INTEGER4 NumBItems = 0; /* No Boundary Items */
121 INTEGER4 ZoneType = ZoneType_FEPolyhedron;
127 const_cast<char*>(zoneName.c_str()),
145 const_cast<INTEGER4*>(varLocArray.begin()),
151 // FatalErrorIn("tecplotWriter::writePolyhedralZone(..) const")
152 // << "Error in TECZNE112." << exit(FatalError);
157 void Foam::tecplotWriter::writePolygonalZone
159 const word& zoneName,
161 const indirectPrimitivePatch& pp,
162 const List<INTEGER4>& varLocArray
166 INTEGER4 NumNodes = pp.nPoints(); /* number of unique nodes */
167 INTEGER4 NumElems = pp.size(); /* number of elements */
168 INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */
170 INTEGER4 ICellMax = 0; /* Not Used, set to zero */
171 INTEGER4 JCellMax = 0; /* Not Used, set to zero */
172 INTEGER4 KCellMax = 0; /* Not Used, set to zero */
174 double SolTime = runTime_.value(); /* solution time */
175 INTEGER4 ParentZone = 0; /* no parent zone */
177 INTEGER4 IsBlock = 1; /* block format */
179 INTEGER4 NFConns = 0; /* not used for FEPolyhedron
182 INTEGER4 FNMode = 0; /* not used for FEPolyhedron
185 INTEGER4 NumFaceNodes = 2*pp.nEdges();
187 Pout<< "zoneName:" << zoneName
188 << " strandID:" << strandID
189 //<< " varLocArray:" << varLocArray
190 << " solTime:" << SolTime
194 INTEGER4 *PassiveVarArray = NULL;
195 INTEGER4 *VarShareArray = NULL;
196 INTEGER4 ShrConn = 0;
198 INTEGER4 NumBConns = 0; /* No Boundary Connections */
199 INTEGER4 NumBItems = 0; /* No Boundary Items */
201 INTEGER4 ZoneType = ZoneType_FEPolygon;
207 const_cast<char*>(zoneName.c_str()),
225 const_cast<INTEGER4*>(varLocArray.begin()),
231 // FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
232 // << "Error in TECZNE112." << exit(FatalError);
237 void Foam::tecplotWriter::writeOrderedZone
239 const word& zoneName,
242 const List<INTEGER4>& varLocArray
246 INTEGER4 IMax = n; /* number of unique nodes */
247 INTEGER4 JMax = 1; /* number of elements */
248 INTEGER4 KMax = 1; /* number of unique faces */
250 INTEGER4 ICellMax = 0; /* Not Used, set to zero */
251 INTEGER4 JCellMax = 0; /* Not Used, set to zero */
252 INTEGER4 KCellMax = 0; /* Not Used, set to zero */
254 double SolTime = runTime_.value(); /* solution time */
255 INTEGER4 ParentZone = 0; /* no parent zone */
257 INTEGER4 IsBlock = 1; /* block format */
259 INTEGER4 NFConns = 0; /* not used for FEPolyhedron
262 INTEGER4 FNMode = 0; /* not used for FEPolyhedron
265 INTEGER4 NumFaceNodes = 1;
266 INTEGER4 NumBConns = 1; /* No Boundary Connections */
267 INTEGER4 NumBItems = 1; /* No Boundary Items */
269 Pout<< "zoneName:" << zoneName
270 << " strandID:" << strandID
271 //<< " varLocArray:" << varLocArray
272 << " solTime:" << SolTime
276 INTEGER4 *PassiveVarArray = NULL;
277 INTEGER4 *VarShareArray = NULL;
278 INTEGER4 ShrConn = 0;
281 INTEGER4 ZoneType = ZoneType_Ordered;
287 const_cast<char*>(zoneName.c_str()),
305 const_cast<INTEGER4*>(varLocArray.begin()),
311 // FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
312 // << "Error in TECZNE112." << exit(FatalError);
317 void Foam::tecplotWriter::writeConnectivity(const fvMesh& mesh) const
319 List<INTEGER4> FaceNodeCounts(mesh.nFaces());
321 forAll(mesh.faces(), faceI)
323 const face& f = mesh.faces()[faceI];
324 FaceNodeCounts[faceI] = INTEGER4(f.size());
328 INTEGER4 nFaceNodes = 0;
329 forAll(mesh.faces(), faceI)
331 nFaceNodes += mesh.faces()[faceI].size();
335 List<INTEGER4> FaceNodes(nFaceNodes);
337 forAll(mesh.faces(), faceI)
339 const face& f = mesh.faces()[faceI];
342 FaceNodes[nodeI++] = INTEGER4(f[fp]+1);
347 List<INTEGER4> FaceLeftElems(mesh.nFaces());
348 forAll(mesh.faceOwner(), faceI)
350 FaceLeftElems[faceI] = mesh.faceOwner()[faceI]+1;
353 List<INTEGER4> FaceRightElems(mesh.nFaces());
354 forAll(mesh.faceNeighbour(), faceI)
356 FaceRightElems[faceI] = mesh.faceNeighbour()[faceI]+1;
360 label faceI = mesh.nInternalFaces();
361 faceI < mesh.nFaces();
365 FaceRightElems[faceI] = 0;
372 FaceNodeCounts.begin(), /* The face node counts array */
373 FaceNodes.begin(), /* The face nodes array */
374 FaceLeftElems.begin(), /* The left elements array */
375 FaceRightElems.begin(), /* The right elements array */
376 NULL, /* No boundary connection counts */
377 NULL, /* No boundary connection elements */
378 NULL /* No boundary connection zones */
382 // FatalErrorIn("tecplotWriter::writeConnectivity(const fvMesh&) const")
383 // << "Error in TECPOLY112." << exit(FatalError);
388 void Foam::tecplotWriter::writeConnectivity
390 const indirectPrimitivePatch& pp
393 INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */
394 INTEGER4 NumFaceNodes = 2*pp.nEdges();
396 // All faces (=edges) have 2 nodes
397 List<INTEGER4> FaceNodeCounts(NumFaces, 2);
399 List<INTEGER4> FaceNodes(NumFaceNodes);
401 forAll(pp.edges(), edgeI)
403 edge e = pp.edges()[edgeI];
409 FaceNodes[nodeI++] = INTEGER4(e[0]+1);
410 FaceNodes[nodeI++] = INTEGER4(e[1]+1);
413 /* Define the right and left elements of each face.
415 * The last step for writing out the polyhedral data is to
416 * define the right and left neighboring elements for each
417 * face. The neighboring elements can be determined using the
418 * right-hand rule. For each face, place your right-hand along
419 * the face which your fingers pointing the direction of
420 * incrementing node numbers (i.e. from node 1 to node 2).
421 * Your right thumb will point towards the right element; the
422 * element on the other side of your hand is the left element.
424 * The number zero is used to indicate that there isn't an
425 * element on that side of the face.
427 * Because of the way we numbered the nodes and faces, the
428 * right element for every face is the element itself
429 * (element 1) and the left element is "no-neighboring element"
433 List<INTEGER4> FaceLeftElems(NumFaces);
434 List<INTEGER4> FaceRightElems(NumFaces);
436 const labelListList& edgeFaces = pp.edgeFaces();
437 forAll(edgeFaces, edgeI)
439 const labelList& eFaces = edgeFaces[edgeI];
441 if (eFaces.size() == 1)
443 FaceLeftElems[edgeI] = 0;
444 FaceRightElems[edgeI] = eFaces[0]+1;
446 else if (eFaces.size() == 2)
448 edge e = pp.edges()[edgeI];
454 const face& f0 = pp.localFaces()[eFaces[0]];
456 // The face that uses the vertices of e in increasing order
459 label fp = findIndex(f0, e[0]);
460 bool f0IsLeft = (f0.nextLabel(fp) == e[1]);
464 FaceLeftElems[edgeI] = eFaces[0]+1;
465 FaceRightElems[edgeI] = eFaces[1]+1;
469 FaceLeftElems[edgeI] = eFaces[1]+1;
470 FaceRightElems[edgeI] = eFaces[0]+1;
475 // non-manifold. Treat as if open.
476 FaceLeftElems[edgeI] = 0;
477 FaceRightElems[edgeI] = eFaces[0]+1;
481 /* Write the face map (created above) using TECPOLY112. */
486 FaceNodeCounts.begin(), /* The face node counts array */
487 FaceNodes.begin(), /* The face nodes array */
488 FaceLeftElems.begin(), /* The left elements array */
489 FaceRightElems.begin(), /* The right elements array */
490 NULL, /* No boundary connection counts */
491 NULL, /* No boundary connection elements */
492 NULL /* No boundary connection zones */
496 // FatalErrorIn("tecplotWriter::writeConnectivity(..) const")
497 // << "Error in TECPOLY112." << exit(FatalError);
502 void Foam::tecplotWriter::writeEnd() const
504 Pout<< "writeEnd" << endl;
508 // FatalErrorIn("tecplotWriter::writeEnd() const")
509 // << "Error in TECEND112." << exit(FatalError);
515 // ************************************************************************* //