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;
98 const polyBoundaryMesh&
pbm =
mesh_.boundaryMesh();
101 const polyPatch&
pp =
pbm[patchI];
105 label faceI =
pp.start()+i;
106 label bFaceI = faceI-
mesh_.nInternalFaces();
109 selectedCell[faceCells[i]]
110 != selectedCell[nbrSelected[bFaceI]]
113 regionFace[faceI] =
true;
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];
156 keepRegion[keepRegionI] =
true;
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);
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);
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;
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);
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;
375void Foam::regionsToCell::combine(
topoSet& set,
const bool add)
const
378 boolList selectedCell(mesh_.nCells(),
true);
380 if (!setName_.empty() && setName_ !=
"none")
382 Info<<
" Loading subset " << setName_
383 <<
" to delimit search region." <<
nl;
388 selectedCell =
false;
389 for (
const label celli : cellLabels)
391 selectedCell[celli] =
true;
396 unselectOutsideRegions(selectedCell);
404 forAll(selectedCell, cellI)
406 if (selectedCell[cellI])
408 addOrDelete(set, cellI,
add);
438 setName_(
dict.getOrDefault<
word>(
"set",
"none")),
445 nErode_(
dict.getOrDefault<label>(
"nErode", 0))
456 setName_(checkIs(is)),
474 Info<<
" Adding all cells of connected region "
475 <<
"containing points "
476 << insidePoints_ <<
" ..." <<
endl;
485 Info<<
" Removing all cells of connected region "
486 <<
"containing points "
487 << 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.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
@ NO_REGISTER
Do not request registration (bool: false).
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
A collection of cell labels.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A face is a list of labels corresponding to mesh vertices.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A patch is a list of labels that address the faces in the global face list.
Lookup type of boundary radiation properties.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
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.
regionsToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
topoSetCellSource(const polyMesh &mesh)
Construct from mesh.
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.
bool verbose_
Output verbosity (default: true).
const polyMesh & mesh() const noexcept
Reference to the mesh.
const polyMesh & mesh_
Reference to the mesh.
static Istream & checkIs(Istream &is)
Check state of stream.
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.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
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).
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
vector point
Point is a vector.
List< bool > boolList
A List of bools.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.