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;
85 const polyBoundaryMesh&
pbm =
mesh_.boundaryMesh();
88 const polyPatch&
pp =
pbm[patchi];
92 label facei =
pp.start()+i;
93 label bFacei = facei-
mesh_.nInternalFaces();
94 if (selectedCell[faceCells[i]] != nbrSelected[bFacei])
96 regionFace[facei] =
true;
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];
125 keepRegion[keepRegionI] =
true;
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);
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);
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;
245void Foam::regionToCell::erode
254 boolList shrunkSelectedCell(selectedCell);
256 for (label iter = 0; iter < nErode_; iter++)
258 shrinkRegions(shrunkSelectedCell);
266 boolList blockedFace(mesh_.nFaces(),
false);
267 markRegionFaces(shrunkSelectedCell, blockedFace);
273 boolList keepRegion(findRegions(verbose_, cellRegion));
277 boolList removeCell(mesh_.nCells(),
false);
280 if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
282 removeCell[celli] =
true;
291 for (label iter = 0; iter < nErode_; iter++)
294 boolList boundaryPoint(mesh_.nPoints(),
false);
297 if (removeCell[celli])
299 const labelList& cPoints = mesh_.cellPoints(celli);
302 boundaryPoint[cPoints[i]] =
true;
311 forAll(boundaryPoint, pointi)
313 if (boundaryPoint[pointi])
315 const labelList& pCells = mesh_.pointCells(pointi);
318 label celli = pCells[i];
319 if (!removeCell[celli])
321 removeCell[celli] =
true;
336 if (removeCell[celli])
338 selectedCell[celli] =
false;
344void Foam::regionToCell::combine(
topoSet& set,
const bool add)
const
347 boolList selectedCell(mesh_.nCells(),
true);
349 if (!setName_.empty() && setName_ !=
"none")
353 Info<<
" Using cellZone " << setName_
354 <<
" to delimit search region." <<
nl;
356 selectedCell =
false;
357 for (
const label celli : mesh_.cellZones()[setName_])
359 selectedCell[celli] =
true;
364 Info<<
" Loading cellSet " << setName_
365 <<
" to delimit search region." <<
nl;
369 selectedCell =
false;
370 for (
const label celli : subSet)
372 selectedCell[celli] =
true;
378 unselectOutsideRegions(selectedCell);
386 forAll(selectedCell, celli)
388 if (selectedCell[celli])
390 addOrDelete(set, celli,
add);
425 dict.getCompat<
pointField>(
"insidePoints", {{
"insidePoint", 0 }})
448 setName_(checkIs(is)),
467 Info<<
" Adding all cells of connected region "
468 <<
"containing points "
469 << insidePoints_ <<
" ..." <<
endl;
478 Info<<
" Removing all cells of connected region "
479 <<
"containing points "
480 << 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.
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 MinMax< label > ge(const label &minVal)
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,...
T getCheckOrDefault(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
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.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
A topoSetCellSource to select cells belonging to a topologically connected region (that contains give...
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
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.
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.
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).
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.