67 planeToFaceZone::typeName,
68 "\n Usage: planeToFaceZone (px py pz) (nx ny nz) include\n\n"
69 " Select faces for which the adjacent cell centres lie on opposite "
78Foam::planeToFaceZone::faceActionNames_
80 { faceAction::ALL,
"all" },
81 { faceAction::CLOSEST,
"closest" },
87void Foam::planeToFaceZone::combine(faceZoneSet& fzSet,
const bool add)
const
90 bitSet cellIsAbovePlane(
mesh_.nCells());
93 if (((
mesh_.cellCentres()[celli] - point_) & normal_) > 0)
95 cellIsAbovePlane.set(celli);
100 bitSet faceIsOnPlane(
mesh_.nFaces());
105 cellIsAbovePlane[
mesh_.faceOwner()[facei]]
106 != cellIsAbovePlane[
mesh_.faceNeighbour()[facei]]
109 faceIsOnPlane.set(facei);
114 const polyPatch&
patch =
mesh_.boundaryMesh()[patchi];
117 const label facei =
patch.start() + patchFacei;
118 if (
patch.coupled() && cellIsAbovePlane[
mesh_.faceOwner()[facei]])
120 faceIsOnPlane.set(facei);
127 labelList newSetFaces(faceIsOnPlane.sortedToc());
128 faceIsOnPlane.clear();
136 labelList newSetFaceRegions(newSetFaces.size(), -1);
142 UIndirectList<face>(
mesh_.faces(), newSetFaces),
163 procRegionOffset[proci] =
164 procRegionOffset[proci - 1]
165 + procNRegions[proci - 1];
169 for (label& regioni : newSetFaceRegions)
175 nRegions = procRegionOffset.last() + procNRegions.last();
185 forAll(newSetFaces, newSetFacei)
187 const label facei = newSetFaces[newSetFacei];
188 const label regioni = newSetFaceRegions[newSetFacei];
189 for (
const label edgei :
mesh_.faceEdges()[facei])
191 meshEdgeRegions[edgei] =
labelList(one{}, regioni);
198 ListOps::appendEqOp<label>(),
204 List<bitSet> regionRegions(nRegions);
205 forAll(newSetFaces, newSetFacei)
207 const label facei = newSetFaces[newSetFacei];
208 const label regioni = newSetFaceRegions[newSetFacei];
209 for (
const label edgei :
mesh_.faceEdges()[facei])
212 regionRegions[regioni].set(meshEdgeRegions[edgei]);
214 forAll(regionRegions, regioni)
217 regionRegions[regioni].unset(regioni);
224 forAll(regionRegions, regioni)
226 for (
const label regi : regionRegions[regioni])
229 regionMap[regi] =
min(regionMap[regi], regionMap[regioni]);
239 forAll(regionMap, regioni)
241 if (regionMap[regioni] > regioni0)
244 regionMap[regioni] = regioni0;
249 nRegions = regioni0 + 1;
253 IndirectList<label>(regionMap, newSetFaceRegions);
257 for (
const label regioni : newSetFaceRegions)
259 ++ regionNFaces[regioni];
263 Info<<
" Found " << nRegions <<
" contiguous regions with "
264 << regionNFaces <<
" faces" <<
endl;
268 label selectedRegioni = -1;
273 forAll(newSetFaces, newSetFacei)
275 const label facei = newSetFaces[newSetFacei];
276 const label regioni = newSetFaceRegions[newSetFacei];
278 const scalar w =
mag(
mesh_.faceAreas()[facei]);
281 regionWeights[regioni] += w;
282 regionCentres[regioni] += w*
c;
289 regionCentres /= regionWeights;
303 Info<<
" Selecting region " << selectedRegioni <<
" with "
304 << regionNFaces[selectedRegioni]
305 <<
" faces as the closest to point " << point_ <<
endl;
311 label newSetFacei0 = 0;
312 forAll(newSetFaces, newSetFacei)
314 newSetFaces[newSetFacei0] = newSetFaces[newSetFacei];
316 if (newSetFaceRegions[newSetFacei] == selectedRegioni)
321 newSetFaces.resize(newSetFacei0);
326 DynamicList<label> newAddressing;
327 DynamicList<bool> newFlipMap;
331 newAddressing = fzSet.addressing();
332 newFlipMap = fzSet.flipMap();
335 const auto& exclude = fzSet;
336 for (
const label facei : newSetFaces)
338 if (!exclude.found(facei))
340 newAddressing.append(facei);
341 newFlipMap.append(cellIsAbovePlane[
mesh_.faceOwner()[facei]]);
348 newAddressing.reserve(fzSet.addressing().size());
349 newFlipMap.reserve(newAddressing.capacity());
352 bitSet exclude(newSetFaces);
353 for (
const label facei : fzSet.addressing())
355 if (!exclude.found(facei))
357 newAddressing.append(facei);
358 newFlipMap.append(cellIsAbovePlane[
mesh_.faceOwner()[facei]]);
362 fzSet.addressing().transfer(newAddressing);
363 fzSet.flipMap().transfer(newFlipMap);
373 const point& basePoint,
375 const faceAction action
422 <<
"Operation only allowed on a faceZoneSet." <<
endl;
432 Info<<
" Adding faces that form a plane at "
433 << point_ <<
" with normal " << normal_ <<
endl;
442 Info<<
" Removing faces that form a plane at "
443 << point_ <<
" with normal " << normal_ <<
endl;
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
static void listGather(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather (reduce) list elements, applying bop to each list element.
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual communication.
static void listCombineReduce(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::listReduce with an in-place cop.
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
@ broadcast
broadcast [MPI]
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Like faceSet but -reads data from faceZone -updates faceZone when writing.
A topoSetSource to select faces based on the adjacent cell centres spanning a given plane....
planeToFaceZone()=delete
No default construct.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Apply specified action to the topoSet.
faceAction
Enumeration defining the valid options.
@ CLOSEST
Select faces belong to the closest contiguous plane.
@ ALL
Select all faces that meet the criteria.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Mesh consisting of general polyhedral cells.
The topoSetFaceZoneSource is a intermediate class for handling topoSet sources for selecting face zon...
topoSetFaceZoneSource(const polyMesh &mesh)
Construct from mesh.
Class with constructor to add usage string to table.
Base class of a source for a topoSet.
setAction
Enumeration defining various actions.
@ SUBTRACT
Subtract elements from current set.
@ ADD
Add elements to current set.
@ NEW
Create a new set and ADD elements to it.
bool verbose_
Output verbosity (default: true).
const polyMesh & mesh() const noexcept
Reference to the mesh.
const polyMesh & mesh_
Reference to the mesh.
static Istream & checkIs(Istream &is)
Check state of stream.
General set of labels of mesh quantity (points, cells, faces).
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar c
Speed of light in a vacuum.
const std::string patch
OpenFOAM patch number as a std::string.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< labelList > labelListList
List of labelList.
bool read(const char *buf, int32_t &val)
Same as readInt32.
List< label > labelList
A List of labels.
label findMin(const ListType &input, label start=0)
Linear search for the index of the min element, similar to std::min_element but for lists and returns...
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
vectorField pointField
pointField is a vectorField.
dict add("bounds", meshBb)
#define forAll(list, i)
Loop across all elements in list.