/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | foam-extend: Open Source CFD \\ / O peration | \\ / A nd | For copyright notice see file Copyright \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of foam-extend. foam-extend 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. foam-extend 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 foam-extend. If not, see . \*---------------------------------------------------------------------------*/ #include "argList.H" #include "objectRegistry.H" #include "Time.H" #include "ensightMesh.H" #include "fvMesh.H" #include "globalMeshData.H" #include "PstreamCombineReduceOps.H" #include "processorPolyPatch.H" #include "cellModeller.H" #include "IOmanip.H" #include "itoa.H" #include "ensightWriteBinary.H" #include // * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * // namespace Foam { //- Proxy-class to hold the patch processor list combination operator class concatPatchProcs { public: void operator() ( List& x, const List& y ) const { forAll(y, i) { const labelList& yPatches = y[i]; if (yPatches.size()) { labelList& xPatches = x[i]; label offset = xPatches.size(); xPatches.setSize(offset + yPatches.size()); forAll(yPatches, i) { xPatches[i + offset] = yPatches[i]; } } } } }; } // End namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::ensightMesh::ensightMesh ( const fvMesh& mesh, const argList& args, const bool binary ) : mesh_(mesh), binary_(binary), patchPartOffset_(2), meshCellSets_(mesh_.nCells()), boundaryFaceSets_(mesh_.boundary().size()), allPatchNames_(0), allPatchProcs_(0), patchNames_(0), nPatchPrims_(0) { 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 (!args.optionFound("noPatches")) { allPatchNames_ = wordList::subList ( mesh_.boundaryMesh().names(), mesh_.boundary().size() - mesh_.globalData().processorPatches().size() ); allPatchProcs_.setSize(allPatchNames_.size()); forAll (allPatchProcs_, patchi) { if (mesh_.boundary()[patchi].size()) { allPatchProcs_[patchi].setSize(1); allPatchProcs_[patchi][0] = Pstream::myProcNo(); } } combineReduce(allPatchProcs_, concatPatchProcs()); if (args.optionFound("patches")) { wordList patchNameList(args.optionLookup("patches")()); if (patchNameList.empty()) { patchNameList = allPatchNames_; } forAll (patchNameList, i) { patchNames_.insert(patchNameList[i]); } } } 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