50 regionToCell::typeName,
51 "\n Usage: regionToCell subCellSet (pt0 .. ptn) nErode\n\n"
52 " Select all cells in the connected region containing"
53 " points (pt0..ptn).\n"
59 void Foam::regionToCell::markRegionFaces
68 forAll(faceNeighbour, facei)
72 selectedCell[faceOwner[facei]]
73 != selectedCell[faceNeighbour[facei]]
76 regionFace[facei] =
true;
88 const polyPatch& pp = pbm[patchi];
92 label facei = pp.start()+i;
94 if (selectedCell[faceCells[i]] != nbrSelected[bFacei])
96 regionFace[facei] =
true;
106 const regionSplit& cellRegion
109 boolList keepRegion(cellRegion.nRegions(),
false);
115 label celli = mesh_.findCell(insidePoints_[i]);
117 label keepRegionI = -1;
118 label keepProci = -1;
121 keepRegionI = cellRegion[celli];
124 reduce(keepRegionI, maxOp<label>());
125 keepRegion[keepRegionI] =
true;
127 reduce(keepProci, maxOp<label>());
132 <<
"Did not find " << insidePoints_[i]
133 <<
" in mesh." <<
" Mesh bounds are " << mesh_.bounds()
139 Info<<
" Found location " << insidePoints_[i]
140 <<
" in cell " << celli <<
" on processor " << keepProci
141 <<
" in global region " << keepRegionI
142 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
150 void Foam::regionToCell::unselectOutsideRegions
156 boolList blockedFace(mesh_.nFaces(),
false);
157 markRegionFaces(selectedCell, blockedFace);
160 regionSplit cellRegion(mesh_, blockedFace);
163 boolList keepRegion(findRegions(verbose_, cellRegion));
168 if (!keepRegion[cellRegion[celli]])
170 selectedCell[celli] =
false;
176 void Foam::regionToCell::shrinkRegions
184 boolList boundaryPoint(mesh_.nPoints(),
false);
186 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
190 const polyPatch& pp = pbm[patchi];
192 if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
196 const face&
f = pp[i];
199 boundaryPoint[
f[fp]] =
true;
205 forAll(selectedCell, celli)
207 if (!selectedCell[celli])
209 const labelList& cPoints = mesh_.cellPoints(celli);
212 boundaryPoint[cPoints[i]] =
true;
224 forAll(boundaryPoint, pointi)
226 if (boundaryPoint[pointi])
228 const labelList& pCells = mesh_.pointCells(pointi);
231 label celli = pCells[i];
232 if (selectedCell[celli])
234 selectedCell[celli] =
false;
242 <<
" cells." <<
endl;
246 void Foam::regionToCell::erode
255 boolList shrunkSelectedCell(selectedCell);
257 for (label iter = 0; iter < nErode_; iter++)
259 shrinkRegions(shrunkSelectedCell);
267 boolList blockedFace(mesh_.nFaces(),
false);
268 markRegionFaces(shrunkSelectedCell, blockedFace);
271 regionSplit cellRegion(mesh_, blockedFace);
274 boolList keepRegion(findRegions(verbose_, cellRegion));
278 boolList removeCell(mesh_.nCells(),
false);
281 if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
283 removeCell[celli] =
true;
292 for (label iter = 0; iter < nErode_; iter++)
295 boolList boundaryPoint(mesh_.nPoints(),
false);
298 if (removeCell[celli])
300 const labelList& cPoints = mesh_.cellPoints(celli);
303 boundaryPoint[cPoints[i]] =
true;
312 forAll(boundaryPoint, pointi)
314 if (boundaryPoint[pointi])
316 const labelList& pCells = mesh_.pointCells(pointi);
319 label celli = pCells[i];
320 if (!removeCell[celli])
322 removeCell[celli] =
true;
337 if (removeCell[celli])
339 selectedCell[celli] =
false;
345 void Foam::regionToCell::combine(topoSet&
set,
const bool add)
const
348 boolList selectedCell(mesh_.nCells(),
true);
350 if (setName_.size() && setName_ !=
"none")
352 Info<<
" Loading subset " << setName_
353 <<
" to delimit search region."
356 cellSet subSet(mesh_, setName_);
358 selectedCell =
false;
359 for (
const label celli : subSet)
361 selectedCell[celli] =
true;
366 unselectOutsideRegions(selectedCell);
374 forAll(selectedCell, celli)
376 if (selectedCell[celli])
378 addOrDelete(
set, celli,
add);
388 const polyMesh&
mesh,
394 topoSetCellSource(
mesh),
396 insidePoints_(insidePoints),
408 setName_(
dict.getOrDefault<
word>(
"set",
"none")),
419 const polyMesh&
mesh,
423 topoSetCellSource(
mesh),
424 setName_(checkIs(is)),
425 insidePoints_(checkIs(is)),
442 Info<<
" Adding all cells of connected region "
443 <<
"containing points "
444 << insidePoints_ <<
" ..." <<
endl;
453 Info<<
" Removing all cells of connected region "
454 <<
"containing points "
455 << insidePoints_ <<
" ..." <<
endl;