50 topoSetFaceZoneSource,
57 topoSetFaceZoneSource,
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 " 78 Foam::planeToFaceZone::faceActionNames_
80 { faceAction::ALL,
"all" },
81 { faceAction::CLOSEST,
"closest" },
87 void Foam::planeToFaceZone::combine(faceZoneSet& fzSet,
const bool add)
const 95 cellIsAbovePlane.set(celli);
109 faceIsOnPlane.set(facei);
117 const label facei =
patch.start() + patchFacei;
120 faceIsOnPlane.set(facei);
127 labelList newSetFaces(faceIsOnPlane.sortedToc());
128 faceIsOnPlane.
clear();
132 if (option_ == faceAction::CLOSEST)
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];
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];
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];
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);
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);
362 fzSet.addressing().transfer(newAddressing);
363 fzSet.flipMap().transfer(newFlipMap);
373 const point& basePoint,
375 const faceAction action
394 option_(faceActionNames_.getOrDefault(
"option",
dict,
faceAction::ALL))
406 normal_(checkIs(is)),
407 option_(faceActionNames_.
read(checkIs(is)))
419 if (!isA<faceZoneSet>(
set))
422 <<
"Operation only allowed on a faceZoneSet." <<
endl;
426 faceZoneSet& zoneSet = refCast<faceZoneSet>(
set);
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;
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
static void listCombineGather(UList< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const labelListList & faceEdges() const
virtual const labelList & faceNeighbour() const
Return face neighbour.
planeToFaceZone()=delete
No default construct.
Create a new set and ADD elements to it.
Add elements to current set.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Ostream & endl(Ostream &os)
Add newline and flush stream.
const cellList & cells() const
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
label nFaces() const noexcept
Number of mesh faces.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
List< labelList > labelListList
List of labelList.
Macros for easy insertion into run-time selection tables.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
bool read(const char *buf, int32_t &val)
Same as readInt32.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
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...
AccessType combine(const UList< T > &lists, AccessOp aop=accessOp< T >())
Combines sub-lists into a single list.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
vectorField pointField
pointField is a vectorField.
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...
void clear()
Clear the list, i.e. set size to zero.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
setAction
Enumeration defining various actions.
virtual const labelList & faceOwner() const
Return face owner.
virtual const faceList & faces() const
Return raw faces.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const vectorField & cellCentres() const
label nEdges() const
Number of mesh edges.
const polyMesh & mesh_
Reference to the mesh.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
const vectorField & faceCentres() const
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual linear/tree communicat...
Subtract elements from current set.
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Class with constructor to add usage string to table.
label nCells() const noexcept
Number of mesh cells.
const vectorField & faceAreas() const
const dimensionedScalar c
Speed of light in a vacuum.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
faceAction
Enumeration defining the valid options.
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
The topoSetFaceZoneSource is a intermediate class for handling topoSet sources for selecting face zon...
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Apply specified action to the topoSet.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements. After completion all processors have the same data.
static constexpr const zero Zero
Global zero (0)