/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright held by original author \\/ 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 "patchWriter.H" #include "writeFuns.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from components Foam::patchWriter::patchWriter ( const vtkMesh& vMesh, const bool binary, const bool nearCellValue, const fileName& fName, const labelList& patchIDs ) : vMesh_(vMesh), binary_(binary), nearCellValue_(nearCellValue), patchIDs_(patchIDs), os_(fName.c_str()) { const fvMesh& mesh = vMesh_.mesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh(); // Write header if (patchIDs_.size() == 1) { writeFuns::writeHeader(os_, binary_, patches[patchIDs_[0]].name()); } else { writeFuns::writeHeader(os_, binary_, "patches"); } os_ << "DATASET UNSTRUCTURED_GRID" << std::endl; // Write topology nPoints_ = 0; nFaces_ = 0; label nFaceVerts = 0; forAll(patchIDs_, i) { const polyPatch& pp = patches[patchIDs_[i]]; nPoints_ += pp.nPoints(); nFaces_ += pp.size(); forAll(pp, faceI) { nFaceVerts += pp[faceI].size() + 1; } } os_ << "POINTS " << nPoints_ << " float" << std::endl; DynamicList ptField(3*nPoints_); forAll(patchIDs_, i) { const polyPatch& pp = patches[patchIDs_[i]]; writeFuns::insert(pp.localPoints(), ptField); } writeFuns::write(os_, binary_, ptField); os_ << "CELLS " << nFaces_ << ' ' << nFaceVerts << std::endl; DynamicList