PatchToolsSearch.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "PatchTools.H"
00031
00032
00033
00034
00035
00036 template
00037 <
00038 class BoolListType,
00039 class Face,
00040 template<class> class FaceList,
00041 class PointField,
00042 class PointType
00043 >
00044
00045 void
00046 Foam::PatchTools::markZone
00047 (
00048 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
00049 const BoolListType& borderEdge,
00050 const label faceI,
00051 const label currentZone,
00052 labelList& faceZone
00053 )
00054 {
00055 const labelListList& faceEdges = p.faceEdges();
00056 const labelListList& edgeFaces = p.edgeFaces();
00057
00058
00059 labelList changedFaces(1, faceI);
00060
00061 while (true)
00062 {
00063
00064 DynamicList<label> newChangedFaces(2*changedFaces.size());
00065
00066 forAll(changedFaces, i)
00067 {
00068 label faceI = changedFaces[i];
00069
00070 const labelList& fEdges = faceEdges[faceI];
00071
00072 forAll(fEdges, fEdgeI)
00073 {
00074 label edgeI = fEdges[fEdgeI];
00075
00076 if (!borderEdge[edgeI])
00077 {
00078 const labelList& eFaceLst = edgeFaces[edgeI];
00079
00080 forAll(eFaceLst, j)
00081 {
00082 label nbrFaceI = eFaceLst[j];
00083
00084 if (faceZone[nbrFaceI] == -1)
00085 {
00086 faceZone[nbrFaceI] = currentZone;
00087 newChangedFaces.append(nbrFaceI);
00088 }
00089 else if (faceZone[nbrFaceI] != currentZone)
00090 {
00091 FatalErrorIn
00092 (
00093 "PatchTools::markZone"
00094 "(const boolList&, const label, const label, labelList&)"
00095 )
00096 << "Zones " << faceZone[nbrFaceI]
00097 << " at face " << nbrFaceI
00098 << " connects to zone " << currentZone
00099 << " at face " << faceI
00100 << abort(FatalError);
00101 }
00102 }
00103 }
00104 }
00105 }
00106
00107 if (newChangedFaces.empty())
00108 {
00109 break;
00110 }
00111
00112
00113 changedFaces.transfer(newChangedFaces);
00114 }
00115 }
00116
00117
00118
00119
00120 template
00121 <
00122 class BoolListType,
00123 class Face,
00124 template<class> class FaceList,
00125 class PointField,
00126 class PointType
00127 >
00128
00129 Foam::label
00130 Foam::PatchTools::markZones
00131 (
00132 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
00133 const BoolListType& borderEdge,
00134 labelList& faceZone
00135 )
00136 {
00137 faceZone.setSize(p.size());
00138 faceZone = -1;
00139
00140 label zoneI = 0;
00141 for (label startFaceI = 0; startFaceI < faceZone.size();)
00142 {
00143
00144 for (; startFaceI < faceZone.size(); ++startFaceI)
00145 {
00146 if (faceZone[startFaceI] == -1)
00147 {
00148 faceZone[startFaceI] = zoneI;
00149 markZone(p, borderEdge, startFaceI, zoneI, faceZone);
00150 zoneI++;
00151 break;
00152 }
00153 }
00154 }
00155
00156 return zoneI;
00157 }
00158
00159
00160
00161
00162
00163 template
00164 <
00165 class BoolListType,
00166 class Face,
00167 template<class> class FaceList,
00168 class PointField,
00169 class PointType
00170 >
00171
00172 void
00173 Foam::PatchTools::subsetMap
00174 (
00175 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
00176 const BoolListType& includeFaces,
00177 labelList& pointMap,
00178 labelList& faceMap
00179 )
00180 {
00181 label faceI = 0;
00182 label pointI = 0;
00183
00184 const List<Face>& localFaces = p.localFaces();
00185
00186 faceMap.setSize(localFaces.size());
00187 pointMap.setSize(p.nPoints());
00188
00189 boolList pointHad(pointMap.size(), false);
00190
00191 forAll(p, oldFaceI)
00192 {
00193 if (includeFaces[oldFaceI])
00194 {
00195
00196 faceMap[faceI++] = oldFaceI;
00197
00198
00199 const Face& f = localFaces[oldFaceI];
00200
00201 forAll(f, fp)
00202 {
00203 const label ptLabel = f[fp];
00204 if (!pointHad[ptLabel])
00205 {
00206 pointHad[ptLabel] = true;
00207 pointMap[pointI++] = ptLabel;
00208 }
00209 }
00210 }
00211 }
00212
00213
00214 faceMap.setSize(faceI);
00215 pointMap.setSize(pointI);
00216 }
00217
00218
00219
Copyright © 2000-2009 OpenCFD Ltd