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 "ensightParts.H"
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 Foam::ensightParts::ensightParts(const polyMesh& pMesh)
38 Foam::ensightParts::ensightParts(const IOobject& ioObj)
42 IOPtrList<ensightPart> ioList(ioObj);
43 partsList_.transfer(ioList);
47 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
49 Foam::ensightParts::~ensightParts()
53 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
55 void Foam::ensightParts::recalculate(const polyMesh& pMesh)
59 // extra space for unzoned cells
62 pMesh.cellZones().size()
63 + pMesh.boundaryMesh().size()
67 partsList_.setSize(nPart);
73 forAll(pMesh.cellZones(), zoneI)
75 const cellZone& cZone = pMesh.cellZones()[zoneI];
76 nZoneCells += cZone.size();
95 // collect unzoned cells
97 // special case: no zones at all - do entire mesh
112 else if (pMesh.nCells() > nZoneCells)
114 // determine which cells are not in a cellZone
115 labelList unzoned(pMesh.nCells(), -1);
117 forAll(pMesh.cellZones(), zoneI)
119 const labelList& idList = pMesh.cellZones()[zoneI];
123 unzoned[idList[i]] = idList[i];
132 unzoned[nUnzoned] = i;
136 unzoned.setSize(nUnzoned);
156 // do boundaries, skipping empty and processor patches
157 forAll(pMesh.boundaryMesh(), patchI)
159 const polyPatch& pPatch = pMesh.boundaryMesh()[patchI];
160 if (pPatch.size() && !isA<processorPolyPatch>(pPatch))
177 // truncate to correct size
178 partsList_.setSize(nPart);
182 void Foam::ensightParts::renumber
184 const labelList& origCellId,
185 const labelList& origFaceId
188 forAll(partsList_, partI)
190 if (partsList_[partI].isCellData())
192 partsList_[partI].renumber(origCellId);
196 partsList_[partI].renumber(origFaceId);
202 void Foam::ensightParts::writeGeometry( ensightGeoFile& os) const
204 // with some feedback
205 Info<< "write geometry part:" << nl << flush;
207 forAll(partsList_, partI)
209 Info<< " " << partI << flush;
210 partsList_[partI].writeGeometry(os);
215 bool Foam::ensightParts::writeSummary(Ostream& os) const
217 forAll(partsList_, partI)
219 partsList_[partI].writeSummary(os);
226 void Foam::ensightParts::writeData(Ostream& os) const
228 // Write size of list
229 os << nl << partsList_.size();
231 // Write beginning of contents
232 os << nl << token::BEGIN_LIST;
234 // Write list contents
235 forAll(partsList_, i)
237 os << nl << partsList_[i];
240 // Write end of contents
241 os << nl << token::END_LIST << nl;
243 // Check state of IOstream
244 os.check("Ostream& operator<<(Ostream&, const PtrList&)");
248 void Foam::ensightParts::writeScalarField
251 const List<scalar>& field,
255 forAll(partsList_, partI)
260 ? partsList_[partI].isFaceData()
261 : partsList_[partI].isCellData()
264 partsList_[partI].writeScalarField(os,field);
270 void Foam::ensightParts::writeVectorField
273 const List<scalar>& field0,
274 const List<scalar>& field1,
275 const List<scalar>& field2,
279 forAll(partsList_, partI)
284 ? partsList_[partI].isFaceData()
285 : partsList_[partI].isCellData()
288 partsList_[partI].writeVectorField(os, field0, field1, field2);
294 // * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
296 Foam::ensightGeoFile& Foam::operator<<
299 const ensightParts& parts
302 parts.writeGeometry(os);
307 // ************************************************************************* //