createPolyCells.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
00031
00032
00033
00034
00035
00036
00037 #include "meshReader.H"
00038
00039
00040
00041 void Foam::meshReader::createPolyCells()
00042 {
00043
00044
00045
00046 const faceListList& cFaces = cellFaces();
00047
00048
00049 cellPolys_.setSize(cFaces.size());
00050
00051 label maxFaces = 0;
00052
00053 forAll(cellPolys_, cellI)
00054 {
00055 cellPolys_[cellI].setSize(cFaces[cellI].size(), -1);
00056
00057 maxFaces += cFaces[cellI].size();
00058 }
00059
00060 Info<< "Maximum possible number of faces in mesh: " << maxFaces << endl;
00061
00062 meshFaces_.setSize(maxFaces);
00063
00064
00065 const labelListList& ptCells = pointCells();
00066
00067
00068 baffleIds_.setSize(baffleFaces_.size());
00069 forAll(baffleIds_, baffleI)
00070 {
00071 baffleIds_[baffleI].setSize(2);
00072 }
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 label baffleOffset = cFaces.size();
00088 forAll(baffleFaces_, baffleI)
00089 {
00090 label cellI = -(baffleOffset + baffleI);
00091 const face& curFace = baffleFaces_[baffleI];
00092
00093
00094 const labelList& curPoints = curFace;
00095
00096
00097
00098 const labelList& curNeighbours = ptCells[curPoints[0]];
00099
00100 label nNeighbours = 0;
00101
00102
00103 forAll(curNeighbours, neiI)
00104 {
00105 label curNei = curNeighbours[neiI];
00106
00107
00108 const faceList& searchFaces = cFaces[curNei];
00109
00110 forAll(searchFaces, neiFaceI)
00111 {
00112 int cmp = face::compare(curFace, searchFaces[neiFaceI]);
00113
00114 if (cmp)
00115 {
00116
00117
00118
00119
00120 label side = 0;
00121 if (cmp < 0)
00122 {
00123 side = 1;
00124 }
00125
00126 #ifdef DEBUG_FACE_ORDERING
00127 Info<< "cmp " << cmp << " matched " << curFace
00128 << " with " << searchFaces[neiFaceI]
00129 << endl;
00130
00131
00132 Info<< "match " << baffleI
00133 << " (" << origCellId_[baffleOffset+baffleI] << ")"
00134 << " side " << side
00135 << " against cell " << curNei
00136 << " face " << neiFaceI
00137 << " curFace " << curFace[1]
00138 << " neiFace " << searchFaces[neiFaceI][1]
00139 << endl;
00140 #endif
00141
00142 if (baffleIds_[baffleI][side].unused())
00143 {
00144 baffleIds_[baffleI][side] = cellFaceIdentifier
00145 (
00146 curNei,
00147 neiFaceI
00148 );
00149
00150 nNeighbours++;
00151 }
00152 else
00153 {
00154 Info<< "multiple matches for side " << side
00155 << " of baffle " << baffleI
00156 << " (original cell "
00157 << origCellId_[baffleOffset+baffleI] << ")"
00158 << endl;
00159 }
00160 break;
00161 }
00162 }
00163 if (nNeighbours >= 2) break;
00164 }
00165
00166 if (nNeighbours == 2)
00167 {
00168 for (label side = 0; side < nNeighbours; ++side)
00169 {
00170 label neiCell = baffleIds_[baffleI][side].cell;
00171 label neiFace = baffleIds_[baffleI][side].face;
00172
00173 if (baffleIds_[baffleI][side].used())
00174 {
00175 cellPolys_[neiCell][neiFace] = cellI;
00176 }
00177 }
00178 }
00179 else
00180 {
00181 Info<< "drop baffle " << baffleI
00182 << " (original cell "
00183 << origCellId_[baffleOffset+baffleI] << ")"
00184 << " with " << nNeighbours << " neighbours" << endl;
00185
00186 baffleFaces_[baffleI].clear();
00187 baffleIds_[baffleI].clear();
00188 }
00189 }
00190
00191 #ifdef DEBUG_CELLPOLY
00192 Info<< "cellPolys_" << cellPolys_ << endl;
00193 Info<< "baffleFaces_" << baffleFaces_ << endl;
00194 Info<< "baffleIds_" << baffleIds_ << endl;
00195 #endif
00196
00197 bool found = false;
00198
00199 nInternalFaces_ = 0;
00200
00201 forAll(cFaces, cellI)
00202 {
00203
00204
00205
00206
00207
00208
00209 const faceList& curFaces = cFaces[cellI];
00210
00211
00212 labelList neiCells(curFaces.size(), -1);
00213
00214
00215 labelList faceOfNeiCell(curFaces.size(), -1);
00216
00217 label nNeighbours = 0;
00218
00219
00220 forAll(curFaces, faceI)
00221 {
00222
00223 if (cellPolys_[cellI][faceI] != -1) continue;
00224
00225 found = false;
00226
00227 const face& curFace = curFaces[faceI];
00228
00229
00230 const labelList& curPoints = curFace;
00231
00232
00233 forAll(curPoints, pointI)
00234 {
00235
00236 const labelList& curNeighbours = ptCells[curPoints[pointI]];
00237
00238
00239 forAll(curNeighbours, neiI)
00240 {
00241 label curNei = curNeighbours[neiI];
00242
00243
00244
00245 if (curNei > cellI)
00246 {
00247
00248 const faceList& searchFaces = cFaces[curNei];
00249
00250 forAll(searchFaces, neiFaceI)
00251 {
00252 if (searchFaces[neiFaceI] == curFace)
00253 {
00254
00255 neiCells[faceI] = curNei;
00256 faceOfNeiCell[faceI] = neiFaceI;
00257 nNeighbours++;
00258 #ifdef DEBUG_FACE_ORDERING
00259 Info<< " cell " << cellI
00260 << " face " << faceI
00261 << " point " << pointI
00262 << " nei " << curNei
00263 << " neiFace " << neiFaceI
00264 << endl;
00265 #endif
00266 found = true;
00267 break;
00268 }
00269 }
00270 if (found) break;
00271 }
00272 if (found) break;
00273 }
00274 if (found) break;
00275 }
00276 }
00277
00278
00279 for (label neiSearch = 0; neiSearch < nNeighbours; neiSearch++)
00280 {
00281
00282 label nextNei = -1;
00283 label minNei = cellPolys_.size();
00284
00285 forAll(neiCells, ncI)
00286 {
00287 if (neiCells[ncI] > -1 && neiCells[ncI] < minNei)
00288 {
00289 nextNei = ncI;
00290 minNei = neiCells[ncI];
00291 }
00292 }
00293
00294 if (nextNei > -1)
00295 {
00296
00297 meshFaces_[nInternalFaces_] = curFaces[nextNei];
00298
00299
00300 cellPolys_[cellI][nextNei] = nInternalFaces_;
00301
00302
00303 cellPolys_[neiCells[nextNei]][faceOfNeiCell[nextNei]] =
00304 nInternalFaces_;
00305
00306
00307 neiCells[nextNei] = -1;
00308
00309
00310 nInternalFaces_++;
00311 }
00312 else
00313 {
00314 FatalErrorIn("meshReader::createPolyCells()")
00315 << "Error in internal face insertion"
00316 << abort(FatalError);
00317 }
00318 }
00319 }
00320
00321 #ifdef DEBUG_CELLPOLY
00322 Info<< "cellPolys = " << cellPolys_ << endl;
00323 #endif
00324
00325
00326
00327 }
00328
00329
00330
Copyright © 2000-2009 OpenCFD Ltd