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
27 \*---------------------------------------------------------------------------*/
29 #include "patchZones.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(Foam::patchZones, 0);
37 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
39 // Gets labels of changed faces and propagates them to the edges. Returns
40 // labels of edges changed.
41 Foam::labelList Foam::patchZones::faceToEdge
43 const labelList& changedFaces,
47 labelList changedEdges(pp_.nEdges(), -1);
50 forAll(changedFaces, i)
52 label faceI = changedFaces[i];
54 const labelList& fEdges = pp_.faceEdges()[faceI];
56 forAll(fEdges, fEdgeI)
58 label edgeI = fEdges[fEdgeI];
60 if (!borderEdge_[edgeI] && (edgeRegion[edgeI] == -1))
62 edgeRegion[edgeI] = nZones_;
64 changedEdges[changedI++] = edgeI;
69 changedEdges.setSize(changedI);
75 // Reverse of faceToEdge: gets edges and returns faces
76 Foam::labelList Foam::patchZones::edgeToFace(const labelList& changedEdges)
78 labelList changedFaces(pp_.size(), -1);
81 forAll(changedEdges, i)
83 label edgeI = changedEdges[i];
85 const labelList& eFaces = pp_.edgeFaces()[edgeI];
87 forAll(eFaces, eFaceI)
89 label faceI = eFaces[eFaceI];
91 if (operator[](faceI) == -1)
93 operator[](faceI) = nZones_;
95 changedFaces[changedI++] = faceI;
100 changedFaces.setSize(changedI);
106 // Finds area, starting at faceI, delimited by borderEdge
107 void Foam::patchZones::markZone(label faceI)
109 // List of faces whose faceZone has been set.
110 labelList changedFaces(1, faceI);
111 // List of edges whose faceZone has been set.
112 labelList changedEdges;
114 // Zones on all edges.
115 labelList edgeZone(pp_.nEdges(), -1);
119 changedEdges = faceToEdge(changedFaces, edgeZone);
123 Info<< "From changedFaces:" << changedFaces.size()
124 << " to changedEdges:" << changedEdges.size()
128 if (changedEdges.empty())
133 changedFaces = edgeToFace(changedEdges);
137 Info<< "From changedEdges:" << changedEdges.size()
138 << " to changedFaces:" << changedFaces.size()
142 if (changedEdges.empty())
150 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
152 // Construct from components
153 Foam::patchZones::patchZones
155 const primitivePatch& pp,
156 const boolList& borderEdge
159 labelList(pp.size(), -1),
161 borderEdge_(borderEdge),
164 // Finds areas delimited by borderEdge (or 'real' edges).
165 // Fills *this with zone number accordingly.
167 if (borderEdge.size() != pp_.nEdges())
171 "patchZones::patchZones(const primitivePatch&, const boolList&)"
172 ) << "borderEdge boolList not same size as number of edges" << endl
173 << "borderEdge:" << borderEdge.size() << endl
174 << "nEdges :" << pp_.nEdges()
175 << abort(FatalError);
182 // Find first non-visited face
183 for (; faceI < pp_.size(); faceI++)
185 if (operator[](faceI) == -1)
187 operator[](faceI) = nZones_;
195 if (faceI == pp_.size())
206 // ************************************************************************* //