OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

cellClassification.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "cellClassification.H"
00030 #include "triSurfaceSearch.H"
00031 #include "indexedOctree.H"
00032 #include "treeDataFace.H"
00033 #include "meshSearch.H"
00034 #include "cellInfo.H"
00035 #include "polyMesh.H"
00036 #include "MeshWave.H"
00037 #include "ListOps.H"
00038 #include "meshTools.H"
00039 
00040 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044     defineTypeNameAndDebug(cellClassification, 0);
00045 }
00046 
00047 
00048 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00049 
00050 Foam::label Foam::cellClassification::count
00051 (
00052     const labelList& elems,
00053     const label elem
00054 )
00055 {
00056     label cnt = 0;
00057 
00058     forAll(elems, elemI)
00059     {
00060         if (elems[elemI] == elem)
00061         {
00062             cnt++;
00063         }
00064     }
00065     return cnt;
00066 
00067 }
00068 
00069 
00070 // Mark all faces that are cut by the surface. Two pass:
00071 // Pass1: mark all mesh edges that intersect surface (quick since triangle
00072 // pierce test).
00073 // Pass2: Check for all point neighbours of these faces whether any of their
00074 // faces are pierced.
00075 Foam::boolList Foam::cellClassification::markFaces
00076 (
00077     const triSurfaceSearch& search
00078 ) const
00079 {
00080     cpuTime timer;
00081 
00082     boolList cutFace(mesh_.nFaces(), false);
00083 
00084     label nCutFaces = 0;
00085 
00086     // Intersect mesh edges with surface (is fast) and mark all faces that
00087     // use edge.
00088 
00089     forAll(mesh_.edges(), edgeI)
00090     {
00091         if (debug && (edgeI % 10000 == 0))
00092         {
00093             Pout<< "Intersecting mesh edge " << edgeI << " with surface"
00094                 << endl;
00095         }
00096 
00097         const edge& e = mesh_.edges()[edgeI];
00098 
00099         const point& p0 = mesh_.points()[e.start()];
00100         const point& p1 = mesh_.points()[e.end()];
00101 
00102         pointIndexHit pHit(search.tree().findLineAny(p0, p1));
00103 
00104         if (pHit.hit())
00105         {
00106             const labelList& myFaces = mesh_.edgeFaces()[edgeI];
00107 
00108             forAll(myFaces, myFaceI)
00109             {
00110                 label faceI = myFaces[myFaceI];
00111 
00112                 if (!cutFace[faceI])
00113                 {
00114                     cutFace[faceI] = true;
00115 
00116                     nCutFaces++;
00117                 }
00118             }
00119         }
00120     }
00121 
00122     if (debug)
00123     {
00124         Pout<< "Intersected edges of mesh with surface in = "
00125             << timer.cpuTimeIncrement() << " s\n" << endl << endl;
00126     }
00127 
00128     //
00129     // Construct octree on faces that have not yet been marked as cut
00130     //
00131 
00132     labelList allFaces(mesh_.nFaces() - nCutFaces);
00133 
00134     label allFaceI = 0;
00135 
00136     forAll(cutFace, faceI)
00137     {
00138         if (!cutFace[faceI])
00139         {
00140             allFaces[allFaceI++] = faceI;
00141         }
00142     }
00143 
00144     if (debug)
00145     {
00146         Pout<< "Testing " << allFaceI << " faces for piercing by surface"
00147             << endl;
00148     }
00149 
00150     treeBoundBox allBb(mesh_.points());
00151 
00152     // Extend domain slightly (also makes it 3D if was 2D)
00153     scalar tol = 1E-6 * allBb.avgDim();
00154 
00155     point& bbMin = allBb.min();
00156     bbMin.x() -= tol;
00157     bbMin.y() -= tol;
00158     bbMin.z() -= tol;
00159 
00160     point& bbMax = allBb.max();
00161     bbMax.x() += 2*tol;
00162     bbMax.y() += 2*tol;
00163     bbMax.z() += 2*tol;
00164 
00165     indexedOctree<treeDataFace> faceTree
00166     (
00167         treeDataFace(false, mesh_, allFaces),
00168         allBb,      // overall search domain
00169         8,          // maxLevel
00170         10,         // leafsize
00171         3.0         // duplicity
00172     );
00173 
00174     const triSurface& surf = search.surface();
00175     const edgeList& edges = surf.edges();
00176     const pointField& localPoints = surf.localPoints();
00177 
00178     label nAddFaces = 0;
00179 
00180     forAll(edges, edgeI)
00181     {
00182         if (debug && (edgeI % 10000 == 0))
00183         {
00184             Pout<< "Intersecting surface edge " << edgeI
00185                 << " with mesh faces" << endl;
00186         }
00187         const edge& e = edges[edgeI];
00188 
00189         const point& start = localPoints[e.start()];
00190         const point& end = localPoints[e.end()];
00191 
00192         vector edgeNormal(end - start);
00193         const scalar edgeMag = mag(edgeNormal);
00194         const vector smallVec = 1E-9*edgeNormal;
00195 
00196         edgeNormal /= edgeMag+VSMALL;
00197 
00198         // Current start of pierce test
00199         point pt = start;
00200 
00201         while (true)
00202         {
00203             pointIndexHit pHit(faceTree.findLine(pt, end));
00204 
00205             if (!pHit.hit())
00206             {
00207                 break;
00208             }
00209             else
00210             {
00211                 label faceI = faceTree.shapes().faceLabels()[pHit.index()];
00212 
00213                 if (!cutFace[faceI])
00214                 {
00215                     cutFace[faceI] = true;
00216 
00217                     nAddFaces++;
00218                 }
00219 
00220                 // Restart from previous endpoint
00221                 pt = pHit.hitPoint() + smallVec;
00222 
00223                 if (((pt-start) & edgeNormal) >= edgeMag)
00224                 {
00225                     break;
00226                 }
00227             }
00228         }
00229     }
00230 
00231     if (debug)
00232     {
00233         Pout<< "Detected an additional " << nAddFaces << " faces cut"
00234             << endl;
00235 
00236         Pout<< "Intersected edges of surface with mesh faces in = "
00237             << timer.cpuTimeIncrement() << " s\n" << endl << endl;
00238     }
00239 
00240     return cutFace;
00241 }
00242 
00243 
00244 // Determine faces cut by surface and use to divide cells into types. See
00245 // cellInfo. All cells reachable from outsidePts are considered to be of type
00246 // 'outside'
00247 void Foam::cellClassification::markCells
00248 (
00249     const meshSearch& queryMesh,
00250     const boolList& piercedFace,
00251     const pointField& outsidePts
00252 )
00253 {
00254     // Use meshwave to partition mesh, starting from outsidePt
00255 
00256 
00257     // Construct null; sets type to NOTSET
00258     List<cellInfo> cellInfoList(mesh_.nCells());
00259 
00260     // Mark cut cells first
00261     forAll(piercedFace, faceI)
00262     {
00263         if (piercedFace[faceI])
00264         {
00265             cellInfoList[mesh_.faceOwner()[faceI]] =
00266                 cellInfo(cellClassification::CUT);
00267 
00268             if (mesh_.isInternalFace(faceI))
00269             {
00270                 cellInfoList[mesh_.faceNeighbour()[faceI]] =
00271                     cellInfo(cellClassification::CUT);
00272             }
00273         }
00274     }
00275 
00276     //
00277     // Mark cells containing outside points as being outside
00278     //
00279 
00280     // Coarse guess number of faces
00281     labelHashSet outsideFacesMap(outsidePts.size() * 6 * 2);
00282 
00283     forAll(outsidePts, outsidePtI)
00284     {
00285         // Use linear search for points.
00286         label cellI = queryMesh.findCell(outsidePts[outsidePtI], -1, false);
00287 
00288         if (cellI == -1)
00289         {
00290             FatalErrorIn
00291             (
00292                 "List<cellClassification::cType> markCells"
00293                 "(const meshSearch&, const boolList&, const pointField&)"
00294             )   << "outsidePoint " << outsidePts[outsidePtI]
00295                 << " is not inside any cell"
00296                 << nl << "It might be on a face or outside the geometry"
00297                 << exit(FatalError);
00298         }
00299 
00300         cellInfoList[cellI] = cellInfo(cellClassification::OUTSIDE);
00301 
00302         // Mark faces of cellI
00303         const labelList& myFaces = mesh_.cells()[cellI];
00304         forAll(myFaces, myFaceI)
00305         {
00306             outsideFacesMap.insert(myFaces[myFaceI]);
00307         }
00308     }
00309 
00310 
00311     //
00312     // Mark faces to start wave from
00313     //
00314 
00315     labelList changedFaces(outsideFacesMap.toc());
00316 
00317     List<cellInfo> changedFacesInfo
00318     (
00319         changedFaces.size(),
00320         cellInfo(cellClassification::OUTSIDE)
00321     );
00322 
00323     MeshWave<cellInfo> cellInfoCalc
00324     (
00325         mesh_,
00326         changedFaces,                       // Labels of changed faces
00327         changedFacesInfo,                   // Information on changed faces
00328         cellInfoList,                       // Information on all cells
00329         mesh_.globalData().nTotalCells()    // max iterations
00330     );
00331 
00332     // Get information out of cellInfoList
00333     const List<cellInfo>& allInfo = cellInfoCalc.allCellInfo();
00334 
00335     forAll(allInfo, cellI)
00336     {
00337         label t = allInfo[cellI].type();
00338 
00339         if (t == cellClassification::NOTSET)
00340         {
00341             t = cellClassification::INSIDE;
00342         }
00343         operator[](cellI) = t;
00344     }
00345 }
00346 
00347 
00348 void Foam::cellClassification::classifyPoints
00349 (
00350     const label meshType,
00351     const labelList& cellType,
00352     List<pointStatus>& pointSide
00353 ) const
00354 {
00355     pointSide.setSize(mesh_.nPoints());
00356 
00357     forAll(mesh_.pointCells(), pointI)
00358     {
00359         const labelList& pCells = mesh_.pointCells()[pointI];
00360 
00361         pointSide[pointI] = UNSET;
00362 
00363         forAll(pCells, i)
00364         {
00365             label type = cellType[pCells[i]];
00366 
00367             if (type == meshType)
00368             {
00369                 if (pointSide[pointI] == UNSET)
00370                 {
00371                     pointSide[pointI] = MESH;
00372                 }
00373                 else if (pointSide[pointI] == NONMESH)
00374                 {
00375                     pointSide[pointI] = MIXED;
00376 
00377                     break;
00378                 }
00379             }
00380             else
00381             {
00382                 if (pointSide[pointI] == UNSET)
00383                 {
00384                     pointSide[pointI] = NONMESH;
00385                 }
00386                 else if (pointSide[pointI] == MESH)
00387                 {
00388                     pointSide[pointI] = MIXED;
00389 
00390                     break;
00391                 }
00392             }
00393         }
00394     }
00395 }
00396 
00397 
00398 bool Foam::cellClassification::usesMixedPointsOnly
00399 (
00400     const List<pointStatus>& pointSide,
00401     const label cellI
00402 ) const
00403 {
00404     const faceList& faces = mesh_.faces();
00405 
00406     const cell& cFaces = mesh_.cells()[cellI];
00407 
00408     forAll(cFaces, cFaceI)
00409     {
00410         const face& f = faces[cFaces[cFaceI]];
00411 
00412         forAll(f, fp)
00413         {
00414             if (pointSide[f[fp]] != MIXED)
00415             {
00416                 return false;
00417             }
00418         }
00419     }
00420 
00421     // All points are mixed.
00422     return true;
00423 }
00424 
00425 
00426 void Foam::cellClassification::getMeshOutside
00427 (
00428     const label meshType,
00429     faceList& outsideFaces,
00430     labelList& outsideOwner
00431 ) const
00432 {
00433     const labelList& own = mesh_.faceOwner();
00434     const labelList& nbr = mesh_.faceNeighbour();
00435     const faceList& faces = mesh_.faces();
00436 
00437     outsideFaces.setSize(mesh_.nFaces());
00438     outsideOwner.setSize(mesh_.nFaces());
00439     label outsideI = 0;
00440 
00441     // Get faces on interface between meshType and non-meshType
00442 
00443     for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
00444     {
00445         label ownType = operator[](own[faceI]);
00446         label nbrType = operator[](nbr[faceI]);
00447 
00448         if (ownType == meshType && nbrType != meshType)
00449         {
00450             outsideFaces[outsideI] = faces[faceI];
00451             outsideOwner[outsideI] = own[faceI];    // meshType cell
00452             outsideI++;
00453         }
00454         else if (ownType != meshType && nbrType == meshType)
00455         {
00456             outsideFaces[outsideI] = faces[faceI];
00457             outsideOwner[outsideI] = nbr[faceI];    // meshType cell
00458             outsideI++;
00459         }
00460     }
00461 
00462     // Get faces on outside of real mesh with cells of meshType.
00463 
00464     for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
00465     {
00466         if (operator[](own[faceI]) == meshType)
00467         {
00468             outsideFaces[outsideI] = faces[faceI];
00469             outsideOwner[outsideI] = own[faceI];    // meshType cell
00470             outsideI++;
00471         }
00472     }
00473     outsideFaces.setSize(outsideI);
00474     outsideOwner.setSize(outsideI);
00475 }
00476 
00477 
00478 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00479 
00480 // Construct from mesh and surface and point(s) on outside
00481 Foam::cellClassification::cellClassification
00482 (
00483     const polyMesh& mesh,
00484     const meshSearch& meshQuery,
00485     const triSurfaceSearch& surfQuery,
00486     const pointField& outsidePoints
00487 )
00488 :
00489     labelList(mesh.nCells(), cellClassification::NOTSET),
00490     mesh_(mesh)
00491 {
00492     markCells
00493     (
00494         meshQuery,
00495         markFaces(surfQuery),
00496         outsidePoints
00497     );
00498 }
00499 
00500 
00501 // Construct from mesh and meshType.
00502 Foam::cellClassification::cellClassification
00503 (
00504     const polyMesh& mesh,
00505     const labelList& cellType
00506 )
00507 :
00508     labelList(cellType),
00509     mesh_(mesh)
00510 {
00511     if (mesh_.nCells() != size())
00512     {
00513         FatalErrorIn
00514         (
00515             "cellClassification::cellClassification"
00516             "(const polyMesh&, const labelList&)"
00517         )   << "Number of elements of cellType argument is not equal to the"
00518             << " number of cells" << abort(FatalError);
00519     }
00520 }
00521 
00522 
00523 // Construct as copy
00524 Foam::cellClassification::cellClassification(const cellClassification& cType)
00525 :
00526     labelList(cType),
00527     mesh_(cType.mesh())
00528 {}
00529 
00530 
00531 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00532 
00533 
00534 // Makes cutCells further than nLayers away from meshType to
00535 // fillType. Returns number of cells changed.
00536 Foam::label Foam::cellClassification::trimCutCells
00537 (
00538     const label nLayers,
00539     const label meshType,
00540     const label fillType
00541 )
00542 {
00543     // Temporary cell type for growing.
00544     labelList newCellType(*this);
00545 
00546 //    // Split types into outside and rest
00547 //    forAll(*this, cellI)
00548 //    {
00549 //        label type = operator[](cellI);
00550 //
00551 //        if (type == meshType)
00552 //        {
00553 //            newCellType[cellI] = type;
00554 //        }
00555 //        else
00556 //        {
00557 //            newCellType[cellI] = fillType;
00558 //        }
00559 //    }
00560 
00561     newCellType = *this;
00562 
00563 
00564     // Do point-cell-point walk on newCellType out from meshType cells
00565     for (label iter = 0; iter < nLayers; iter++)
00566     {
00567         // Get status of points: visible from meshType (pointSide == MESH)
00568         // or fillType/cutCells cells (pointSide == NONMESH) or
00569         // both (pointSide == MIXED)
00570         List<pointStatus> pointSide(mesh_.nPoints());
00571         classifyPoints(meshType, newCellType, pointSide);
00572 
00573         // Grow layer of outside cells
00574         forAll(pointSide, pointI)
00575         {
00576             if (pointSide[pointI] == MIXED)
00577             {
00578                 // Make cut
00579                 const labelList& pCells = mesh_.pointCells()[pointI];
00580 
00581                 forAll(pCells, i)
00582                 {
00583                     label type = newCellType[pCells[i]];
00584 
00585                     if (type == cellClassification::CUT)
00586                     {
00587                         // Found cut cell sharing point with
00588                         // mesh type cell. Grow.
00589                         newCellType[pCells[i]] = meshType;
00590                     }
00591                 }
00592             }
00593         }
00594     }
00595 
00596     // Merge newCellType into *this:
00597     // - leave meshType cells intact
00598     // - leave nonMesh cells intact
00599     // - make cutcells fillType if they were not marked in newCellType
00600 
00601     label nChanged = 0;
00602 
00603     forAll(newCellType, cellI)
00604     {
00605         if (operator[](cellI) == cellClassification::CUT)
00606         {
00607             if (newCellType[cellI] != meshType)
00608             {
00609                 // Cell was cutCell but further than nLayers away from
00610                 // meshType. Convert to fillType.
00611                 operator[](cellI) = fillType;
00612                 nChanged++;
00613             }
00614         }
00615     }
00616 
00617     return nChanged;
00618 }
00619 
00620 
00621 // Grow surface by pointNeighbours of type meshType
00622 Foam::label Foam::cellClassification::growSurface
00623 (
00624     const label meshType,
00625     const label fillType
00626 )
00627 {
00628     boolList hasMeshType(mesh_.nPoints(), false);
00629 
00630     // Mark points used by meshType cells
00631 
00632     forAll(mesh_.pointCells(), pointI)
00633     {
00634         const labelList& myCells = mesh_.pointCells()[pointI];
00635 
00636         // Check if one of cells has meshType
00637         forAll(myCells, myCellI)
00638         {
00639             label type = operator[](myCells[myCellI]);
00640 
00641             if (type == meshType)
00642             {
00643                 hasMeshType[pointI] = true;
00644 
00645                 break;
00646             }
00647         }
00648     }
00649 
00650     // Change neighbours of marked points
00651 
00652     label nChanged = 0;
00653 
00654     forAll(hasMeshType, pointI)
00655     {
00656         if (hasMeshType[pointI])
00657         {
00658             const labelList& myCells = mesh_.pointCells()[pointI];
00659 
00660             forAll(myCells, myCellI)
00661             {
00662                 if (operator[](myCells[myCellI]) != meshType)
00663                 {
00664                     operator[](myCells[myCellI]) = fillType;
00665 
00666                     nChanged++;
00667                 }
00668             }
00669         }
00670     }
00671     return nChanged;
00672 }
00673 
00674 
00675 // Check all points used by cells of meshType for use of at least one point
00676 // which is not on the outside. If all points are on the outside of the mesh
00677 // this would probably result in a flattened cell when projecting the cell
00678 // onto the surface.
00679 Foam::label Foam::cellClassification::fillHangingCells
00680 (
00681     const label meshType,
00682     const label fillType,
00683     const label maxIter
00684 )
00685 {
00686     label nTotChanged = 0;
00687 
00688     for(label iter = 0; iter < maxIter; iter++)
00689     {
00690         label nChanged = 0;
00691 
00692         // Get status of points: visible from meshType or non-meshType cells
00693         List<pointStatus> pointSide(mesh_.nPoints());
00694         classifyPoints(meshType, *this, pointSide);
00695 
00696         // Check all cells using mixed point type for whether they use mixed
00697         // points only. Note: could probably speed this up by counting number
00698         // of mixed verts per face and mixed faces per cell or something?
00699         forAll(pointSide, pointI)
00700         {
00701             if (pointSide[pointI] == MIXED)
00702             {
00703                 const labelList& pCells = mesh_.pointCells()[pointI];
00704 
00705                 forAll(pCells, i)
00706                 {
00707                     label cellI = pCells[i];
00708 
00709                     if (operator[](cellI) == meshType)
00710                     {
00711                         if (usesMixedPointsOnly(pointSide, cellI))
00712                         {
00713                             operator[](cellI) = fillType;
00714 
00715                             nChanged++;
00716                         }
00717                     }
00718                 }
00719             }
00720         }
00721         nTotChanged += nChanged;
00722 
00723         Pout<< "removeHangingCells : changed " << nChanged
00724             << " hanging cells" << endl;
00725 
00726         if (nChanged == 0)
00727         {
00728             break;
00729         }
00730     }
00731 
00732     return nTotChanged;
00733 }
00734 
00735 
00736 Foam::label Foam::cellClassification::fillRegionEdges
00737 (
00738     const label meshType,
00739     const label fillType,
00740     const label maxIter
00741 )
00742 {
00743     label nTotChanged = 0;
00744 
00745     for(label iter = 0; iter < maxIter; iter++)
00746     {
00747         // Get interface between meshType cells and non-meshType cells as a list
00748         // of faces and for each face the cell which is the meshType.
00749         faceList outsideFaces;
00750         labelList outsideOwner;
00751 
00752         getMeshOutside(meshType, outsideFaces, outsideOwner);
00753 
00754         // Build primitivePatch out of it and check it for problems.
00755         primitiveFacePatch fp(outsideFaces, mesh_.points());
00756 
00757         const labelListList& edgeFaces = fp.edgeFaces();
00758 
00759         label nChanged = 0;
00760 
00761         // Check all edgeFaces for non-manifoldness
00762 
00763         forAll(edgeFaces, edgeI)
00764         {
00765             const labelList& eFaces = edgeFaces[edgeI];
00766 
00767             if (eFaces.size() > 2)
00768             {
00769                 // patch connected through pinched edge. Remove first face using
00770                 // edge (and not yet changed)
00771 
00772                 forAll(eFaces, i)
00773                 {
00774                     label patchFaceI = eFaces[i];
00775 
00776                     label ownerCell = outsideOwner[patchFaceI];
00777 
00778                     if (operator[](ownerCell) == meshType)
00779                     {
00780                         operator[](ownerCell) = fillType;
00781 
00782                         nChanged++;
00783 
00784                         break;
00785                     }
00786                 }
00787             }
00788         }
00789 
00790         nTotChanged += nChanged;
00791 
00792         Pout<< "fillRegionEdges : changed " << nChanged
00793             << " cells using multiply connected edges" << endl;
00794 
00795         if (nChanged == 0)
00796         {
00797             break;
00798         }
00799     }
00800 
00801     return nTotChanged;
00802 }
00803 
00804 
00805 Foam::label Foam::cellClassification::fillRegionPoints
00806 (
00807     const label meshType,
00808     const label fillType,
00809     const label maxIter
00810 )
00811 {
00812     label nTotChanged = 0;
00813 
00814     for(label iter = 0; iter < maxIter; iter++)
00815     {
00816         // Get interface between meshType cells and non-meshType cells as a list
00817         // of faces and for each face the cell which is the meshType.
00818         faceList outsideFaces;
00819         labelList outsideOwner;
00820 
00821         getMeshOutside(meshType, outsideFaces, outsideOwner);
00822 
00823         // Build primitivePatch out of it and check it for problems.
00824         primitiveFacePatch fp(outsideFaces, mesh_.points());
00825 
00826         labelHashSet nonManifoldPoints;
00827 
00828         // Check for non-manifold points.
00829         fp.checkPointManifold(false, &nonManifoldPoints);
00830 
00831         const Map<label>& meshPointMap = fp.meshPointMap();
00832 
00833         label nChanged = 0;
00834 
00835         for
00836         (
00837             labelHashSet::const_iterator iter = nonManifoldPoints.begin();
00838             iter != nonManifoldPoints.end();
00839             ++iter
00840         )
00841         {
00842             // Find a face on fp using point and remove it.
00843             label patchPointI = meshPointMap[iter.key()];
00844 
00845             const labelList& pFaces = fp.pointFaces()[patchPointI];
00846 
00847             // Remove any face using conflicting point. Does first face which
00848             // has not yet been done. Could be more intelligent and decide which
00849             // one would be best to remove.
00850             forAll(pFaces, i)
00851             {
00852                 label patchFaceI = pFaces[i];
00853 
00854                 label ownerCell = outsideOwner[patchFaceI];
00855 
00856                 if (operator[](ownerCell) == meshType)
00857                 {
00858                     operator[](ownerCell) = fillType;
00859 
00860                     nChanged++;
00861 
00862                     break;
00863                 }
00864             }
00865         }
00866 
00867         nTotChanged += nChanged;
00868 
00869         Pout<< "fillRegionPoints : changed " << nChanged
00870             << " cells using multiply connected points" << endl;
00871 
00872         if (nChanged == 0)
00873         {
00874             break;
00875         }
00876     }
00877 
00878     return nTotChanged;
00879 }
00880 
00881 
00882 void Foam::cellClassification::writeStats(Ostream& os) const
00883 {
00884     os  << "Cells:" << size() << endl
00885         << "    notset  : " << count(*this, NOTSET) << endl
00886         << "    cut     : " << count(*this, CUT) << endl
00887         << "    inside  : " << count(*this, INSIDE) << endl
00888         << "    outside : " << count(*this, OUTSIDE) << endl;
00889 }
00890 
00891 
00892 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00893 
00894 void Foam::cellClassification::operator=(const Foam::cellClassification& rhs)
00895 {
00896     labelList::operator=(rhs);
00897 }
00898 
00899 
00900 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd