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"
59void Foam::regionToCell::markRegionFaces
61 const boolList& selectedCell,
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;
150void 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;
176void 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;
246void 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;
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);
408 setName_(
dict.getOrDefault<
word>(
"set",
"none")),
411 dict.getCompat<
pointField>(
"insidePoints", {{
"insidePoint", 0 }})
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;
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
static MinMax< T > ge(const T &minVal)
A semi-infinite range from minVal to the type max.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getCheckOrDefault(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
label nInternalFaces() const noexcept
Number of internal faces.
int myProcNo() const noexcept
Return processor number.
A topoSetCellSource to select cells belonging to a topologically connected region (that contains give...
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
Class with constructor to add usage string to table.
Base class of a source for a topoSet.
setAction
Enumeration defining various actions.
@ SUBTRACT
Subtract elements from current set.
@ ADD
Add elements to current set.
@ NEW
Create a new set and ADD elements to it.
const polyMesh & mesh_
Reference to the mesh.
General set of labels of mesh quantity (points, cells, faces).
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< label > labelList
A List of labels.
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
List< bool > boolList
A List of bools.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
#define forAll(list, i)
Loop across all elements in list.