44 void Foam::regionToCell::markRegionFaces
53 forAll(faceNeighbour, facei)
57 selectedCell[faceOwner[facei]]
58 != selectedCell[faceNeighbour[facei]]
61 regionFace[facei] =
true;
73 const polyPatch& pp = pbm[
patchi];
77 label facei = pp.start()+i;
79 if (selectedCell[faceCells[i]] != nbrSelected[bFacei])
81 regionFace[facei] =
true;
91 const regionSplit& cellRegion
94 boolList keepRegion(cellRegion.nRegions(),
false);
100 label celli = mesh_.findCell(insidePoints_[i]);
102 label keepRegionI = -1;
103 label keepProci = -1;
106 keepRegionI = cellRegion[celli];
109 reduce(keepRegionI, maxOp<label>());
110 keepRegion[keepRegionI] =
true;
112 reduce(keepProci, maxOp<label>());
117 <<
"Did not find " << insidePoints_[i]
118 <<
" in mesh." <<
" Mesh bounds are " << mesh_.bounds()
124 Info<<
" Found location " << insidePoints_[i]
125 <<
" in cell " << celli <<
" on processor " << keepProci
126 <<
" in global region " << keepRegionI
127 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
135 void Foam::regionToCell::unselectOutsideRegions
141 boolList blockedFace(mesh_.nFaces(),
false);
142 markRegionFaces(selectedCell, blockedFace);
145 regionSplit cellRegion(mesh_, blockedFace);
148 boolList keepRegion(findRegions(
true, cellRegion));
153 if (!keepRegion[cellRegion[celli]])
155 selectedCell[celli] =
false;
161 void Foam::regionToCell::shrinkRegions
169 boolList boundaryPoint(mesh_.nPoints(),
false);
171 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
175 const polyPatch& pp = pbm[
patchi];
177 if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
181 const face&
f = pp[i];
184 boundaryPoint[
f[fp]] =
true;
190 forAll(selectedCell, celli)
192 if (!selectedCell[celli])
194 const labelList& cPoints = mesh_.cellPoints(celli);
197 boundaryPoint[cPoints[i]] =
true;
209 forAll(boundaryPoint, pointi)
211 if (boundaryPoint[pointi])
213 const labelList& pCells = mesh_.pointCells(pointi);
216 label celli = pCells[i];
217 if (selectedCell[celli])
219 selectedCell[celli] =
false;
226 <<
" cells." <<
endl;
230 void Foam::regionToCell::erode
239 boolList shrunkSelectedCell(selectedCell);
241 for (
label iter = 0; iter < nErode_; iter++)
243 shrinkRegions(shrunkSelectedCell);
252 boolList blockedFace(mesh_.nFaces(),
false);
253 markRegionFaces(shrunkSelectedCell, blockedFace);
256 regionSplit cellRegion(mesh_, blockedFace);
259 boolList keepRegion(findRegions(
true, cellRegion));
263 boolList removeCell(mesh_.nCells(),
false);
266 if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
268 removeCell[celli] =
true;
278 for (
label iter = 0; iter < nErode_; iter++)
281 boolList boundaryPoint(mesh_.nPoints(),
false);
284 if (removeCell[celli])
286 const labelList& cPoints = mesh_.cellPoints(celli);
289 boundaryPoint[cPoints[i]] =
true;
297 forAll(boundaryPoint, pointi)
299 if (boundaryPoint[pointi])
301 const labelList& pCells = mesh_.pointCells(pointi);
304 label celli = pCells[i];
305 if (!removeCell[celli])
307 removeCell[celli] =
true;
321 if (removeCell[celli])
323 selectedCell[celli] =
false;
329 void Foam::regionToCell::combine(topoSet& set,
const bool add)
const
332 boolList selectedCell(mesh_.nCells(),
true);
334 if (setName_.size() && setName_ !=
"none")
336 Info<<
" Loading subset " << setName_ <<
" to delimit search region."
338 cellSet subSet(mesh_, setName_);
340 selectedCell =
false;
343 selectedCell[iter.key()] =
true;
348 unselectOutsideRegions(selectedCell);
356 forAll(selectedCell, celli)
358 if (selectedCell[celli])
360 addOrDelete(set, celli,
add);
390 setName_(
dict.lookupOrDefault<
word>(
"set",
"none")),
397 nErode_(
dict.lookupOrDefault(
"nErode", 0))
417 Info<<
" Adding all cells of connected region containing points "
418 << insidePoints_ <<
" ..." <<
endl;
424 Info<<
" Removing all cells of connected region containing points "
425 << insidePoints_ <<
" ..." <<
endl;
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Macros for easy insertion into run-time selection tables.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
A list of keyword definitions, which are a keyword followed by any number of values (e....
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
label nInternalFaces() const
TopoSetSource. Select cells belonging to topological connected region (that contains given points)
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
virtual ~regionToCell()
Destructor.
Base class of a source for a topoSet.
setAction
Enumeration defining the valid actions.
General set of labels of mesh quantity (points, cells, faces).
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet dimLength
List< bool > boolList
Bool container classes.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
defineTypeNameAndDebug(combustionModel, 0)
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
UList< label > labelUList