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;
245 void 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);
270 regionSplit cellRegion(mesh_, 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;
344 void 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);
400 const polyMesh&
mesh,
406 topoSetCellSource(
mesh),
425 dict.getCompat<
pointField>(
"insidePoints", {{
"insidePoint", 0 }})
443 const polyMesh&
mesh,
447 topoSetCellSource(
mesh),
448 setName_(checkIs(is)),
450 insidePoints_(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;
const polyBoundaryMesh & pbm
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Create a new set and ADD elements to it.
Add elements to current set.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells...
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
#define forAll(list, i)
Loop across all elements in list.
AccessType combine(const UList< T > &lists, AccessOp aop=accessOp< T >())
Combines sub-lists into a single list.
vectorField pointField
pointField is a vectorField.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
static MinMax< T > ge(const T &minVal)
A semi-infinite range from minVal to the type max.
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...
setAction
Enumeration defining various actions.
virtual const labelList & faceOwner() const
Return face owner.
label nInternalFaces() const noexcept
Number of internal faces.
const polyMesh & mesh_
Reference to the mesh.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
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...
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
Subtract elements from current set.
Class with constructor to add usage string to table.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
List< bool > boolList
A List of bools.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Do not request registration (bool: false)
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)