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 \*---------------------------------------------------------------------------*/
28 #include "mapPolyMesh.H"
30 #include "processorPolyPatch.H"
31 #include "cyclicPolyPatch.H"
33 #include "addToRunTimeSelectionTable.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(faceSet, 0);
44 addToRunTimeSelectionTable(topoSet, faceSet, word);
45 addToRunTimeSelectionTable(topoSet, faceSet, size);
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 faceSet::faceSet(const IOobject& obj)
52 topoSet(obj, typeName)
64 topoSet(mesh, typeName, name, r, w)
78 topoSet(mesh, name, size, w)
86 const labelHashSet& set,
90 topoSet(mesh, name, set, w)
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 void faceSet::sync(const polyMesh& mesh)
104 const polyBoundaryMesh& patches = mesh.boundaryMesh();
108 if (Pstream::parRun())
110 // Send faces in set that are on a processorPatch. Send as patch face
112 forAll(patches, patchI)
114 const polyPatch& pp = patches[patchI];
116 if (isType<processorPolyPatch>(pp))
118 const processorPolyPatch& procPatch =
119 refCast<const processorPolyPatch>(pp);
121 // Convert faceSet locally to labelList.
122 DynamicList<label> setFaces(pp.size());
126 if (found(pp.start() + i))
136 procPatch.neighbProcNo()
139 toNeighbour << setFaces;
144 forAll(patches, patchI)
146 const polyPatch& pp = patches[patchI];
148 if (isType<processorPolyPatch>(pp))
150 const processorPolyPatch& procPatch =
151 refCast<const processorPolyPatch>(pp);
153 IPstream fromNeighbour
156 procPatch.neighbProcNo()
159 labelList setFaces(fromNeighbour);
163 if (insert(pp.start() + setFaces[i]))
172 // Couple cyclic patches
173 forAll (patches, patchI)
175 const polyPatch& pp = patches[patchI];
177 if (typeid(pp) == typeid(cyclicPolyPatch))
179 const cyclicPolyPatch& cycPatch =
180 refCast<const cyclicPolyPatch>(pp);
184 label thisFaceI = cycPatch.start() + i;
185 label otherFaceI = cycPatch.transformGlobalFace(thisFaceI);
187 if (found(thisFaceI))
189 if (insert(otherFaceI))
194 else if (found(otherFaceI))
196 if (insert(thisFaceI))
206 reduce(nAdded, sumOp<label>());
210 // Info<< "Added an additional " << nAdded
211 // << " faces on coupled patches. "
212 // << "(processorPolyPatch, cyclicPolyPatch)" << endl;
217 label faceSet::maxSize(const polyMesh& mesh) const
219 return mesh.nFaces();
223 void faceSet::updateMesh(const mapPolyMesh& morphMap)
225 updateLabels(morphMap.reverseFaceMap());
229 void faceSet::writeDebug
232 const primitiveMesh& mesh,
236 topoSet::writeDebug(os, mesh.faceCentres(), maxLen);
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 } // End namespace Foam
244 // ************************************************************************* //