45 regionToCell::typeName,
46 "\n Usage: regionToCell subCellSet (pt0 .. ptn)\n\n" 47 " Select all cells in the connected region containing" 48 " points (pt0..ptn).\n" 54 void Foam::regionToCell::markRegionFaces
61 const labelList& faceOwner = mesh_.faceOwner();
62 const labelList& faceNeighbour = mesh_.faceNeighbour();
63 forAll(faceNeighbour, facei)
67 selectedCell[faceOwner[facei]]
68 != selectedCell[faceNeighbour[facei]]
71 regionFace[facei] =
true;
80 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
83 const polyPatch& pp = pbm[
patchi];
87 label facei = pp.start()+i;
88 label bFacei = facei-mesh_.nInternalFaces();
91 selectedCell[faceCells[i]]
92 != selectedCell[nbrSelected[bFacei]]
95 regionFace[facei] =
true;
105 const regionSplit& cellRegion
108 boolList keepRegion(cellRegion.nRegions(),
false);
114 label celli = mesh_.findCell(insidePoints_[i]);
116 label keepRegionI = -1;
117 label keepProci = -1;
120 keepRegionI = cellRegion[celli];
123 reduce(keepRegionI, maxOp<label>());
124 keepRegion[keepRegionI] =
true;
126 reduce(keepProci, maxOp<label>());
131 <<
"Did not find " << insidePoints_[i]
132 <<
" in mesh." <<
" Mesh bounds are " << mesh_.bounds()
138 Info<<
" Found location " << insidePoints_[i]
139 <<
" in cell " << celli <<
" on processor " << keepProci
140 <<
" in global region " << keepRegionI
141 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
149 void Foam::regionToCell::unselectOutsideRegions
155 boolList blockedFace(mesh_.nFaces(),
false);
156 markRegionFaces(selectedCell, blockedFace);
159 regionSplit cellRegion(mesh_, blockedFace);
162 boolList keepRegion(findRegions(
true, cellRegion));
167 if (!keepRegion[cellRegion[celli]])
169 selectedCell[celli] =
false;
175 void Foam::regionToCell::shrinkRegions
183 boolList boundaryPoint(mesh_.nPoints(),
false);
185 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
189 const polyPatch& pp = pbm[
patchi];
191 if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
195 const face&
f = pp[i];
198 boundaryPoint[f[fp]] =
true;
204 forAll(selectedCell, celli)
206 if (!selectedCell[celli])
208 const labelList& cPoints = mesh_.cellPoints(celli);
211 boundaryPoint[cPoints[i]] =
true;
223 forAll(boundaryPoint, pointi)
225 if (boundaryPoint[pointi])
227 const labelList& pCells = mesh_.pointCells(pointi);
230 label celli = pCells[i];
231 if (selectedCell[celli])
233 selectedCell[celli] =
false;
240 <<
" cells." <<
endl;
244 void Foam::regionToCell::erode
253 boolList shrunkSelectedCell(selectedCell);
255 for (
label iter = 0; iter < nErode_; iter++)
257 shrinkRegions(shrunkSelectedCell);
266 boolList blockedFace(mesh_.nFaces(),
false);
267 markRegionFaces(shrunkSelectedCell, blockedFace);
270 regionSplit cellRegion(mesh_, blockedFace);
273 boolList keepRegion(findRegions(
true, cellRegion));
277 boolList removeCell(mesh_.nCells(),
false);
280 if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
282 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_ <<
" to delimit search region." 354 cellSet subSet(mesh_, setName_);
356 selectedCell =
false;
359 selectedCell[iter.key()] =
true;
364 unselectOutsideRegions(selectedCell);
372 forAll(selectedCell, celli)
374 if (selectedCell[celli])
376 addOrDelete(
set, celli, add);
394 insidePoints_(insidePoints),
409 dict.
found(
"insidePoints")
410 ? dict.
lookup(
"insidePoints")
411 : dict.
lookup(
"insidePoint")
424 setName_(checkIs(is)),
425 insidePoints_(checkIs(is)),
446 Info<<
" Adding all cells of connected region containing points " 447 << insidePoints_ <<
" ..." <<
endl;
453 Info<<
" Removing all cells of connected region containing points " 454 << 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.
intWM_LABEL_SIZE_t 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.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
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.
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
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.
A class for handling words, derived from string.
setAction
Enumeration defining the valid actions.
List< label > labelList
A List of labels.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
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,.
Class with constructor to add usage string to table.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Mesh consisting of general polyhedral cells.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.