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 "MeshedSurface.H"
28 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
31 void Foam::MeshedSurface<Face>::checkZones()
33 // extra safety, ensure we have at some zones
34 // and they cover all the faces - fix start silently
35 surfZoneList& zones = this->storedZones();
41 zones[zoneI].start() = count;
42 count += zones[zoneI].size();
45 if (count < this->size())
49 "MeshedSurface::checkZones()\n"
51 << "more faces " << this->size() << " than zones " << count
52 << " ... extending final zone"
55 zones[zones.size()-1].size() += count - this->size();
57 else if (count > this->size())
61 "MeshedSurface::checkZones()\n"
63 << "more zones " << count << " than faces " << this->size()
71 void Foam::MeshedSurface<Face>::sortFacesAndStore
73 const Xfer< List<Face> >& unsortedFaces,
74 const Xfer< List<label> >& zoneIds,
78 List<Face> oldFaces(unsortedFaces);
79 List<label> zones(zoneIds);
83 // already sorted - simply transfer faces
84 this->storedFaces().transfer(oldFaces);
88 // unsorted - determine the sorted order:
89 // avoid SortableList since we discard the main list anyhow
91 sortedOrder(zones, faceMap);
95 List<Face> newFaces(faceMap.size());
96 forAll(faceMap, faceI)
98 // use transfer to recover memory where possible
99 newFaces[faceI].transfer(oldFaces[faceMap[faceI]]);
101 this->storedFaces().transfer(newFaces);
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 void Foam::MeshedSurface<Face>::addZones
112 const UList<surfZone>& srfZones,
118 surfZoneList& zones = this->storedZones();
119 zones.setSize(zones.size());
122 if (srfZones[zoneI].size() || !cullEmpty)
124 zones[nZone] = surfZone(srfZones[zoneI], nZone);
128 zones.setSize(nZone);
133 void Foam::MeshedSurface<Face>::addZones
135 const UList<label>& sizes,
136 const UList<word>& names,
143 surfZoneList& zones = this->storedZones();
144 zones.setSize(sizes.size());
147 if (sizes[zoneI] || !cullEmpty)
149 zones[nZone] = surfZone
156 start += sizes[zoneI];
160 zones.setSize(nZone);
165 void Foam::MeshedSurface<Face>::addZones
167 const UList<label>& sizes,
174 surfZoneList& zones = this->storedZones();
175 zones.setSize(sizes.size());
178 if (sizes[zoneI] || !cullEmpty)
180 zones[nZone] = surfZone
182 word("zone") + ::Foam::name(nZone),
187 start += sizes[zoneI];
191 zones.setSize(nZone);
196 void Foam::MeshedSurface<Face>::removeZones()
198 this->storedZones().clear();
202 // ************************************************************************* //