44static constexpr Foam::label
BLOCKED = -2;
53template<
class Container>
56 const label len = input.
size();
60 for (label i = 0; i < len; ++i)
62 output[i] = input[i].
size();
73void Foam::regionSplit::checkBoundaryFaceSync
75 const boolList& blockedFace
78 if (blockedFace.size())
81 boolList syncBlockedFace(blockedFace);
84 forAll(syncBlockedFace, facei)
88 blockedFace.test(facei)
89 != syncBlockedFace.test(facei)
93 <<
"Face " << facei <<
" not synchronised. My value:"
94 << blockedFace.test(facei) <<
" coupled value:"
95 << syncBlockedFace.test(facei) <<
nl
103void Foam::regionSplit::updateFacePair
114 if (faceRegion[face1] >= 0)
116 faceRegion[face0] = faceRegion[face1];
117 facesChanged.append(face0);
119 else if (faceRegion[face1] ==
BLOCKED)
125 else if (faceRegion[face0] >= 0)
129 faceRegion[face1] = faceRegion[face0];
130 facesChanged.append(face1);
132 else if (faceRegion[face1] ==
BLOCKED)
137 else if (faceRegion[face1] != faceRegion[face0])
140 <<
"Problem : coupled face " << face0
142 <<
" has region " << faceRegion[face0]
143 <<
" but coupled face " << face1
144 <<
" has region " << faceRegion[face1] <<
nl
145 <<
"Is your blocked faces specification"
146 <<
" synchronized across coupled boundaries?" <<
endl
153void Foam::regionSplit::fillSeedMask
156 const label seedCellId,
157 const label markValue,
163 cellRegion[seedCellId] = markValue;
166 changedFaces_.clear();
167 for (
const label facei :
mesh().
cells()[seedCellId])
171 faceRegion[facei] = markValue;
172 changedFaces_.append(facei);
180 while (changedFaces_.size())
182 changedCells_.clear();
184 for (
const label facei : changedFaces_)
190 cellRegion[own] = markValue;
191 changedCells_.append(own);
194 if (
mesh().isInternalFace(facei))
200 cellRegion[nei] = markValue;
201 changedCells_.append(nei);
208 Pout<<
" Changed cells / faces : "
209 << changedCells_.size() <<
" / " << changedFaces_.size()
210 <<
" before sync" <<
endl;
214 changedFaces_.clear();
215 for (
const label celli : changedCells_)
217 for (
const label facei :
mesh().
cells()[celli])
221 faceRegion[facei] = markValue;
222 changedFaces_.append(facei);
235 if (cpp && cpp->owner())
238 const auto& cycPatch = *cpp;
240 label face0 = cycPatch.start();
244 const label face1 = cycPatch.transformGlobalFace(face0);
259 for (
const labelPair& pr : explicitConnections)
272 Pout<<
" Changed faces : "
273 << changedFaces_.size()
274 <<
" after sync" <<
endl;
280Foam::label Foam::regionSplit::localRegionSplit
290 changedCells_.reserve(mesh_.nCells());
291 changedFaces_.reserve(mesh_.nFaces());
298 label nLocalRegions = 0;
300 for (label seedCellId = 0; seedCellId < cellRegion.size(); ++seedCellId)
304 for (; seedCellId < cellRegion.size(); ++seedCellId)
312 if (seedCellId >= cellRegion.size())
330 changedCells_.clearStorage();
331 changedFaces_.clearStorage();
337 if (cellRegion[celli] < 0)
340 <<
"cell:" << celli <<
" region:" << cellRegion[celli]
350 <<
"face:" << facei <<
" region:" << faceRegion[facei]
356 DebugInfo <<
"regionSplit = " << double(timing.elapsed()) <<
"s\n";
358 return nLocalRegions;
367 const bool doGlobalRegions
383 const bitSet& blockedFace,
385 const bool doGlobalRegions
388 MeshObject_type(
mesh),
401 for (
const label facei : blockedFace)
406 const label numLocalRegions =
407 localRegionSplit(explicitConnections, cellRegion, faceRegion);
414 bitSetOrBoolList hasBlockedFace(blockedFace);
417 reduceRegionsImpl(numLocalRegions, hasBlockedFace, cellRegion);
429 const polyMesh&
mesh,
431 const List<labelPair>& explicitConnections,
432 const bool doGlobalRegions
435 MeshObject_type(
mesh),
441 checkBoundaryFaceSync(blockedFace);
448 forAll(blockedFace, facei)
450 if (blockedFace.test(facei))
457 const label numLocalRegions =
458 localRegionSplit(explicitConnections, cellRegion, faceRegion);
465 bitSetOrBoolList hasBlockedFace(blockedFace);
468 reduceRegionsImpl(numLocalRegions, hasBlockedFace, cellRegion);
472 globalNumbering_ = globalIndex(numLocalRegions);
480Foam::regionSplit::reduceRegionsImpl
482 const label numLocalRegions,
483 const bitSetOrBoolList& blockedFace,
489 if (cellRegion.size() !=
mesh().nCells())
492 <<
"The cellRegion size " << cellRegion.size()
501 const label nLocalRegions =
517 for (
const label regioni : cellRegion)
519 localToGlobal.insert(regioni, globalRegions.toGlobal(regioni));
550 bool emitWarning =
true;
556 Pout<<
nl <<
"-- Starting Iteration --" <<
endl;
559 updateLookup.clear();
577 const label celli =
faceCells[patchFacei];
578 const label meshFacei =
pp.start()+patchFacei;
580 if (!blockedFace.test(meshFacei))
583 const label orig = cellRegion[celli];
585 patchNbrRegion[patchFacei] = localToGlobal[orig];
607 const label celli =
faceCells[patchFacei];
608 const label meshFacei =
pp.start()+patchFacei;
610 if (!blockedFace.test(meshFacei))
614 const label orig = cellRegion[celli];
616 const label sent = localToGlobal[orig];
617 const label recv = patchNbrRegion[patchFacei];
623 Pout<<
"Warning in regionSplit:"
624 " received unassigned on "
625 <<
pp.name() <<
" at patchFace "
627 <<
". Check synchronisation in caller"
631 else if (recv < sent)
635 auto fnd = updateLookup.find(sent);
638 updateLookup.insert(sent, recv);
640 else if (recv < *fnd)
662 labelList keys(localToGlobal.sortedToc());
666 vals[i] = localToGlobal[keys[i]];
669 Pout<<
"Updated local regions:" <<
nl
675 Pout<<
"Updated " << localToGlobal.size()
676 <<
" local regions" <<
endl;
696 const label regioni = iter.val();
698 if (globalRegions.isLocal(regioni))
700 localRegion.insert(regioni);
704 nCompact = localRegion.size();
719 updateLookup.clear();
733 nonLocal[proci].reserve(estimatedCount);
740 const label regioni = iter.val();
742 if (globalRegions.isLocal(regioni))
747 globalCompact.toGlobal(updateLookup.size())
752 nonLocal[globalRegions.whichProcID(regioni)].insert(regioni);
758 Pout<<
" per processor nonLocal regions: "
764 forAll(sendNonLocal, proci)
766 sendNonLocal[proci] = nonLocal[proci].toc();
788 for (label& regioni : send)
790 regioni = updateLookup[regioni];
809 forAll(recvNonLocal, proci)
811 const labelList& send = sendNonLocal[proci];
812 const labelList& recv = recvNonLocal[proci];
816 updateLookup.insert(send[i], recv[i]);
829 cellRegion[celli] = localToGlobal[cellRegion[celli]];
833 <<
"regionSplit::reduceRegions = " << double(timing.elapsed()) <<
"s\n";
835 return globalCompact;
842 const label numLocalRegions,
843 const bitSet& blockedFace,
849 bitSetOrBoolList hasBlockedFace(blockedFace);
851 return reduceRegionsImpl(numLocalRegions, hasBlockedFace, cellRegion);
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
label size() const noexcept
The number of elements in table.
label size() const noexcept
The number of elements in the list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void clear()
Clear the list, i.e. set size to zero.
A HashTable to objects of type <T> with a label key.
const polyMesh & mesh() const noexcept
static void exchange(const UList< Container > &sendBufs, const labelUList &recvSizes, List< Container > &recvBufs, const int tag=UPstream::msgType(), const int comm=UPstream::worldComm, const bool wait=true)
Helper: exchange contiguous data. Sends sendBufs, receives into recvBufs using predetermined receive ...
A non-owning sub-view of a List (allocated or unallocated storage).
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool test(const label i) const
Test bool value at specified position, always false for out-of-range access.
void size(const label n)
Older name for setAddressableSize.
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 label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Access to high-resolution clock value with some basic operations. Used to calculate time durations,...
Smooth ATC in cells next to a set of patches supplied by type.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A patch is a list of labels that address the faces in the global face list.
label nCells() const noexcept
Number of mesh cells.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
globalIndex reduceRegions(const label numLocalRegions, const bitSet &blockedFace, labelList &cellRegion) const
Manually consolidate regions globally by swapping information.
regionSplit(const polyMesh &mesh, const bool doGlobalRegions=Pstream::parRun())
Construct from mesh.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
Namespace for handling debugging switches.
Pair< label > labelPair
A pair of labels.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
label inplaceMapValue(const labelUList &oldToNew, Container &input)
Map values. Ignore negative values.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
errorManip< error > abort(error &err)
List< bool > boolList
A List of bools.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
UList< label > labelUList
A UList of labels.
static labelList containerSizes(const UList< Container > &input)
The sizes of a List of containers (eg, labelHashSet).
constexpr char nl
The newline '\n' character (0x0a).
static constexpr Foam::label UNASSIGNED
static constexpr Foam::label BLOCKED
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.