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