1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 "MeshedSurface.H"
29 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
32 void Foam::MeshedSurface<Face>::checkZones()
34 // extra safety, ensure we have at some zones
35 // and they cover all the faces - fix start silently
36 surfZoneList& zones = this->storedZones();
42 zones[zoneI].start() = count;
43 count += zones[zoneI].size();
46 if (count < this->size())
50 "MeshedSurface::checkZones()\n"
52 << "more faces " << this->size() << " than zones " << count
53 << " ... extending final zone"
56 zones[zones.size()-1].size() += count - this->size();
58 else if (count > this->size())
62 "MeshedSurface::checkZones()\n"
64 << "more zones " << count << " than faces " << this->size()
72 void Foam::MeshedSurface<Face>::sortFacesAndStore
74 const Xfer< List<Face> >& unsortedFaces,
75 const Xfer< List<label> >& zoneIds,
79 List<Face> oldFaces(unsortedFaces);
80 List<label> zones(zoneIds);
84 // already sorted - simply transfer faces
85 this->storedFaces().transfer(oldFaces);
89 // unsorted - determine the sorted order:
90 // avoid SortableList since we discard the main list anyhow
92 sortedOrder(zones, faceMap);
96 List<Face> newFaces(faceMap.size());
97 forAll(faceMap, faceI)
99 // use transfer to recover memory where possible
100 newFaces[faceI].transfer(oldFaces[faceMap[faceI]]);
102 this->storedFaces().transfer(newFaces);
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 void Foam::MeshedSurface<Face>::addZones
113 const UList<surfZone>& srfZones,
119 surfZoneList& zones = this->storedZones();
120 zones.setSize(zones.size());
123 if (srfZones[zoneI].size() || !cullEmpty)
125 zones[nZone] = surfZone(srfZones[zoneI], nZone);
129 zones.setSize(nZone);
134 void Foam::MeshedSurface<Face>::addZones
136 const UList<label>& sizes,
137 const UList<word>& names,
144 surfZoneList& zones = this->storedZones();
145 zones.setSize(sizes.size());
148 if (sizes[zoneI] || !cullEmpty)
150 zones[nZone] = surfZone
157 start += sizes[zoneI];
161 zones.setSize(nZone);
166 void Foam::MeshedSurface<Face>::addZones
168 const UList<label>& sizes,
175 surfZoneList& zones = this->storedZones();
176 zones.setSize(sizes.size());
179 if (sizes[zoneI] || !cullEmpty)
181 zones[nZone] = surfZone
183 word("zone") + ::Foam::name(nZone),
188 start += sizes[zoneI];
192 zones.setSize(nZone);
197 void Foam::MeshedSurface<Face>::removeZones()
199 this->storedZones().clear();
203 // ************************************************************************* //