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" 72 void Foam::regionsToCell::markRegionFaces
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;
181 void 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;
207 void 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;
274 void 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;
375 void 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);
418 const polyMesh&
mesh,
424 topoSetCellSource(
mesh),
438 setName_(
dict.getOrDefault<
word>(
"set",
"none")),
445 nErode_(
dict.getOrDefault<label>(
"nErode", 0))
456 setName_(checkIs(is)),
457 insidePoints_(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;
const polyBoundaryMesh & pbm
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
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.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
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...
Lookup type of boundary radiation properties.
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.
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
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.
A class for handling words, derived from Foam::string.
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)
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
regionsToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
Subtract elements from current set.
vector point
Point is a vector.
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.
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)