1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "patchWriter.H"
27 #include "writeFuns.H"
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 // Construct from components
34 Foam::patchWriter::patchWriter
38 const bool nearCellValue,
39 const fileName& fName,
40 const labelList& patchIDs
45 nearCellValue_(nearCellValue),
50 const fvMesh& mesh = vMesh_.mesh();
51 const polyBoundaryMesh& patches = mesh.boundaryMesh();
54 if (patchIDs_.size() == 1)
56 writeFuns::writeHeader(os_, binary_, patches[patchIDs_[0]].name());
60 writeFuns::writeHeader(os_, binary_, "patches");
62 os_ << "DATASET UNSTRUCTURED_GRID" << std::endl;
71 const polyPatch& pp = patches[patchIDs_[i]];
73 nPoints_ += pp.nPoints();
78 nFaceVerts += pp[faceI].size() + 1;
82 os_ << "POINTS " << nPoints_ << " float" << std::endl;
84 DynamicList<floatScalar> ptField(3*nPoints_);
88 const polyPatch& pp = patches[patchIDs_[i]];
90 writeFuns::insert(pp.localPoints(), ptField);
92 writeFuns::write(os_, binary_, ptField);
94 os_ << "CELLS " << nFaces_ << ' ' << nFaceVerts
97 DynamicList<label> vertLabels(nFaceVerts);
98 DynamicList<label> faceTypes(nFaceVerts);
104 const polyPatch& pp = patches[patchIDs_[i]];
108 const face& f = pp.localFaces()[faceI];
110 const label fSize = f.size();
111 vertLabels.append(fSize);
113 writeFuns::insert(f + offset, vertLabels);
117 faceTypes.append(vtkTopo::VTK_TRIANGLE);
121 faceTypes.append(vtkTopo::VTK_QUAD);
125 faceTypes.append(vtkTopo::VTK_POLYGON);
128 offset += pp.nPoints();
130 writeFuns::write(os_, binary_, vertLabels);
132 os_ << "CELL_TYPES " << nFaces_ << std::endl;
134 writeFuns::write(os_, binary_, faceTypes);
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 void Foam::patchWriter::writePatchIDs()
142 const fvMesh& mesh = vMesh_.mesh();
144 DynamicList<floatScalar> fField(nFaces_);
146 os_ << "patchID 1 " << nFaces_ << " float" << std::endl;
150 label patchI = patchIDs_[i];
152 const polyPatch& pp = mesh.boundaryMesh()[patchI];
154 if (!isA<emptyPolyPatch>(pp))
156 writeFuns::insert(scalarField(pp.size(), patchI), fField);
159 writeFuns::write(os_, binary_, fField);
163 // ************************************************************************* //