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();
89 if (selectedCell[faceCells[i]] != nbrSelected[bFacei])
91 regionFace[facei] =
true;
101 const regionSplit& cellRegion
104 boolList keepRegion(cellRegion.nRegions(),
false);
110 label celli = mesh_.findCell(insidePoints_[i]);
112 label keepRegionI = -1;
113 label keepProci = -1;
116 keepRegionI = cellRegion[celli];
119 reduce(keepRegionI, maxOp<label>());
120 keepRegion[keepRegionI] =
true;
122 reduce(keepProci, maxOp<label>());
127 <<
"Did not find " << insidePoints_[i]
128 <<
" in mesh." <<
" Mesh bounds are " << mesh_.bounds()
134 Info<<
" Found location " << insidePoints_[i]
135 <<
" in cell " << celli <<
" on processor " << keepProci
136 <<
" in global region " << keepRegionI
137 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
145 void Foam::regionToCell::unselectOutsideRegions
151 boolList blockedFace(mesh_.nFaces(),
false);
152 markRegionFaces(selectedCell, blockedFace);
155 regionSplit cellRegion(mesh_, blockedFace);
158 boolList keepRegion(findRegions(
true, cellRegion));
163 if (!keepRegion[cellRegion[celli]])
165 selectedCell[celli] =
false;
171 void Foam::regionToCell::shrinkRegions
179 boolList boundaryPoint(mesh_.nPoints(),
false);
181 const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
185 const polyPatch& pp = pbm[
patchi];
187 if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
191 const face&
f = pp[i];
194 boundaryPoint[f[fp]] =
true;
200 forAll(selectedCell, celli)
202 if (!selectedCell[celli])
204 const labelList& cPoints = mesh_.cellPoints(celli);
207 boundaryPoint[cPoints[i]] =
true;
219 forAll(boundaryPoint, pointi)
221 if (boundaryPoint[pointi])
223 const labelList& pCells = mesh_.pointCells(pointi);
226 label celli = pCells[i];
227 if (selectedCell[celli])
229 selectedCell[celli] =
false;
236 <<
" cells." <<
endl;
240 void Foam::regionToCell::erode
249 boolList shrunkSelectedCell(selectedCell);
251 for (
label iter = 0; iter < nErode_; iter++)
253 shrinkRegions(shrunkSelectedCell);
262 boolList blockedFace(mesh_.nFaces(),
false);
263 markRegionFaces(shrunkSelectedCell, blockedFace);
266 regionSplit cellRegion(mesh_, blockedFace);
269 boolList keepRegion(findRegions(
true, cellRegion));
273 boolList removeCell(mesh_.nCells(),
false);
276 if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
278 removeCell[celli] =
true;
288 for (
label iter = 0; iter < nErode_; iter++)
291 boolList boundaryPoint(mesh_.nPoints(),
false);
294 if (removeCell[celli])
296 const labelList& cPoints = mesh_.cellPoints(celli);
299 boundaryPoint[cPoints[i]] =
true;
308 forAll(boundaryPoint, pointi)
310 if (boundaryPoint[pointi])
312 const labelList& pCells = mesh_.pointCells(pointi);
315 label celli = pCells[i];
316 if (!removeCell[celli])
318 removeCell[celli] =
true;
333 if (removeCell[celli])
335 selectedCell[celli] =
false;
341 void Foam::regionToCell::combine(topoSet&
set,
const bool add)
const 344 boolList selectedCell(mesh_.nCells(),
true);
346 if (setName_.size() && setName_ !=
"none")
348 Info<<
" Loading subset " << setName_ <<
" to delimit search region." 350 cellSet subSet(mesh_, setName_);
352 selectedCell =
false;
355 selectedCell[iter.key()] =
true;
360 unselectOutsideRegions(selectedCell);
368 forAll(selectedCell, celli)
370 if (selectedCell[celli])
372 addOrDelete(
set, celli, add);
390 insidePoints_(insidePoints),
405 dict.
found(
"insidePoint")
407 : dict.
lookup(
"insidePoints")
409 nErode_(dict.lookupOrDefault(
"nErode", 0))
420 setName_(checkIs(is)),
421 insidePoints_(checkIs(is)),
442 Info<<
" Adding all cells of connected region containing points " 443 << insidePoints_ <<
" ..." <<
endl;
449 Info<<
" Removing all cells of connected region containing points " 450 << 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.
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.
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.