45 void Foam::regionToCell::markRegionFaces
54 forAll(faceNeighbour, facei)
58 selectedCell[faceOwner[facei]]
59 != selectedCell[faceNeighbour[facei]]
62 regionFace[facei] =
true;
74 const polyPatch& pp = pbm[
patchi];
78 label facei = pp.start()+i;
80 if (selectedCell[faceCells[i]] != nbrSelected[bFacei])
82 regionFace[facei] =
true;
92 const regionSplit& cellRegion
97 boolList keepRegion(cellRegion.nRegions(),
false);
103 label celli = searchEngine.findCell(insidePoints_[i]);
105 label keepRegionI = -1;
106 label keepProci = -1;
109 keepRegionI = cellRegion[celli];
112 reduce(keepRegionI, maxOp<label>());
113 keepRegion[keepRegionI] =
true;
115 reduce(keepProci, maxOp<label>());
120 <<
"Did not find " << insidePoints_[i]
121 <<
" in mesh." <<
" Mesh bounds are " << mesh_.bounds()
127 Info<<
" Found location " << insidePoints_[i]
128 <<
" in cell " << celli <<
" on processor " << keepProci
129 <<
" in global region " << keepRegionI
130 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
138 void Foam::regionToCell::unselectOutsideRegions
144 boolList blockedFace(mesh_.nFaces(),
false);
145 markRegionFaces(selectedCell, blockedFace);
148 regionSplit cellRegion(mesh_, blockedFace);
151 boolList keepRegion(findRegions(
true, cellRegion));
156 if (!keepRegion[cellRegion[celli]])
158 selectedCell[celli] =
false;
164 void Foam::regionToCell::shrinkRegions
172 boolList boundaryPoint(mesh_.nPoints(),
false);
174 const polyBoundaryMesh& pbm = mesh_.boundary();
178 const polyPatch& pp = pbm[
patchi];
180 if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
184 const face&
f = pp[i];
187 boundaryPoint[
f[fp]] =
true;
193 forAll(selectedCell, celli)
195 if (!selectedCell[celli])
197 const labelList& cPoints = mesh_.cellPoints(celli);
200 boundaryPoint[cPoints[i]] =
true;
212 forAll(boundaryPoint, pointi)
214 if (boundaryPoint[pointi])
216 const labelList& pCells = mesh_.pointCells(pointi);
219 label celli = pCells[i];
220 if (selectedCell[celli])
222 selectedCell[celli] =
false;
229 <<
" cells." <<
endl;
233 void Foam::regionToCell::erode
242 boolList shrunkSelectedCell(selectedCell);
244 for (
label iter = 0; iter < nErode_; iter++)
246 shrinkRegions(shrunkSelectedCell);
255 boolList blockedFace(mesh_.nFaces(),
false);
256 markRegionFaces(shrunkSelectedCell, blockedFace);
259 regionSplit cellRegion(mesh_, blockedFace);
262 boolList keepRegion(findRegions(
true, cellRegion));
266 boolList removeCell(mesh_.nCells(),
false);
269 if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
271 removeCell[celli] =
true;
281 for (
label iter = 0; iter < nErode_; iter++)
284 boolList boundaryPoint(mesh_.nPoints(),
false);
287 if (removeCell[celli])
289 const labelList& cPoints = mesh_.cellPoints(celli);
292 boundaryPoint[cPoints[i]] =
true;
300 forAll(boundaryPoint, pointi)
302 if (boundaryPoint[pointi])
304 const labelList& pCells = mesh_.pointCells(pointi);
307 label celli = pCells[i];
308 if (!removeCell[celli])
310 removeCell[celli] =
true;
324 if (removeCell[celli])
326 selectedCell[celli] =
false;
332 void Foam::regionToCell::combine(topoSet& set,
const bool add)
const
335 boolList selectedCell(mesh_.nCells(),
true);
337 if (setName_.size() && setName_ !=
"none")
339 Info<<
" Loading subset " << setName_ <<
" to delimit search region."
341 cellSet subSet(mesh_, setName_);
343 selectedCell =
false;
346 selectedCell[iter.key()] =
true;
351 unselectOutsideRegions(selectedCell);
359 forAll(selectedCell, celli)
361 if (selectedCell[celli])
363 addOrDelete(set, celli,
add);
373 const polyMesh&
mesh,
388 const polyMesh&
mesh,
389 const dictionary&
dict
393 setName_(
dict.lookupOrDefault<word>(
"set",
"none")),
400 nErode_(
dict.lookupOrDefault(
"nErode", 0))
420 Info<<
" Adding all cells of connected region containing points "
421 << insidePoints_ <<
" ..." <<
endl;
427 Info<<
" Removing all cells of connected region containing points "
428 << insidePoints_ <<
" ..." <<
endl;
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
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 const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
Motion of the mesh specified as a list of pointMeshMovers.
const polyBoundaryMesh & boundary() const
Return boundary mesh.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
label nInternalFaces() const
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
virtual ~regionToCell()
Destructor.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
setAction
Enumeration defining the valid actions.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
void add(GeometricField< typename typeOfSum< Type1, Type2 >::type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type1, GeoMesh, PrimitiveField2 > &gf1, const GeometricField< Type2, GeoMesh, PrimitiveField3 > &gf2)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet & dimLength
vectorField pointField
pointField is a vectorField.
List< bool > boolList
Bool container classes.
vector point
Point is a vector.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
UList< label > labelUList