removeCellLayer.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 "layerAdditionRemoval.H"
00031 #include "polyMesh.H"
00032 #include "primitiveMesh.H"
00033 #include "polyTopoChange.H"
00034 #include "oppositeFace.H"
00035 #include "polyTopoChanger.H"
00036 #include "polyRemoveCell.H"
00037 #include "polyRemoveFace.H"
00038 #include "polyRemovePoint.H"
00039 #include "polyModifyFace.H"
00040
00041
00042
00043 bool Foam::layerAdditionRemoval::validCollapse() const
00044 {
00045
00046
00047
00048 if (debug)
00049 {
00050 Pout << "Checking layer collapse for object " << name() << endl;
00051 }
00052
00053
00054 const polyMesh& mesh = topoChanger().mesh();
00055
00056 const labelList& ftc = facesPairing();
00057 const labelList& mf = mesh.faceZones()[faceZoneID_.index()];
00058
00059 label nBoundaryHits = 0;
00060
00061 forAll (mf, faceI)
00062 {
00063 if
00064 (
00065 !mesh.isInternalFace(mf[faceI])
00066 && !mesh.isInternalFace(ftc[faceI])
00067 )
00068 {
00069 nBoundaryHits++;
00070 }
00071 }
00072
00073
00074 if (debug)
00075 {
00076 Pout<< "Finished checking layer collapse for object "
00077 << name() <<". Number of boundary-on-boundary hits: "
00078 << nBoundaryHits << endl;
00079 }
00080
00081 if (returnReduce(nBoundaryHits, sumOp<label>()) > 0)
00082 {
00083 return false;
00084 }
00085 else
00086 {
00087 return true;
00088 }
00089 }
00090
00091 void Foam::layerAdditionRemoval::removeCellLayer
00092 (
00093 polyTopoChange& ref
00094 ) const
00095 {
00096
00097
00098
00099
00100
00101
00102
00103
00104 if (debug)
00105 {
00106 Pout << "Removing the cell layer for object " << name() << endl;
00107 }
00108
00109 const polyMesh& mesh = topoChanger().mesh();
00110
00111 const labelList& ptc = pointsPairing();
00112 const labelList& ftc = facesPairing();
00113
00114
00115 const labelList& mc =
00116 topoChanger().mesh().faceZones()[faceZoneID_.index()].masterCells();
00117
00118 forAll (mc, cellI)
00119 {
00120 ref.setAction(polyRemoveCell(mc[cellI]));
00121 }
00122
00123
00124
00125 labelHashSet facesToRemoveMap(mc.size()*primitiveMesh::facesPerCell_);
00126
00127 const cellList& cells = mesh.cells();
00128
00129 forAll (mc, cellI)
00130 {
00131 const cell& curCell = cells[mc[cellI]];
00132
00133 forAll (curCell, faceI)
00134 {
00135
00136 if
00137 (
00138 mesh.faceZones().whichZone(curCell[faceI])
00139 != faceZoneID_.index()
00140 )
00141 {
00142 facesToRemoveMap.insert(curCell[faceI]);
00143 }
00144 }
00145 }
00146
00147 forAllConstIter(labelHashSet, facesToRemoveMap, iter)
00148 {
00149 ref.setAction(polyRemoveFace(iter.key()));
00150 }
00151
00152
00153 forAll (ptc, pointI)
00154 {
00155 ref.setAction(polyRemovePoint(ptc[pointI]));
00156 }
00157
00158
00159
00160
00161
00162
00163
00164
00165 Map<label> removedPointMap(2*ptc.size());
00166
00167 const labelList& meshPoints =
00168 mesh.faceZones()[faceZoneID_.index()]().meshPoints();
00169
00170 forAll (ptc, pointI)
00171 {
00172 removedPointMap.insert(ptc[pointI], meshPoints[pointI]);
00173 }
00174
00175 const labelListList& pf = mesh.pointFaces();
00176
00177 const faceList& faces = mesh.faces();
00178 const labelList& own = mesh.faceOwner();
00179 const labelList& nei = mesh.faceNeighbour();
00180
00181
00182 labelHashSet facesToModify(ptc.size()*primitiveMesh::facesPerPoint_);
00183
00184 forAll (ptc, pointI)
00185 {
00186 const labelList& curFaces = pf[ptc[pointI]];
00187
00188 forAll (curFaces, faceI)
00189 {
00190 if (!facesToRemoveMap.found(curFaces[faceI]))
00191 {
00192 facesToModify.insert(curFaces[faceI]);
00193 }
00194 }
00195 }
00196
00197 labelList ftm = facesToModify.toc();
00198
00199
00200
00201 forAll (ftm, faceI)
00202 {
00203
00204
00205
00206 label curFaceID = ftm[faceI];
00207
00208 face newFace(faces[curFaceID]);
00209
00210 forAll (newFace, pointI)
00211 {
00212 Map<label>::iterator rpmIter =
00213 removedPointMap.find(newFace[pointI]);
00214
00215 if (rpmIter != removedPointMap.end())
00216 {
00217
00218 newFace[pointI] = rpmIter();
00219 }
00220 }
00221
00222
00223
00224
00225
00226
00227 label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID);
00228 bool modifiedFaceZoneFlip = false;
00229
00230 if (modifiedFaceZone >= 0)
00231 {
00232 modifiedFaceZoneFlip =
00233 mesh.faceZones()[modifiedFaceZone].flipMap()
00234 [
00235 mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID)
00236 ];
00237 }
00238
00239 label newNei;
00240
00241 if (curFaceID < mesh.nInternalFaces())
00242 {
00243 newNei = nei[curFaceID];
00244 }
00245 else
00246 {
00247 newNei = -1;
00248 }
00249
00250
00251 ref.setAction
00252 (
00253 polyModifyFace
00254 (
00255 newFace,
00256 curFaceID,
00257 own[curFaceID],
00258 newNei,
00259 false,
00260 mesh.boundaryMesh().whichPatch(curFaceID),
00261 false,
00262 modifiedFaceZone,
00263 modifiedFaceZoneFlip
00264 )
00265 );
00266 }
00267
00268
00269
00270 const labelList& mf = mesh.faceZones()[faceZoneID_.index()];
00271 const boolList& mfFlip = mesh.faceZones()[faceZoneID_.index()].flipMap();
00272
00273 forAll (mf, faceI)
00274 {
00275
00276
00277 label masterSideCell = own[mf[faceI]];
00278
00279 if (masterSideCell == mc[faceI])
00280 {
00281
00282
00283 masterSideCell = nei[mf[faceI]];
00284 }
00285
00286 label slaveSideCell = own[ftc[faceI]];
00287
00288 if (slaveSideCell == mc[faceI])
00289 {
00290
00291
00292 slaveSideCell = nei[ftc[faceI]];
00293 }
00294
00295
00296 label newOwner = -1;
00297 label newNeighbour = -1;
00298 bool flipFace = false;
00299 label newPatchID = -1;
00300 label newZoneID = -1;
00301
00302
00303
00304
00305
00306 if (!mesh.isInternalFace(mf[faceI]))
00307 {
00308
00309 newOwner = slaveSideCell;
00310 newNeighbour = -1;
00311 flipFace = false;
00312 newPatchID = mesh.boundaryMesh().whichPatch(mf[faceI]);
00313 newZoneID = mesh.faceZones().whichZone(mf[faceI]);
00314 }
00315 else if (!mesh.isInternalFace(ftc[faceI]))
00316 {
00317
00318 newOwner = slaveSideCell;
00319 newNeighbour = -1;
00320
00321
00322 if (own[mf[faceI]] == slaveSideCell)
00323 {
00324 flipFace = false;
00325 }
00326 else
00327 {
00328 flipFace = true;
00329 }
00330
00331 newPatchID = mesh.boundaryMesh().whichPatch(ftc[faceI]);
00332
00333
00334 newZoneID = mesh.faceZones().whichZone(mf[faceI]);
00335 }
00336 else
00337 {
00338
00339
00340 newOwner = min(masterSideCell, slaveSideCell);
00341 newNeighbour = max(masterSideCell, slaveSideCell);
00342
00343 if (newOwner == own[mf[faceI]] || newNeighbour == nei[mf[faceI]])
00344 {
00345 flipFace = false;
00346 }
00347 else
00348 {
00349 flipFace = true;
00350 }
00351
00352 newPatchID = -1;
00353
00354
00355 newZoneID = mesh.faceZones().whichZone(mf[faceI]);
00356 }
00357
00358
00359 face newFace = faces[mf[faceI]];
00360 bool zoneFlip = mfFlip[faceI];
00361
00362 if (flipFace)
00363 {
00364 newFace = newFace.reverseFace();
00365 zoneFlip = !zoneFlip;
00366 }
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378 ref.setAction
00379 (
00380 polyModifyFace
00381 (
00382 newFace,
00383 mf[faceI],
00384 newOwner,
00385 newNeighbour,
00386 flipFace,
00387 newPatchID,
00388 false,
00389 newZoneID,
00390 zoneFlip
00391 )
00392 );
00393 }
00394 }
00395
00396
00397
Copyright © 2000-2009 OpenCFD Ltd