/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA \*---------------------------------------------------------------------------*/ #include "argList.H" #include "Time.H" #include "ensightMesh.H" #include "fvMesh.H" #include "PstreamCombineReduceOps.H" #include "processorPolyPatch.H" #include "cellModeller.H" #include "IOmanip.H" #include "itoa.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // namespace Foam { class concatPatchNames { public: void operator() ( HashTable& x, const HashTable& y ) const { for ( HashTable::const_iterator iter = y.begin(); iter != y.end(); ++iter ) { HashTable::iterator xiter = x.find(iter.key()); if (xiter == x.end()) { x.insert(iter.key(), iter()); } else { labelList& xPatches = xiter(); const labelList& yPatches = iter(); label offset = xPatches.size(); xPatches.setSize(offset + yPatches.size()); forAll(yPatches, i) { xPatches[i + offset] = yPatches[i]; } } } } }; } // End namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from fvMesh Foam::ensightMesh::ensightMesh(const fvMesh& fMesh, const argList& args) : mesh(fMesh), meshCellSets(mesh.nCells()), boundaryFaceSets(mesh.boundary().size()) { forAll (mesh.boundaryMesh(), patchi) { if (typeid(mesh.boundaryMesh()[patchi]) != typeid(processorPolyPatch)) { if (!allPatchNames.found(mesh.boundaryMesh()[patchi].name())) { allPatchNames.insert ( mesh.boundaryMesh()[patchi].name(), labelList(1, Pstream::myProcNo()) ); patchIndices.insert ( mesh.boundaryMesh()[patchi].name(), patchi ); } } } combineReduce(allPatchNames, concatPatchNames()); if (args.options().found("patches")) { wordList patchNameList(IStringStream(args.options()["patches"])()); if (!patchNameList.size()) { patchNameList = allPatchNames.toc(); } forAll (patchNameList, i) { patchNames.insert(patchNameList[i]); } } const cellShapeList& cellShapes = mesh.cellShapes(); const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& wedge = *(cellModeller::lookup("wedge")); const cellModel& hex = *(cellModeller::lookup("hex")); labelList& tets = meshCellSets.tets; labelList& pyrs = meshCellSets.pyrs; labelList& prisms = meshCellSets.prisms; labelList& wedges = meshCellSets.wedges; labelList& hexes = meshCellSets.hexes; labelList& polys = meshCellSets.polys; // Count the shapes label nTets = 0; label nPyrs = 0; label nPrisms = 0; label nWedges = 0; label nHexes = 0; label nPolys = 0; if (!patchNames.size()) { forAll(cellShapes, celli) { const cellShape& cellShape = cellShapes[celli]; const cellModel& cellModel = cellShape.model(); if (cellModel == tet) { tets[nTets++] = celli; } else if (cellModel == pyr) { pyrs[nPyrs++] = celli; } else if (cellModel == prism) { prisms[nPrisms++] = celli; } else if (cellModel == wedge) { wedges[nWedges++] = celli; } else if (cellModel == hex) { hexes[nHexes++] = celli; } else { polys[nPolys++] = celli; } } tets.setSize(nTets); pyrs.setSize(nPyrs); prisms.setSize(nPrisms); wedges.setSize(nWedges); hexes.setSize(nHexes); polys.setSize(nPolys); meshCellSets.nTets = nTets; reduce(meshCellSets.nTets, sumOp