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 "patchZones.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 defineTypeNameAndDebug(Foam::patchZones, 0);
34 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
36 // Gets labels of changed faces and propagates them to the edges. Returns
37 // labels of edges changed.
38 Foam::labelList Foam::patchZones::faceToEdge
40 const labelList& changedFaces,
44 labelList changedEdges(pp_.nEdges(), -1);
47 forAll(changedFaces, i)
49 label faceI = changedFaces[i];
51 const labelList& fEdges = pp_.faceEdges()[faceI];
53 forAll(fEdges, fEdgeI)
55 label edgeI = fEdges[fEdgeI];
57 if (!borderEdge_[edgeI] && (edgeRegion[edgeI] == -1))
59 edgeRegion[edgeI] = nZones_;
61 changedEdges[changedI++] = edgeI;
66 changedEdges.setSize(changedI);
72 // Reverse of faceToEdge: gets edges and returns faces
73 Foam::labelList Foam::patchZones::edgeToFace(const labelList& changedEdges)
75 labelList changedFaces(pp_.size(), -1);
78 forAll(changedEdges, i)
80 label edgeI = changedEdges[i];
82 const labelList& eFaces = pp_.edgeFaces()[edgeI];
84 forAll(eFaces, eFaceI)
86 label faceI = eFaces[eFaceI];
88 if (operator[](faceI) == -1)
90 operator[](faceI) = nZones_;
92 changedFaces[changedI++] = faceI;
97 changedFaces.setSize(changedI);
103 // Finds area, starting at faceI, delimited by borderEdge
104 void Foam::patchZones::markZone(label faceI)
106 // List of faces whose faceZone has been set.
107 labelList changedFaces(1, faceI);
108 // List of edges whose faceZone has been set.
109 labelList changedEdges;
111 // Zones on all edges.
112 labelList edgeZone(pp_.nEdges(), -1);
116 changedEdges = faceToEdge(changedFaces, edgeZone);
120 Info<< "From changedFaces:" << changedFaces.size()
121 << " to changedEdges:" << changedEdges.size()
125 if (changedEdges.empty())
130 changedFaces = edgeToFace(changedEdges);
134 Info<< "From changedEdges:" << changedEdges.size()
135 << " to changedFaces:" << changedFaces.size()
139 if (changedEdges.empty())
147 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
149 // Construct from components
150 Foam::patchZones::patchZones
152 const primitivePatch& pp,
153 const boolList& borderEdge
156 labelList(pp.size(), -1),
158 borderEdge_(borderEdge),
161 // Finds areas delimited by borderEdge (or 'real' edges).
162 // Fills *this with zone number accordingly.
164 if (borderEdge.size() != pp_.nEdges())
168 "patchZones::patchZones(const primitivePatch&, const boolList&)"
169 ) << "borderEdge boolList not same size as number of edges" << endl
170 << "borderEdge:" << borderEdge.size() << endl
171 << "nEdges :" << pp_.nEdges()
172 << abort(FatalError);
179 // Find first non-visited face
180 for (; faceI < pp_.size(); faceI++)
182 if (operator[](faceI) == -1)
184 operator[](faceI) = nZones_;
192 if (faceI == pp_.size())
203 // ************************************************************************* //