1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "pointZoneSet.H"
27 #include "mapPolyMesh.H"
29 #include "processorPolyPatch.H"
30 #include "cyclicPolyPatch.H"
32 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 defineTypeNameAndDebug(pointZoneSet, 0);
43 addToRunTimeSelectionTable(topoSet, pointZoneSet, word);
44 addToRunTimeSelectionTable(topoSet, pointZoneSet, size);
45 addToRunTimeSelectionTable(topoSet, pointZoneSet, set);
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 void pointZoneSet::updateSet()
53 sortedOrder(addressing_, order);
54 inplaceReorder(order, addressing_);
56 pointSet::clearStorage();
57 pointSet::resize(2*addressing_.size());
58 forAll(addressing_, i)
60 pointSet::insert(addressing_[i]);
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 pointZoneSet::pointZoneSet
75 pointSet(mesh, name, 1000), // do not read pointSet
79 const pointZoneMesh& pointZones = mesh.pointZones();
80 label zoneID = pointZones.findZoneID(name);
84 r == IOobject::MUST_READ
85 || r == IOobject::MUST_READ_IF_MODIFIED
86 || (r == IOobject::READ_IF_PRESENT && zoneID != -1)
89 const pointZone& fz = pointZones[zoneID];
95 check(mesh.nPoints());
99 pointZoneSet::pointZoneSet
101 const polyMesh& mesh,
107 pointSet(mesh, name, size, w),
115 pointZoneSet::pointZoneSet
117 const polyMesh& mesh,
123 pointSet(mesh, name, set.size(), w),
125 addressing_(refCast<const pointZoneSet>(set).addressing())
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
133 pointZoneSet::~pointZoneSet()
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 void pointZoneSet::invert(const label maxLen)
143 for (label pointI = 0; pointI < maxLen; pointI++)
147 addressing_[n] = pointI;
151 addressing_.setSize(n);
156 void pointZoneSet::subset(const topoSet& set)
158 DynamicList<label> newAddressing(addressing_.size());
160 const pointZoneSet& fSet = refCast<const pointZoneSet>(set);
162 forAll(fSet.addressing(), i)
164 label pointI = fSet.addressing()[i];
168 newAddressing.append(pointI);
172 addressing_.transfer(newAddressing);
177 void pointZoneSet::addSet(const topoSet& set)
179 DynamicList<label> newAddressing(addressing_);
181 const pointZoneSet& fSet = refCast<const pointZoneSet>(set);
183 forAll(fSet.addressing(), i)
185 label pointI = fSet.addressing()[i];
189 newAddressing.append(pointI);
193 addressing_.transfer(newAddressing);
198 void pointZoneSet::deleteSet(const topoSet& set)
200 DynamicList<label> newAddressing(addressing_.size());
202 const pointZoneSet& fSet = refCast<const pointZoneSet>(set);
204 forAll(addressing_, i)
206 label pointI = addressing_[i];
208 if (!fSet.found(pointI))
210 // Not found in fSet so add
211 newAddressing.append(pointI);
215 addressing_.transfer(newAddressing);
220 void pointZoneSet::sync(const polyMesh& mesh)
224 label pointZoneSet::maxSize(const polyMesh& mesh) const
226 return mesh.nPoints();
230 //- Write using given format, version and compression
231 bool pointZoneSet::writeObject
233 IOstream::streamFormat s,
234 IOstream::versionNumber v,
235 IOstream::compressionType c
238 // Write shadow pointSet
239 word oldTypeName = typeName;
240 const_cast<word&>(type()) = pointSet::typeName;
241 bool ok = pointSet::writeObject(s, v, c);
242 const_cast<word&>(type()) = oldTypeName;
245 pointZoneMesh& pointZones = const_cast<polyMesh&>(mesh_).pointZones();
246 label zoneID = pointZones.findZoneID(name());
250 zoneID = pointZones.size();
252 pointZones.setSize(zoneID+1);
267 pointZones[zoneID] = addressing_;
269 pointZones.clearAddressing();
271 return ok && pointZones.write();
275 void pointZoneSet::updateMesh(const mapPolyMesh& morphMap)
278 labelList newAddressing(addressing_.size());
281 forAll(addressing_, i)
283 label pointI = addressing_[i];
284 label newPointI = morphMap.reversePointMap()[pointI];
287 newAddressing[n] = newPointI;
291 newAddressing.setSize(n);
293 addressing_.transfer(newAddressing);
299 void pointZoneSet::writeDebug
302 const primitiveMesh& mesh,
306 pointSet::writeDebug(os, mesh, maxLen);
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 } // End namespace Foam
314 // ************************************************************************* //