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