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>());
136 "outsideCellSelection::findRegions" 137 "(const bool, const regionSplit&)" 138 ) <<
"Did not find " << insidePoints_[i]
139 <<
" in mesh." <<
" Mesh bounds are " << mesh_.bounds()
145 Info<<
" Found location " << insidePoints_[i]
146 <<
" in cell " << cellI <<
" on processor " << keepProcI
147 <<
" in global region " << keepRegionI
148 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
156 void Foam::regionToCell::unselectOutsideRegions
162 boolList blockedFace(mesh_.nFaces(),
false);
163 markRegionFaces(selectedCell, blockedFace);
166 regionSplit cellRegion(mesh_, blockedFace);
169 boolList keepRegion(findRegions(
true, cellRegion));
174 if (!keepRegion[cellRegion[cellI]])
176 selectedCell[cellI] =
false;
182 void Foam::regionToCell::shrinkRegions
190 boolList boundaryPoint(mesh_.nPoints(),
false);
192 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
196 const polyPatch& pp = pbm[patchI];
198 if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
202 const face&
f = pp[i];
205 boundaryPoint[f[fp]] =
true;
211 forAll(selectedCell, cellI)
213 if (!selectedCell[cellI])
215 const labelList& cPoints = mesh_.cellPoints(cellI);
218 boundaryPoint[cPoints[i]] =
true;
230 forAll(boundaryPoint, pointI)
232 if (boundaryPoint[pointI])
234 const labelList& pCells = mesh_.pointCells(pointI);
237 label cellI = pCells[i];
238 if (selectedCell[cellI])
240 selectedCell[cellI] =
false;
247 <<
" cells." <<
endl;
251 void Foam::regionToCell::erode
260 boolList shrunkSelectedCell(selectedCell);
262 for (
label iter = 0; iter < nErode_; iter++)
264 shrinkRegions(shrunkSelectedCell);
273 boolList blockedFace(mesh_.nFaces(),
false);
274 markRegionFaces(shrunkSelectedCell, blockedFace);
277 regionSplit cellRegion(mesh_, blockedFace);
280 boolList keepRegion(findRegions(
true, cellRegion));
284 boolList removeCell(mesh_.nCells(),
false);
287 if (shrunkSelectedCell[cellI] && !keepRegion[cellRegion[cellI]])
289 removeCell[cellI] =
true;
299 for (
label iter = 0; iter < nErode_; iter++)
302 boolList boundaryPoint(mesh_.nPoints(),
false);
305 if (removeCell[cellI])
307 const labelList& cPoints = mesh_.cellPoints(cellI);
310 boundaryPoint[cPoints[i]] =
true;
319 forAll(boundaryPoint, pointI)
321 if (boundaryPoint[pointI])
323 const labelList& pCells = mesh_.pointCells(pointI);
326 label cellI = pCells[i];
327 if (!removeCell[cellI])
329 removeCell[cellI] =
true;
344 if (removeCell[cellI])
346 selectedCell[cellI] =
false;
352 void Foam::regionToCell::combine(topoSet&
set,
const bool add)
const 355 boolList selectedCell(mesh_.nCells(),
true);
357 if (setName_.size() && setName_ !=
"none")
359 Info<<
" Loading subset " << setName_ <<
" to delimit search region." 361 cellSet subSet(mesh_, setName_);
363 selectedCell =
false;
366 selectedCell[iter.key()] =
true;
371 unselectOutsideRegions(selectedCell);
379 forAll(selectedCell, cellI)
381 if (selectedCell[cellI])
383 addOrDelete(
set, cellI, add);
402 insidePoints_(insidePoints),
418 dict.
found(
"insidePoints")
419 ? dict.
lookup(
"insidePoints")
420 : dict.
lookup(
"insidePoint")
434 setName_(checkIs(is)),
435 insidePoints_(checkIs(is)),
456 Info<<
" Adding all cells of connected region containing points " 457 << insidePoints_ <<
" ..." <<
endl;
463 Info<<
" Removing all cells of connected region containing points " 464 << insidePoints_ <<
" ..." <<
endl;
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
UList< label > labelUList
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
General set of labels of mesh quantity (points, cells, faces).
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A class for handling words, derived from string.
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)
virtual ~regionToCell()
Destructor.
A list of keyword definitions, which are a keyword followed by any number of values (e...
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Ostream & endl(Ostream &os)
Add newline and flush stream.
setAction
Enumeration defining the valid actions.
Macros for easy insertion into run-time selection tables.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Mesh consisting of general polyhedral cells.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
List< label > labelList
A List of labels.
Base class of a source for a topoSet.
static void swapBoundaryCellList(const polyMesh &mesh, const UList< T > &cellData, List< T > &neighbourCellData)
Swap to obtain neighbour cell values for all boundary faces.
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
Class with constructor to add usage string to table.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
List< bool > boolList
Bool container classes.