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"
72void Foam::regionsToCell::markRegionFaces
74 const boolList& selectedCell,
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;
181void 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;
207void 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;
274void 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;
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);
436 setName_(
dict.getOrDefault<
word>(
"set",
"none")),
443 nErode_(
dict.getOrDefault<label>(
"nErode", 0))
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;
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
#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)....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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.
Lookup type of boundary radiation properties.
TopoSetSource. Select cells belonging to topological connected region (that contains given points)
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)
vector point
Point is a vector.
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.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
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.