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 \*---------------------------------------------------------------------------*/
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);
46 addToRunTimeSelectionTable(topoSet, faceSet, set);
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 faceSet::faceSet(const IOobject& obj)
53 topoSet(obj, typeName)
65 topoSet(mesh, typeName, name, r, w)
79 topoSet(mesh, name, size, w)
91 topoSet(mesh, name, set, w)
99 const labelHashSet& set,
103 topoSet(mesh, name, set, w)
107 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 void faceSet::sync(const polyMesh& mesh)
117 const polyBoundaryMesh& patches = mesh.boundaryMesh();
121 if (Pstream::parRun())
123 // Send faces in set that are on a processorPatch. Send as patch face
125 forAll(patches, patchI)
127 const polyPatch& pp = patches[patchI];
129 if (isA<processorPolyPatch>(pp))
131 const processorPolyPatch& procPatch =
132 refCast<const processorPolyPatch>(pp);
134 // Convert faceSet locally to labelList.
135 DynamicList<label> setFaces(pp.size());
139 if (found(pp.start() + i))
149 procPatch.neighbProcNo()
152 toNeighbour << setFaces;
157 forAll(patches, patchI)
159 const polyPatch& pp = patches[patchI];
161 if (isA<processorPolyPatch>(pp))
163 const processorPolyPatch& procPatch =
164 refCast<const processorPolyPatch>(pp);
166 IPstream fromNeighbour
169 procPatch.neighbProcNo()
172 labelList setFaces(fromNeighbour);
176 if (insert(pp.start() + setFaces[i]))
185 // Couple cyclic patches
186 forAll (patches, patchI)
188 const polyPatch& pp = patches[patchI];
190 if (isA<cyclicPolyPatch>(pp))
192 const cyclicPolyPatch& cycPatch =
193 refCast<const cyclicPolyPatch>(pp);
197 label thisFaceI = cycPatch.start() + i;
198 label otherFaceI = cycPatch.transformGlobalFace(thisFaceI);
200 if (found(thisFaceI))
202 if (insert(otherFaceI))
207 else if (found(otherFaceI))
209 if (insert(thisFaceI))
219 reduce(nAdded, sumOp<label>());
223 // Info<< "Added an additional " << nAdded
224 // << " faces on coupled patches. "
225 // << "(processorPolyPatch, cyclicPolyPatch)" << endl;
230 label faceSet::maxSize(const polyMesh& mesh) const
232 return mesh.nFaces();
236 void faceSet::updateMesh(const mapPolyMesh& morphMap)
238 updateLabels(morphMap.reverseFaceMap());
242 void faceSet::writeDebug
245 const primitiveMesh& mesh,
249 topoSet::writeDebug(os, mesh.faceCentres(), maxLen);
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 } // End namespace Foam
257 // ************************************************************************* //