44 void Foam::regionToCell::markRegionFaces
51 const labelList& faceOwner = mesh_.faceOwner();
52 const labelList& faceNeighbour = mesh_.faceNeighbour();
53 forAll(faceNeighbour, facei)
57 selectedCell[faceOwner[facei]]
58 != selectedCell[faceNeighbour[facei]]
61 regionFace[facei] =
true;
70 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
73 const polyPatch& pp = pbm[
patchi];
77 label facei = pp.start()+i;
78 label bFacei = facei-mesh_.nInternalFaces();
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;
298 forAll(boundaryPoint, pointi)
300 if (boundaryPoint[pointi])
302 const labelList& pCells = mesh_.pointCells(pointi);
305 label celli = pCells[i];
306 if (!removeCell[celli])
308 removeCell[celli] =
true;
323 if (removeCell[celli])
325 selectedCell[celli] =
false;
331 void Foam::regionToCell::combine(topoSet&
set,
const bool add)
const 334 boolList selectedCell(mesh_.nCells(),
true);
336 if (setName_.size() && setName_ !=
"none")
338 Info<<
" Loading subset " << setName_ <<
" to delimit search region." 340 cellSet subSet(mesh_, setName_);
342 selectedCell =
false;
345 selectedCell[iter.key()] =
true;
350 unselectOutsideRegions(selectedCell);
358 forAll(selectedCell, celli)
360 if (selectedCell[celli])
362 addOrDelete(
set, celli, add);
380 insidePoints_(insidePoints),
395 dict.
found(
"insidePoint")
397 : dict.
lookup(
"insidePoints")
399 nErode_(dict.lookupOrDefault(
"nErode", 0))
419 Info<<
" Adding all cells of connected region containing points " 420 << insidePoints_ <<
" ..." <<
endl;
426 Info<<
" Removing all cells of connected region containing points " 427 << insidePoints_ <<
" ..." <<
endl;
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual ~regionToCell()
Destructor.
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
Base class of a source for a topoSet.
List< bool > boolList
Bool container classes.
vectorField pointField
pointField is a vectorField.
stressControl lookup("compactNormalStress") >> compactNormalStress
A class for handling words, derived from string.
setAction
Enumeration defining the valid actions.
List< label > labelList
A List of labels.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
General set of labels of mesh quantity (points, cells, faces).
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Mesh consisting of general polyhedral cells.
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.