44 void Foam::regionSplit::transferCoupledFaceRegion
47 const label otherFacei,
50 DynamicList<label>& newChangedFaces
53 if (faceRegion[facei] >= 0)
55 if (faceRegion[otherFacei] == -1)
57 faceRegion[otherFacei] = faceRegion[facei];
58 newChangedFaces.append(otherFacei);
60 else if (faceRegion[otherFacei] == -2)
65 else if (faceRegion[otherFacei] != faceRegion[facei])
68 <<
"Problem : coupled face " << facei
70 <<
" has region " << faceRegion[facei]
71 <<
" but coupled face " << otherFacei
72 <<
" has region " << faceRegion[otherFacei]
74 <<
"Is your blocked faces specification" 75 <<
" synchronized across coupled boundaries?" 79 else if (faceRegion[facei] == -1)
81 if (faceRegion[otherFacei] >= 0)
83 faceRegion[facei] = faceRegion[otherFacei];
84 newChangedFaces.append(facei);
86 else if (faceRegion[otherFacei] == -2)
95 void Foam::regionSplit::fillSeedMask
97 const List<labelPair>& explicitConnections,
100 const label seedCellID,
101 const label markValue
105 cellRegion[seedCellID] = markValue;
109 const cell& cFaces =
mesh().
cells()[seedCellID];
117 label facei = cFaces[i];
119 if (faceRegion[facei] == -1)
121 faceRegion[facei] = markValue;
122 changedFaces[nFaces++] = facei;
125 changedFaces.setSize(nFaces);
130 while (changedFaces.size())
138 DynamicList<label> changedCells(changedFaces.size());
142 label facei = changedFaces[i];
146 if (cellRegion[own] == -1)
148 cellRegion[own] = markValue;
152 if (
mesh().isInternalFace(facei))
156 if (cellRegion[nei] == -1)
158 cellRegion[nei] = markValue;
172 DynamicList<label> newChangedFaces(changedCells.size());
176 label celli = changedCells[i];
178 const cell& cFaces =
mesh().
cells()[celli];
182 label facei = cFaces[cFacei];
184 if (faceRegion[facei] == -1)
186 faceRegion[facei] = markValue;
187 newChangedFaces.append(facei);
207 const polyPatch& pp = patches[
patchi];
211 isA<cyclicPolyPatch>(pp)
212 && refCast<const cyclicPolyPatch>(pp).owner()
217 const cyclicPolyPatch& cycPatch =
218 refCast<const cyclicPolyPatch>(pp);
220 label facei = cycPatch.start();
224 label otherFacei = cycPatch.transformGlobalFace(facei);
226 transferCoupledFaceRegion
238 forAll(explicitConnections, i)
240 transferCoupledFaceRegion
242 explicitConnections[i][0],
243 explicitConnections[i][1],
255 changedFaces.transfer(newChangedFaces);
260 Foam::label Foam::regionSplit::calcLocalRegionSplit
263 const List<labelPair>& explicitConnections,
270 if (blockedFace.size())
273 boolList syncBlockedFace(blockedFace);
276 forAll(syncBlockedFace, facei)
278 if (syncBlockedFace[facei] != blockedFace[facei])
281 <<
"Face " << facei <<
" not synchronised. My value:" 282 << blockedFace[facei] <<
" coupled value:" 283 << syncBlockedFace[facei]
295 if (blockedFace.size())
297 forAll(blockedFace, facei)
299 if (blockedFace[facei])
301 faceRegion[facei] = -2;
311 label nLocalRegions = 0;
313 label unsetCelli = 0;
319 for (; unsetCelli <
mesh().
nCells(); unsetCelli++)
321 if (cellRegion[unsetCelli] == -1)
352 if (cellRegion[celli] < 0)
355 <<
"cell:" << celli <<
" region:" << cellRegion[celli]
362 if (faceRegion[facei] == -1)
365 <<
"face:" << facei <<
" region:" << faceRegion[facei]
371 return nLocalRegions;
377 const bool doGlobalRegions,
379 const List<labelPair>& explicitConnections,
387 label nLocalRegions = calcLocalRegionSplit
394 if (!doGlobalRegions)
396 return autoPtr<globalIndex>(
new globalIndex(nLocalRegions));
404 globalIndex globalRegions(nLocalRegions);
410 cellRegion[celli] = globalRegions.toGlobal(cellRegion[celli]);
425 Pout<<
nl <<
"-- Starting Iteration --" <<
endl;
434 const polyPatch& pp = patches[
patchi];
438 const labelList& patchCells = pp.faceCells();
439 SubList<label> patchNbrRegion
448 label facei = pp.start()+i;
449 if (!blockedFace.size() || !blockedFace[facei])
451 patchNbrRegion[i] = cellRegion[patchCells[i]];
458 Map<label> globalToMerged(
mesh().nFaces()-
mesh().nInternalFaces());
462 const polyPatch& pp = patches[
patchi];
466 const labelList& patchCells = pp.faceCells();
467 SubList<label> patchNbrRegion
476 label facei = pp.start()+i;
478 if (!blockedFace.size() || !blockedFace[facei])
480 if (patchNbrRegion[i] < cellRegion[patchCells[i]])
490 globalToMerged.insert
492 cellRegion[patchCells[i]],
506 Pout<<
"nMerged:" << nMerged <<
endl;
517 label regionI = cellRegion[celli];
519 if (iter != globalToMerged.end())
521 cellRegion[celli] = iter();
538 globalRegions.isLocal(cellRegion[celli])
539 && localRegion.insert(cellRegion[celli])
549 Pout<<
"Compacted from " << nLocalRegions
550 <<
" down to " << nCompact <<
" local regions." <<
endl;
555 autoPtr<globalIndex> globalCompactPtr(
new globalIndex(nCompact));
556 const globalIndex& globalCompact = globalCompactPtr();
566 Map<label> globalToCompact(2*nCompact);
576 label region = cellRegion[celli];
577 if (globalRegions.isLocal(region))
580 if (iter == globalToCompact.end())
582 label compactRegion = globalCompact.toGlobal
584 globalToCompact.size()
586 globalToCompact.insert(region, compactRegion);
591 nonLocal[globalRegions.whichProcID(region)].insert(region);
602 forAll(sendNonLocal, proci)
604 sendNonLocal[proci].setSize(nonLocal[proci].size());
607 sendNonLocal[proci][nNonLocal[proci]++] = iter.key();
615 Pout<<
" from processor " << proci
616 <<
" want " << nNonLocal[proci]
617 <<
" region numbers." 626 Pstream::exchange<labelList, label>(sendNonLocal, recvNonLocal);
633 forAll(recvNonLocal, proci)
635 const labelList& nonLocal = recvNonLocal[proci];
636 sendWantedLocal[proci].
setSize(nonLocal.size());
640 sendWantedLocal[proci][i] = globalToCompact[nonLocal[i]];
646 recvNonLocal.clear();
647 Pstream::exchange<labelList, label>(sendWantedLocal, recvNonLocal);
648 sendWantedLocal.clear();
654 forAll(recvNonLocal, proci)
656 const labelList& wantedRegions = sendNonLocal[proci];
657 const labelList& compactRegions = recvNonLocal[proci];
661 globalToCompact.insert(wantedRegions[i], compactRegions[i]);
668 cellRegion[celli] = globalToCompact[cellRegion[celli]];
671 return globalCompactPtr;
682 globalNumberingPtr_ = calcRegionSplit
696 const bool doGlobalRegions
702 globalNumberingPtr_ = calcRegionSplit
717 const bool doGlobalRegions
723 globalNumberingPtr_ = calcRegionSplit
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
List< labelList > labelListList
A List of labelList.
#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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Ostream & endl(Ostream &os)
Add newline and flush stream.
HashTable< label, label, Hash< label > >::const_iterator const_iterator
const cellList & cells() const
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
List< bool > boolList
Bool container classes.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
void append(const T &)
Append an element at the end of the list.
List< label > labelList
A List of labels.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
prefixOSstream Pout(cout,"Pout")
defineTypeNameAndDebug(combustionModel, 0)
regionSplit(const polyMesh &, const bool doGlobalRegions=Pstream::parRun())
Construct from mesh.
void setSize(const label)
Reset size of List.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
virtual const labelList & faceNeighbour() const
Return face neighbour.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
label nInternalFaces() const
const polyMesh & mesh() const