49 regionToCell::typeName,
50 "\n Usage: regionToCell subCellSet (pt0 .. ptn)\n\n" 51 " Select all cells in the connected region containing" 52 " points (pt0..ptn).\n" 58 void Foam::regionToCell::markRegionFaces
65 const labelList& faceOwner = mesh_.faceOwner();
66 const labelList& faceNeighbour = mesh_.faceNeighbour();
67 forAll(faceNeighbour, facei)
71 selectedCell[faceOwner[facei]]
72 != selectedCell[faceNeighbour[facei]]
75 regionFace[facei] =
true;
84 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
87 const polyPatch& pp = pbm[
patchi];
91 label facei = pp.start()+i;
92 label bFacei = facei-mesh_.nInternalFaces();
95 selectedCell[faceCells[i]]
96 != selectedCell[nbrSelected[bFacei]]
99 regionFace[facei] =
true;
109 const regionSplit& cellRegion
112 boolList keepRegion(cellRegion.nRegions(),
false);
118 label celli = mesh_.findCell(insidePoints_[i]);
120 label keepRegionI = -1;
121 label keepProci = -1;
124 keepRegionI = cellRegion[celli];
127 reduce(keepRegionI, maxOp<label>());
128 keepRegion[keepRegionI] =
true;
130 reduce(keepProci, maxOp<label>());
135 <<
"Did not find " << insidePoints_[i]
136 <<
" in mesh." <<
" Mesh bounds are " << mesh_.bounds()
142 Info<<
" Found location " << insidePoints_[i]
143 <<
" in cell " << celli <<
" on processor " << keepProci
144 <<
" in global region " << keepRegionI
145 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
153 void Foam::regionToCell::unselectOutsideRegions
159 boolList blockedFace(mesh_.nFaces(),
false);
160 markRegionFaces(selectedCell, blockedFace);
163 regionSplit cellRegion(mesh_, blockedFace);
166 boolList keepRegion(findRegions(
true, cellRegion));
171 if (!keepRegion[cellRegion[celli]])
173 selectedCell[celli] =
false;
179 void Foam::regionToCell::shrinkRegions
187 boolList boundaryPoint(mesh_.nPoints(),
false);
189 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
193 const polyPatch& pp = pbm[
patchi];
195 if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
199 const face&
f = pp[i];
202 boundaryPoint[f[fp]] =
true;
208 forAll(selectedCell, celli)
210 if (!selectedCell[celli])
212 const labelList& cPoints = mesh_.cellPoints(celli);
215 boundaryPoint[cPoints[i]] =
true;
227 forAll(boundaryPoint, pointi)
229 if (boundaryPoint[pointi])
231 const labelList& pCells = mesh_.pointCells(pointi);
234 label celli = pCells[i];
235 if (selectedCell[celli])
237 selectedCell[celli] =
false;
244 <<
" cells." <<
endl;
248 void Foam::regionToCell::erode
257 boolList shrunkSelectedCell(selectedCell);
259 for (
label iter = 0; iter < nErode_; iter++)
261 shrinkRegions(shrunkSelectedCell);
270 boolList blockedFace(mesh_.nFaces(),
false);
271 markRegionFaces(shrunkSelectedCell, blockedFace);
274 regionSplit cellRegion(mesh_, blockedFace);
277 boolList keepRegion(findRegions(
true, cellRegion));
281 boolList removeCell(mesh_.nCells(),
false);
284 if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
286 removeCell[celli] =
true;
296 for (
label iter = 0; iter < nErode_; iter++)
299 boolList boundaryPoint(mesh_.nPoints(),
false);
302 if (removeCell[celli])
304 const labelList& cPoints = mesh_.cellPoints(celli);
307 boundaryPoint[cPoints[i]] =
true;
316 forAll(boundaryPoint, pointi)
318 if (boundaryPoint[pointi])
320 const labelList& pCells = mesh_.pointCells(pointi);
323 label celli = pCells[i];
324 if (!removeCell[celli])
326 removeCell[celli] =
true;
341 if (removeCell[celli])
343 selectedCell[celli] =
false;
349 void Foam::regionToCell::combine(topoSet&
set,
const bool add)
const 352 boolList selectedCell(mesh_.nCells(),
true);
354 if (setName_.size() && setName_ !=
"none")
356 Info<<
" Loading subset " << setName_ <<
" to delimit search region." 358 cellSet subSet(mesh_, setName_);
360 selectedCell =
false;
363 selectedCell[iter.key()] =
true;
368 unselectOutsideRegions(selectedCell);
376 forAll(selectedCell, celli)
378 if (selectedCell[celli])
380 addOrDelete(
set, celli, add);
399 insidePoints_(insidePoints),
415 dict.
found(
"insidePoints")
416 ? dict.
lookup(
"insidePoints")
417 : dict.
lookup(
"insidePoint")
431 setName_(checkIs(is)),
432 insidePoints_(checkIs(is)),
453 Info<<
" Adding all cells of connected region containing points " 454 << insidePoints_ <<
" ..." <<
endl;
460 Info<<
" Removing all cells of connected region containing points " 461 << 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.
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.