/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2010 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 3 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, see . \*---------------------------------------------------------------------------*/ #include "ensightMesh.H" #include "argList.H" #include "Time.H" #include "fvMesh.H" #include "globalMeshData.H" #include "PstreamCombineReduceOps.H" #include "processorPolyPatch.H" #include "cellModeller.H" #include "IOmanip.H" #include "itoa.H" #include "globalIndex.H" #include "mapDistribute.H" #include "stringListOps.H" #include "ensightBinaryStream.H" #include "ensightAsciiStream.H" #include // * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * // void Foam::ensightMesh::correct() { patchPartOffset_ = 2; meshCellSets_ = mesh_.nCells(); boundaryFaceSets_.setSize(mesh_.boundary().size()); allPatchNames_.clear(); patchNames_.clear(); nPatchPrims_ = 0; faceZoneFaceSets_.setSize(mesh_.faceZones().size()); faceZoneNames_.clear(); nFaceZonePrims_ = 0; boundaryFaceToBeIncluded_.clear(); 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")); if (!noPatches_) { // Patches are output. Check that they're synced. mesh_.boundaryMesh().checkParallelSync(true); allPatchNames_ = wordList::subList ( mesh_.boundaryMesh().names(), mesh_.boundary().size() - mesh_.globalData().processorPatches().size() ); if (patches_) { if (patchPatterns_.empty()) { forAll(allPatchNames_, nameI) { patchNames_.insert(allPatchNames_[nameI]); } } else { // Find patch names which match that requested at command-line forAll(allPatchNames_, nameI) { const word& patchName = allPatchNames_[nameI]; if (findStrings(patchPatterns_, patchName)) { patchNames_.insert(patchName); } } } } } if (patchNames_.size()) { // no internalMesh patchPartOffset_ = 1; } else { // Count the shapes labelList& tets = meshCellSets_.tets; labelList& pyrs = meshCellSets_.pyrs; labelList& prisms = meshCellSets_.prisms; labelList& wedges = meshCellSets_.wedges; labelList& hexes = meshCellSets_.hexes; labelList& polys = meshCellSets_.polys; label nTets = 0; label nPyrs = 0; label nPrisms = 0; label nWedges = 0; label nHexes = 0; label nPolys = 0; 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