63 regionsToCell::typeName,
64 "\n Usage: regionsToCell subCellSet (pt0 .. ptn) nErode\n\n"
65 " Select all cells in the connected region containing"
66 " points (pt0..ptn).\n"
72 void Foam::regionsToCell::markRegionFaces
81 forAll(faceNeighbour, faceI)
85 selectedCell[faceOwner[faceI]]
86 != selectedCell[faceNeighbour[faceI]]
89 regionFace[faceI] =
true;
101 const polyPatch& pp = pbm[patchI];
105 label faceI = pp.start()+i;
109 selectedCell[faceCells[i]]
110 != selectedCell[nbrSelected[bFaceI]]
113 regionFace[faceI] =
true;
124 const regionSplit& cellRegion
127 boolList keepRegion(cellRegion.nRegions(),
false);
129 for (
const point& insidePt : insidePoints_)
135 forAll(selectedCell, index)
148 label keepRegionI = -1;
149 label keepProcI = -1;
152 keepRegionI = cellRegion[cellI];
155 reduce(keepRegionI, maxOp<label>());
156 keepRegion[keepRegionI] =
true;
158 reduce(keepProcI, maxOp<label>());
163 <<
"Did not find " << insidePt
164 <<
" in mesh." <<
" Mesh bounds are " << mesh_.bounds()
170 Info<<
" Found location " << insidePt
171 <<
" in cell " << cellI <<
" on processor " << keepProcI
172 <<
" in global region " << keepRegionI
173 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
181 void Foam::regionsToCell::unselectOutsideRegions
187 boolList blockedFace(mesh_.nFaces(),
false);
188 markRegionFaces(selectedCell, blockedFace);
191 regionSplit cellRegion(mesh_, blockedFace);
194 boolList keepRegion(findRegions(verbose_, selectedCell, cellRegion));
199 if (!keepRegion[cellRegion[cellI]])
201 selectedCell[cellI] =
false;
207 void Foam::regionsToCell::shrinkRegions
215 boolList boundaryPoint(mesh_.nPoints(),
false);
217 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
219 for (
const polyPatch& pp : pbm)
221 if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
225 const face&
f = pp[i];
228 boundaryPoint[
f[fp]] =
true;
234 forAll(selectedCell, cellI)
236 if (!selectedCell[cellI])
238 const labelList& cPoints = mesh_.cellPoints(cellI);
241 boundaryPoint[cPoints[i]] =
true;
253 forAll(boundaryPoint, pointI)
255 if (boundaryPoint[pointI])
257 const labelList& pCells = mesh_.pointCells(pointI);
260 label cellI = pCells[i];
261 if (selectedCell[cellI])
263 selectedCell[cellI] =
false;
270 <<
" cells." <<
endl;
274 void Foam::regionsToCell::erode
283 boolList shrunkSelectedCell(selectedCell);
285 for (label iter = 0; iter < nErode_; iter++)
287 shrinkRegions(shrunkSelectedCell);
296 boolList blockedFace(mesh_.nFaces(),
false);
297 markRegionFaces(shrunkSelectedCell, blockedFace);
300 regionSplit cellRegion(mesh_, blockedFace);
303 boolList keepRegion(findRegions(verbose_, shrunkSelectedCell, cellRegion));
307 boolList removeCell(mesh_.nCells(),
false);
310 if (shrunkSelectedCell[cellI] && !keepRegion[cellRegion[cellI]])
312 removeCell[cellI] =
true;
322 for (label iter = 0; iter < nErode_; iter++)
325 boolList boundaryPoint(mesh_.nPoints(),
false);
328 if (removeCell[cellI])
330 const labelList& cPoints = mesh_.cellPoints(cellI);
333 boundaryPoint[cPoints[i]] =
true;
342 forAll(boundaryPoint, pointI)
344 if (boundaryPoint[pointI])
346 const labelList& pCells = mesh_.pointCells(pointI);
349 label cellI = pCells[i];
350 if (!removeCell[cellI])
352 removeCell[cellI] =
true;
367 if (removeCell[cellI])
369 selectedCell[cellI] =
false;
375 void Foam::regionsToCell::combine(topoSet&
set,
const bool add)
const
378 boolList selectedCell(mesh_.nCells(),
true);
380 if (setName_.size() && setName_ !=
"none")
382 Info<<
" Loading subset " << setName_ <<
" to delimit search region."
384 cellSet subSet(mesh_, setName_);
386 selectedCell =
false;
387 for (
const label celli :
static_cast<const labelHashSet&
>(subSet))
389 selectedCell[celli] =
true;
394 unselectOutsideRegions(selectedCell);
402 forAll(selectedCell, cellI)
404 if (selectedCell[cellI])
406 addOrDelete(
set, cellI,
add);
454 setName_(checkIs(is)),
455 insidePoints_(checkIs(is)),
472 Info<<
" Adding all cells of connected region "
473 <<
"containing points "
474 << insidePoints_ <<
" ..." <<
endl;
483 Info<<
" Removing all cells of connected region "
484 <<
"containing points "
485 << insidePoints_ <<
" ..." <<
endl;