diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 00720d2382..57514a2053 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -167,8 +167,10 @@ FoamFile // source regionToCell; // sourceInfo // { -// set c0; // name of cellSet giving mesh subset -// insidePoint (1 2 3); // point inside region to select +// set c0; // optional name of cellSet giving mesh subset +// insidePoints ((1 2 3)); // points inside region to select +// nErode 0; // optional number of layers to erode +// // selection // } // // // Cells underneath plane such that volume is reached. E.g. for use diff --git a/src/meshTools/sets/cellSources/regionToCell/regionToCell.C b/src/meshTools/sets/cellSources/regionToCell/regionToCell.C index 77948ca5a5..57c7b79af5 100644 --- a/src/meshTools/sets/cellSources/regionToCell/regionToCell.C +++ b/src/meshTools/sets/cellSources/regionToCell/regionToCell.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,12 +24,10 @@ License \*---------------------------------------------------------------------------*/ #include "regionToCell.H" -#include "polyMesh.H" #include "regionSplit.H" -#include "globalMeshData.H" +#include "emptyPolyPatch.H" #include "cellSet.H" #include "syncTools.H" - #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -49,104 +47,339 @@ addToRunTimeSelectionTable(topoSetSource, regionToCell, istream); Foam::topoSetSource::addToUsageTable Foam::regionToCell::usage_ ( regionToCell::typeName, - "\n Usage: regionToCell subCellSet (x y z)\n\n" - " Select all cells in the connected region containing point.\n" - " If started inside the subCellSet keeps to it;\n" - " if started outside stays outside.\n" + "\n Usage: regionToCell subCellSet (pt0 .. ptn)\n\n" + " Select all cells in the connected region containing" + " points (pt0..ptn).\n" ); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::regionToCell::markRegionFaces +( + const boolList& selectedCell, + boolList& regionFace +) const +{ + // Internal faces + const labelList& faceOwner = mesh_.faceOwner(); + const labelList& faceNeighbour = mesh_.faceNeighbour(); + forAll(faceNeighbour, faceI) + { + if + ( + selectedCell[faceOwner[faceI]] + != selectedCell[faceNeighbour[faceI]] + ) + { + regionFace[faceI] = true; + } + } + + // Swap neighbour selectedCell state + boolList nbrSelected; + syncTools::swapBoundaryCellList(mesh_, selectedCell, nbrSelected); + + // Boundary faces + const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); + forAll(pbm, patchI) + { + const polyPatch& pp = pbm[patchI]; + const labelUList& faceCells = pp.faceCells(); + forAll(faceCells, i) + { + label faceI = pp.start()+i; + label bFaceI = faceI-mesh_.nInternalFaces(); + if + ( + selectedCell[faceCells[i]] + != selectedCell[nbrSelected[bFaceI]] + ) + { + regionFace[faceI] = true; + } + } + } +} + + +Foam::boolList Foam::regionToCell::findRegions +( + const bool verbose, + const regionSplit& cellRegion +) const +{ + boolList keepRegion(cellRegion.nRegions(), false); + + forAll(insidePoints_, i) + { + // Find the region containing the insidePoint + + label cellI = mesh_.findCell(insidePoints_[i]); + + label keepRegionI = -1; + label keepProcI = -1; + if (cellI != -1) + { + keepRegionI = cellRegion[cellI]; + keepProcI = Pstream::myProcNo(); + } + reduce(keepRegionI, maxOp