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
00031
00032
00033
00034
00035
00036
00037 #include "PrimitivePatch_.H"
00038 #include <OpenFOAM/DynamicList.H>
00039
00040
00041
00042
00043 template
00044 <
00045 class Face,
00046 template<class> class FaceList,
00047 class PointField,
00048 class PointType
00049 >
00050 void
00051 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00052 calcAddressing() const
00053 {
00054 if (debug)
00055 {
00056 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00057 << "calcAddressing() : calculating patch addressing"
00058 << endl;
00059 }
00060
00061 if (edgesPtr_ || faceFacesPtr_ || edgeFacesPtr_ || faceEdgesPtr_)
00062 {
00063
00064
00065 FatalErrorIn
00066 (
00067 "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00068 "calcAddressing()"
00069 ) << "addressing already calculated"
00070 << abort(FatalError);
00071 }
00072
00073
00074 const List<Face>& locFcs = localFaces();
00075
00076
00077 const labelListList& pf = pointFaces();
00078
00079
00080 label maxEdges = 0;
00081 forAll (locFcs, faceI)
00082 {
00083 maxEdges += locFcs[faceI].size();
00084 }
00085
00086
00087 edgesPtr_ = new edgeList(maxEdges);
00088 edgeList& edges = *edgesPtr_;
00089
00090 edgeFacesPtr_ = new labelListList(maxEdges);
00091 labelListList& edgeFaces = *edgeFacesPtr_;
00092
00093
00094
00095 List<DynamicList<label> > ff(locFcs.size());
00096
00097 faceEdgesPtr_ = new labelListList(locFcs.size());
00098 labelListList& faceEdges = *faceEdgesPtr_;
00099
00100
00101 labelList noFaceFaces(locFcs.size());
00102
00103
00104 edgeListList faceIntoEdges(locFcs.size());
00105
00106 forAll (locFcs, faceI)
00107 {
00108 faceIntoEdges[faceI] = locFcs[faceI].edges();
00109
00110 labelList& curFaceEdges = faceEdges[faceI];
00111 curFaceEdges.setSize(faceIntoEdges[faceI].size());
00112
00113 forAll (curFaceEdges, faceEdgeI)
00114 {
00115 curFaceEdges[faceEdgeI] = -1;
00116 }
00117 }
00118
00119
00120
00121
00122
00123 label nEdges = 0;
00124
00125 bool found = false;
00126
00127
00128
00129
00130
00131 forAll (locFcs, faceI)
00132 {
00133
00134 const Face& curF = locFcs[faceI];
00135 const edgeList& curEdges = faceIntoEdges[faceI];
00136
00137
00138 List<DynamicList<label> > neiFaces(curF.size());
00139 List<DynamicList<label> > edgeOfNeiFace(curF.size());
00140
00141 label nNeighbours = 0;
00142
00143
00144 forAll (curEdges, edgeI)
00145 {
00146
00147 if (faceEdges[faceI][edgeI] >= 0) continue;
00148
00149 found = false;
00150
00151
00152 const edge& e = curEdges[edgeI];
00153
00154
00155
00156 const labelList& nbrFaces = pf[e.start()];
00157
00158 forAll (nbrFaces, nbrFaceI)
00159 {
00160
00161 label curNei = nbrFaces[nbrFaceI];
00162
00163
00164 if (curNei > faceI)
00165 {
00166
00167 const edgeList& searchEdges = faceIntoEdges[curNei];
00168
00169 forAll (searchEdges, neiEdgeI)
00170 {
00171 if (searchEdges[neiEdgeI] == e)
00172 {
00173
00174 found = true;
00175
00176 neiFaces[edgeI].append(curNei);
00177 edgeOfNeiFace[edgeI].append(neiEdgeI);
00178
00179
00180 ff[faceI].append(curNei);
00181 ff[curNei].append(faceI);
00182
00183
00184 }
00185 }
00186 }
00187 }
00188
00189 if (found)
00190 {
00191
00192 nNeighbours++;
00193 }
00194 }
00195
00196
00197
00198
00199
00200
00201 for (label neiSearch = 0; neiSearch < nNeighbours; neiSearch++)
00202 {
00203
00204 label nextNei = -1;
00205 label minNei = locFcs.size();
00206
00207 forAll (neiFaces, nfI)
00208 {
00209 if (neiFaces[nfI].size() && neiFaces[nfI][0] < minNei)
00210 {
00211 nextNei = nfI;
00212 minNei = neiFaces[nfI][0];
00213 }
00214 }
00215
00216 if (nextNei > -1)
00217 {
00218
00219 edges[nEdges] = curEdges[nextNei];
00220
00221
00222 faceEdges[faceI][nextNei] = nEdges;
00223
00224 DynamicList<label>& cnf = neiFaces[nextNei];
00225 DynamicList<label>& eonf = edgeOfNeiFace[nextNei];
00226
00227
00228 labelList& curEf = edgeFaces[nEdges];
00229 curEf.setSize(cnf.size() + 1);
00230 curEf[0] = faceI;
00231
00232 forAll (cnf, cnfI)
00233 {
00234 faceEdges[cnf[cnfI]][eonf[cnfI]] = nEdges;
00235
00236 curEf[cnfI + 1] = cnf[cnfI];
00237 }
00238
00239
00240 cnf.clear();
00241 eonf.clear();
00242
00243
00244 nEdges++;
00245 }
00246 else
00247 {
00248 FatalErrorIn
00249 (
00250 "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00251 "calcAddressing()"
00252 ) << "Error in internal edge insertion"
00253 << abort(FatalError);
00254 }
00255 }
00256 }
00257
00258 nInternalEdges_ = nEdges;
00259
00260
00261
00262 forAll (faceEdges, faceI)
00263 {
00264 labelList& curEdges = faceEdges[faceI];
00265
00266 forAll (curEdges, edgeI)
00267 {
00268 if (curEdges[edgeI] < 0)
00269 {
00270
00271 edges[nEdges] = faceIntoEdges[faceI][edgeI];
00272 curEdges[edgeI] = nEdges;
00273
00274
00275 labelList& curEf = edgeFaces[nEdges];
00276 curEf.setSize(1);
00277 curEf[0] = faceI;
00278
00279 nEdges++;
00280 }
00281 }
00282 }
00283
00284
00285 edges.setSize(nEdges);
00286
00287
00288 edgeFaces.setSize(nEdges);
00289
00290
00291 faceFacesPtr_ = new labelListList(locFcs.size());
00292 labelListList& faceFaces = *faceFacesPtr_;
00293
00294 forAll (faceFaces, faceI)
00295 {
00296 faceFaces[faceI].transfer(ff[faceI]);
00297 }
00298
00299
00300 if (debug)
00301 {
00302 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00303 << "calcAddressing() : finished calculating patch addressing"
00304 << endl;
00305 }
00306 }
00307
00308
00309