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;
242 <<
" cells." <<
endl;
246 void Foam::regionToCell::erode
255 boolList shrunkSelectedCell(selectedCell);
257 for (label iter = 0; iter < nErode_; iter++)
259 shrinkRegions(shrunkSelectedCell);
267 boolList blockedFace(mesh_.nFaces(),
false);
268 markRegionFaces(shrunkSelectedCell, blockedFace);
271 regionSplit cellRegion(mesh_, blockedFace);
274 boolList keepRegion(findRegions(verbose_, cellRegion));
278 boolList removeCell(mesh_.nCells(),
false);
281 if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
283 removeCell[celli] =
true;
292 for (label iter = 0; iter < nErode_; iter++)
295 boolList boundaryPoint(mesh_.nPoints(),
false);
298 if (removeCell[celli])
300 const labelList& cPoints = mesh_.cellPoints(celli);
303 boundaryPoint[cPoints[i]] =
true;
312 forAll(boundaryPoint, pointi)
314 if (boundaryPoint[pointi])
316 const labelList& pCells = mesh_.pointCells(pointi);
319 label celli = pCells[i];
320 if (!removeCell[celli])
322 removeCell[celli] =
true;
337 if (removeCell[celli])
339 selectedCell[celli] =
false;
345 void Foam::regionToCell::combine(topoSet&
set,
const bool add)
const 348 boolList selectedCell(mesh_.nCells(),
true);
350 if (setName_.size() && setName_ !=
"none")
352 Info<<
" Loading subset " << setName_
353 <<
" to delimit search region." 356 cellSet subSet(mesh_, setName_);
358 selectedCell =
false;
359 for (
const label celli : subSet)
361 selectedCell[celli] =
true;
366 unselectOutsideRegions(selectedCell);
374 forAll(selectedCell, celli)
376 if (selectedCell[celli])
378 addOrDelete(
set, celli,
add);
388 const polyMesh&
mesh,
394 topoSetCellSource(
mesh),
408 setName_(
dict.getOrDefault<
word>(
"set",
"none")),
419 const polyMesh&
mesh,
423 topoSetCellSource(
mesh),
424 setName_(checkIs(is)),
425 insidePoints_(checkIs(is)),
442 Info<<
" Adding all cells of connected region " 443 <<
"containing points " 444 << insidePoints_ <<
" ..." <<
endl;
453 Info<<
" Removing all cells of connected region " 454 <<
"containing points " 455 << insidePoints_ <<
" ..." <<
endl;
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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.
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)
Number of this process (starting from masterNo() = 0)
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.
A class for handling words, derived from Foam::string.
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)
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Subtract elements from current set.
Class with constructor to add usage string to table.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
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.