/usr/include/freefoam/OpenFOAM/PrimitivePatchAddressing.C is in libfreefoam-dev 0.1.0+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
This function calculates the list of patch edges, defined on the list of
points supporting the patch. The edges are ordered:
- 0..nInternalEdges-1 : upper triangular order
- nInternalEdges.. : boundary edges (no particular order)
Other patch addressing information is also calculated:
- faceFaces with neighbour faces in ascending order
- edgeFaces with ascending face order
- faceEdges sorted according to edges of a face
\*---------------------------------------------------------------------------*/
#include "PrimitivePatch_.H"
#include <OpenFOAM/DynamicList.H>
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcAddressing() const
{
if (debug)
{
Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
<< "calcAddressing() : calculating patch addressing"
<< endl;
}
if (edgesPtr_ || faceFacesPtr_ || edgeFacesPtr_ || faceEdgesPtr_)
{
// it is considered an error to attempt to recalculate
// if already allocated
FatalErrorIn
(
"PrimitivePatch<Face, FaceList, PointField, PointType>::"
"calcAddressing()"
) << "addressing already calculated"
<< abort(FatalError);
}
// get reference to localFaces
const List<Face>& locFcs = localFaces();
// get reference to pointFaces
const labelListList& pf = pointFaces();
// Guess the max number of edges and neighbours for a face
label maxEdges = 0;
forAll (locFcs, faceI)
{
maxEdges += locFcs[faceI].size();
}
// create the lists for the various results. (resized on completion)
edgesPtr_ = new edgeList(maxEdges);
edgeList& edges = *edgesPtr_;
edgeFacesPtr_ = new labelListList(maxEdges);
labelListList& edgeFaces = *edgeFacesPtr_;
// faceFaces created using a dynamic list. Cannot guess size because
// of multiple connections
List<DynamicList<label> > ff(locFcs.size());
faceEdgesPtr_ = new labelListList(locFcs.size());
labelListList& faceEdges = *faceEdgesPtr_;
// count the number of face neighbours
labelList noFaceFaces(locFcs.size());
// initialise the lists of subshapes for each face to avoid duplication
edgeListList faceIntoEdges(locFcs.size());
forAll (locFcs, faceI)
{
faceIntoEdges[faceI] = locFcs[faceI].edges();
labelList& curFaceEdges = faceEdges[faceI];
curFaceEdges.setSize(faceIntoEdges[faceI].size());
forAll (curFaceEdges, faceEdgeI)
{
curFaceEdges[faceEdgeI] = -1;
}
}
// This algorithm will produce a separated list of edges, internal edges
// starting from 0 and boundary edges starting from the top and
// growing down.
label nEdges = 0;
bool found = false;
// Note that faceIntoEdges is sorted acc. to local vertex numbering
// in face (i.e. curEdges[0] is edge between f[0] and f[1])
// For all local faces ...
forAll (locFcs, faceI)
{
// Get reference to vertices of current face and corresponding edges.
const Face& curF = locFcs[faceI];
const edgeList& curEdges = faceIntoEdges[faceI];
// Record the neighbour face. Multiple connectivity allowed
List<DynamicList<label> > neiFaces(curF.size());
List<DynamicList<label> > edgeOfNeiFace(curF.size());
label nNeighbours = 0;
// For all edges ...
forAll (curEdges, edgeI)
{
// If the edge is already detected, skip
if (faceEdges[faceI][edgeI] >= 0) continue;
found = false;
// Set reference to the current edge
const edge& e = curEdges[edgeI];
// Collect neighbours for the current face vertex.
const labelList& nbrFaces = pf[e.start()];
forAll (nbrFaces, nbrFaceI)
{
// set reference to the current neighbour
label curNei = nbrFaces[nbrFaceI];
// Reject neighbours with the lower label
if (curNei > faceI)
{
// get the reference to subshapes of the neighbour
const edgeList& searchEdges = faceIntoEdges[curNei];
forAll (searchEdges, neiEdgeI)
{
if (searchEdges[neiEdgeI] == e)
{
// Match
found = true;
neiFaces[edgeI].append(curNei);
edgeOfNeiFace[edgeI].append(neiEdgeI);
// Record faceFaces both ways
ff[faceI].append(curNei);
ff[curNei].append(faceI);
// Keep searching due to multiple connectivity
}
}
}
} // End of neighbouring faces
if (found)
{
// Register another detected internal edge
nNeighbours++;
}
} // End of current edges
// Add the edges in increasing number of neighbours.
// Note: for multiply connected surfaces, the lower index neighbour for
// an edge will come first.
// Add the faces in the increasing order of neighbours
for (label neiSearch = 0; neiSearch < nNeighbours; neiSearch++)
{
// Find the lowest neighbour which is still valid
label nextNei = -1;
label minNei = locFcs.size();
forAll (neiFaces, nfI)
{
if (neiFaces[nfI].size() && neiFaces[nfI][0] < minNei)
{
nextNei = nfI;
minNei = neiFaces[nfI][0];
}
}
if (nextNei > -1)
{
// Add the face to the list of faces
edges[nEdges] = curEdges[nextNei];
// Set face-edge and face-neighbour-edge to current face label
faceEdges[faceI][nextNei] = nEdges;
DynamicList<label>& cnf = neiFaces[nextNei];
DynamicList<label>& eonf = edgeOfNeiFace[nextNei];
// Set edge-face addressing
labelList& curEf = edgeFaces[nEdges];
curEf.setSize(cnf.size() + 1);
curEf[0] = faceI;
forAll (cnf, cnfI)
{
faceEdges[cnf[cnfI]][eonf[cnfI]] = nEdges;
curEf[cnfI + 1] = cnf[cnfI];
}
// Stop the neighbour from being used again
cnf.clear();
eonf.clear();
// Increment number of faces counter
nEdges++;
}
else
{
FatalErrorIn
(
"PrimitivePatch<Face, FaceList, PointField, PointType>::"
"calcAddressing()"
) << "Error in internal edge insertion"
<< abort(FatalError);
}
}
}
nInternalEdges_ = nEdges;
// Do boundary faces
forAll (faceEdges, faceI)
{
labelList& curEdges = faceEdges[faceI];
forAll (curEdges, edgeI)
{
if (curEdges[edgeI] < 0)
{
// Grab edge and faceEdge
edges[nEdges] = faceIntoEdges[faceI][edgeI];
curEdges[edgeI] = nEdges;
// Add edgeFace
labelList& curEf = edgeFaces[nEdges];
curEf.setSize(1);
curEf[0] = faceI;
nEdges++;
}
}
}
// edges
edges.setSize(nEdges);
// edgeFaces list
edgeFaces.setSize(nEdges);
// faceFaces list
faceFacesPtr_ = new labelListList(locFcs.size());
labelListList& faceFaces = *faceFacesPtr_;
forAll (faceFaces, faceI)
{
faceFaces[faceI].transfer(ff[faceI]);
}
if (debug)
{
Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
<< "calcAddressing() : finished calculating patch addressing"
<< endl;
}
}
// ************************ vim: set sw=4 sts=4 et: ************************ //
|