1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*----------------------------------------------------------------------------*/
27 #include <conversion/ensightParts.H>
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 Foam::ensightParts::ensightParts(const polyMesh& pMesh)
39 Foam::ensightParts::ensightParts(const IOobject& ioObj)
43 IOPtrList<ensightPart> ioList(ioObj);
44 partsList_.transfer(ioList);
48 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
50 Foam::ensightParts::~ensightParts()
54 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
56 void Foam::ensightParts::recalculate(const polyMesh& pMesh)
60 // extra space for unzoned cells
63 pMesh.cellZones().size()
64 + pMesh.boundaryMesh().size()
68 partsList_.setSize(nPart);
74 forAll(pMesh.cellZones(), zoneI)
76 const cellZone& cZone = pMesh.cellZones()[zoneI];
77 nZoneCells += cZone.size();
96 // collect unzoned cells
98 // special case: no zones at all - do entire mesh
113 else if (pMesh.nCells() > nZoneCells)
115 // determine which cells are not in a cellZone
116 labelList unzoned(pMesh.nCells(), -1);
118 forAll(pMesh.cellZones(), zoneI)
120 const labelList& idList = pMesh.cellZones()[zoneI];
124 unzoned[idList[i]] = idList[i];
133 unzoned[nUnzoned] = i;
137 unzoned.setSize(nUnzoned);
157 // do boundaries, skipping empty and processor patches
158 forAll(pMesh.boundaryMesh(), patchI)
160 const polyPatch& pPatch = pMesh.boundaryMesh()[patchI];
164 && typeid(pPatch) != typeid(processorPolyPatch)
182 // truncate to correct size
183 partsList_.setSize(nPart);
187 void Foam::ensightParts::renumber
189 const labelList& origCellId,
190 const labelList& origFaceId
193 forAll(partsList_, partI)
195 if (partsList_[partI].isCellData())
197 partsList_[partI].renumber(origCellId);
201 partsList_[partI].renumber(origFaceId);
207 void Foam::ensightParts::writeGeometry( ensightGeoFile& os) const
209 // with some feedback
210 Info<< "write geometry part:" << nl << flush;
212 forAll(partsList_, partI)
214 Info<< " " << partI << flush;
215 partsList_[partI].writeGeometry(os);
220 bool Foam::ensightParts::writeSummary(Ostream& os) const
222 forAll(partsList_, partI)
224 partsList_[partI].writeSummary(os);
231 void Foam::ensightParts::writeData(Ostream& os) const
233 // Write size of list
234 os << nl << partsList_.size();
236 // Write beginning of contents
237 os << nl << token::BEGIN_LIST;
239 // Write list contents
240 forAll(partsList_, i)
242 os << nl << partsList_[i];
245 // Write end of contents
246 os << nl << token::END_LIST << nl;
248 // Check state of IOstream
249 os.check("Ostream& operator<<(Ostream&, const PtrList&)");
253 void Foam::ensightParts::writeScalarField
256 const List<scalar>& field,
260 forAll(partsList_, partI)
265 ? partsList_[partI].isFaceData()
266 : partsList_[partI].isCellData()
269 partsList_[partI].writeScalarField(os,field);
275 void Foam::ensightParts::writeVectorField
278 const List<scalar>& field0,
279 const List<scalar>& field1,
280 const List<scalar>& field2,
284 forAll(partsList_, partI)
289 ? partsList_[partI].isFaceData()
290 : partsList_[partI].isCellData()
293 partsList_[partI].writeVectorField(os, field0, field1, field2);
299 // * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
301 Foam::ensightGeoFile& Foam::operator<<
304 const ensightParts& parts
307 parts.writeGeometry(os);
312 // ************************ vim: set sw=4 sts=4 et: ************************ //