36 void Foam::domainDecomposition::mark
45 label pointi = zoneElems[i];
47 if (elementToZone[pointi] == -1)
50 elementToZone[pointi] = zoneI;
52 else if (elementToZone[pointi] >= 0)
55 elementToZone[pointi] = -2;
61 void Foam::domainDecomposition::addInterProcFace
64 const label ownerProc,
66 const label subPatchID,
67 List<Map<label>>& nbrToInterPatch,
68 List<DynamicList<DynamicList<label>>>& interPatchFaces,
69 List<labelListList>& subPatchIDs,
70 List<labelListList>& subPatchStarts
74 label toNbrProcPatchi = -1, toOwnerProcPatchi = -1;
75 if (!nbrToInterPatch[ownerProc].
found(nbrProc))
77 toNbrProcPatchi = nbrToInterPatch[ownerProc].size();
78 nbrToInterPatch[ownerProc].insert(nbrProc, toNbrProcPatchi);
79 interPatchFaces[ownerProc].append(DynamicList<label>());
80 subPatchIDs[ownerProc].append(
labelList(1, subPatchID));
85 toOwnerProcPatchi = nbrToInterPatch[nbrProc].size();
86 nbrToInterPatch[nbrProc].insert(ownerProc, toOwnerProcPatchi);
87 interPatchFaces[nbrProc].append(DynamicList<label>());
88 subPatchIDs[nbrProc].append(
labelList(1, subPatchID));
94 toNbrProcPatchi = nbrToInterPatch[ownerProc][nbrProc];
98 toOwnerProcPatchi = nbrToInterPatch[nbrProc][ownerProc];
103 if (subPatchIDs[ownerProc][toNbrProcPatchi].last() != subPatchID)
105 subPatchIDs[ownerProc][toNbrProcPatchi].append(subPatchID);
106 subPatchStarts[ownerProc][toNbrProcPatchi].append
108 interPatchFaces[ownerProc][toNbrProcPatchi].size()
111 if (facei != -1 &&
completeMesh().isInternalFace(facei))
113 subPatchIDs[nbrProc][toOwnerProcPatchi].append(subPatchID);
114 subPatchStarts[nbrProc][toOwnerProcPatchi].append
116 interPatchFaces[nbrProc][toOwnerProcPatchi].size()
124 interPatchFaces[ownerProc][toNbrProcPatchi].append(facei + 1);
128 interPatchFaces[nbrProc][toOwnerProcPatchi].append(- facei - 1);
136 Info<<
"\nCalculating distribution of cells" <<
endl;
138 cpuTime decompositionTime;
140 const dictionary decomposeParDict =
144 if (decomposeParDict.found(
"weightField"))
146 const word weightName = decomposeParDict.lookup(
"weightField");
160 cellWeights = weights.primitiveField();
170 Info<<
"\nFinished decomposition in " 171 << decompositionTime.elapsedCpuTime()
178 template<
class BinaryOp>
179 inline void Foam::domainDecomposition::processInterCyclics
182 const polyBoundaryMesh& patches,
183 List<DynamicList<DynamicList<label>>>& interPatchFaces,
184 List<Map<label>>& procNbrToInterPatch,
185 List<labelListList>& subPatchIDs,
186 List<labelListList>& subPatchStarts,
194 if (isA<nonConformalCyclicPolyPatch>(patches[patchi]))
196 const nonConformalCyclicPolyPatch& nccPp =
197 refCast<const nonConformalCyclicPolyPatch>(patches[
patchi]);
199 if (nccPp.owner() != owner)
continue;
201 const polyPatch& origPp = nccPp.origPatch();
202 const polyPatch& nbrOrigPp = nccPp.nbrPatch().origPatch();
204 const labelUList& origPatchFaceCells = origPp.faceCells();
205 const labelUList& nbrOrigPatchFaceCells = nbrOrigPp.faceCells();
209 forAll(origPatchFaceCells, origFacei)
211 const label ownerProc =
212 cellToProc[origPatchFaceCells[origFacei]];
214 forAll(nbrOrigPatchFaceCells, nbrOrigFacei)
216 const label nbrProc =
217 cellToProc[nbrOrigPatchFaceCells[nbrOrigFacei]];
219 if (bop(ownerProc, nbrProc))
236 else if (isA<cyclicPolyPatch>(patches[patchi]))
238 const cyclicPolyPatch& cPp =
239 refCast<const cyclicPolyPatch>(patches[
patchi]);
241 if (cPp.owner() != owner)
continue;
243 const labelUList& patchFaceCells = cPp.faceCells();
244 const labelUList& nbrPatchFaceCells = cPp.nbrPatch().faceCells();
247 forAll(patchFaceCells, facei)
249 const label ownerProc = cellToProc[patchFaceCells[facei]];
250 const label nbrProc = cellToProc[nbrPatchFaceCells[facei]];
252 if (bop(ownerProc, nbrProc))
277 const labelList cellToProc = distributeCells();
282 Info<<
"\nCalculating original mesh data" <<
endl;
293 Info<<
"\nDistributing cells to processors" <<
endl;
298 Info<<
"\nDistributing faces to processors" <<
endl;
309 if (cellToProc[owner[facei]] == cellToProc[neighbour[facei]])
312 dynProcFaceAddressing[cellToProc[owner[facei]]].
append(facei+1);
320 forAll(procPatchSize, proci)
323 procPatchStartIndex[proci].
setSize(patches.
size());
330 forAll(procPatchSize, proci)
332 procPatchSize[proci][
patchi] = 0;
333 procPatchStartIndex[proci][
patchi] =
334 dynProcFaceAddressing[proci].
size();
339 if (!isA<cyclicPolyPatch>(patches[patchi]))
346 forAll(patchFaceCells, facei)
348 const label curProc = cellToProc[patchFaceCells[facei]];
351 dynProcFaceAddressing[curProc].
append(patchStart+facei+1);
354 procPatchSize[curProc][
patchi]++;
363 refCast<const cyclicPolyPatch>(patches[
patchi]);
368 forAll(patchFaceCells, facei)
370 const label curProc = cellToProc[patchFaceCells[facei]];
371 const label nbrProc = cellToProc[nbrPatchFaceCells[facei]];
373 if (curProc == nbrProc)
376 dynProcFaceAddressing[curProc].
append(patchStart+facei+1);
379 procPatchSize[curProc][
patchi]++;
401 label ownerProc = cellToProc[owner[facei]];
402 label nbrProc = cellToProc[neighbour[facei]];
404 if (ownerProc != nbrProc)
499 forAll(procNbrToInterPatch, proci)
501 label nInterfaces = procNbrToInterPatch[proci].
size();
503 procNeighbourProcessors[proci].
setSize(nInterfaces);
504 procProcessorPatchSize[proci].
setSize(nInterfaces);
505 procProcessorPatchStartIndex[proci].
setSize(nInterfaces);
506 procProcessorPatchSubPatchIDs[proci].
setSize(nInterfaces);
507 procProcessorPatchSubPatchStarts[proci].
setSize(nInterfaces);
510 const Map<label>& curNbrToInterPatch = procNbrToInterPatch[proci];
516 interPatchFaces[proci];
520 const label nbrProc = nbrs[i];
521 const label interPatch = curNbrToInterPatch[nbrProc];
523 procNeighbourProcessors[proci][i] = nbrProc;
524 procProcessorPatchSize[proci][i] =
525 curInterPatchFaces[interPatch].
size();
526 procProcessorPatchStartIndex[proci][i] =
527 dynProcFaceAddressing[proci].
size();
530 subPatchStarts[proci][interPatch].
append 532 curInterPatchFaces[interPatch].size()
534 procProcessorPatchSubPatchIDs[proci][i].
transfer 536 subPatchIDs[proci][interPatch]
538 procProcessorPatchSubPatchStarts[proci][i].
transfer 540 subPatchStarts[proci][interPatch]
545 curInterPatchFaces[interPatch];
547 forAll(interPatchFaces, j)
549 dynProcFaceAddressing[proci].
append(interPatchFaces[j]);
556 dynProcFaceAddressing[proci].shrink();
560 forAll(dynProcFaceAddressing, proci)
562 procFaceAddressing_[proci].
transfer(dynProcFaceAddressing[proci]);
567 forAll(procPatchStartIndex, proci)
569 Info<<
"Processor:" << proci <<
endl;
570 Info<<
" total faces:" << procFaceAddressing_[proci].
size()
573 const labelList& curProcPatchStartIndex =
574 procPatchStartIndex[proci];
576 forAll(curProcPatchStartIndex, patchi)
578 Info<<
" patch:" << patchi
579 <<
"\tstart:" << curProcPatchStartIndex[
patchi]
580 <<
"\tsize:" << procPatchSize[proci][
patchi]
586 forAll(procNeighbourProcessors, proci)
588 Info<<
"Processor " << proci <<
endl;
589 forAll(procNeighbourProcessors[proci], i)
591 Info<<
" nbr:" << procNeighbourProcessors[proci][i] <<
endl;
592 Info<<
" size:" << procProcessorPatchSize[proci][i] <<
endl;
593 Info<<
" start:" << procProcessorPatchStartIndex[proci][i]
602 forAll(procFaceAddressing_, proci)
604 Info<<
"Processor:" << proci <<
endl;
605 Info<<
" faces:" << procFaceAddressing_[proci] <<
endl;
609 Info<<
"\nDistributing points to processors" <<
endl;
616 forAll(procPointAddressing_, proci)
621 const labelList& procFaceLabels = procFaceAddressing_[proci];
623 forAll(procFaceLabels, facei)
626 const labelList& facePoints = fcs[
mag(procFaceLabels[facei]) - 1];
628 forAll(facePoints, pointi)
631 pointLabels[facePoints[pointi]] =
true;
636 labelList& procPointLabels = procPointAddressing_[proci];
640 label nUsedPoints = 0;
642 forAll(pointLabels, pointi)
644 if (pointLabels[pointi])
646 procPointLabels[nUsedPoints] = pointi;
653 procPointLabels.
setSize(nUsedPoints);
656 Info<<
"\nConstructing processor meshes" <<
endl;
670 mark(
completeMesh().pointZones()[zoneI], zoneI, pointToZone);
677 mark(
completeMesh().faceZones()[zoneI], zoneI, faceToZone);
684 mark(
completeMesh().cellZones()[zoneI], zoneI, cellToZone);
688 label maxProcCells = 0;
689 label totProcFaces = 0;
690 label maxProcPatches = 0;
691 label totProcPatches = 0;
692 label maxProcFaces = 0;
698 const labelList& curPointLabels = procPointAddressing_[proci];
702 forAll(curPointLabels, pointi)
704 procPoints[pointi] = meshPoints[curPointLabels[pointi]];
705 pointLookup[curPointLabels[pointi]] = pointi;
709 const labelList& curFaceLabels = procFaceAddressing_[proci];
713 forAll(curFaceLabels, facei)
717 label curF =
mag(curFaceLabels[facei]) - 1;
719 faceLookup[curF] = facei;
724 if (curFaceLabels[facei] >= 0)
727 origFaceLabels = meshFaces[curF];
731 origFaceLabels = meshFaces[curF].reverseFace();
735 face& procFaceLabels = procFaces[facei];
739 forAll(origFaceLabels, pointi)
741 procFaceLabels[pointi] = pointLookup[origFaceLabels[pointi]];
746 const labelList& curCellLabels = procCellAddressing_[proci];
749 forAll(curCellLabels, celli)
751 const labelList& origCellLabels = meshCells[curCellLabels[celli]];
752 cell& curCell = procCells[celli];
754 forAll(origCellLabels, cellFacei)
756 curCell[cellFacei] = faceLookup[origCellLabels[cellFacei]];
777 fvMesh& procMesh = procMeshes_[proci];
781 const labelList& curPatchSizes = procPatchSize[proci];
782 const labelList& curPatchStarts = procPatchStartIndex[proci];
783 const labelList& curNeighbourProcessors =
784 procNeighbourProcessors[proci];
785 const labelList& curProcessorPatchSizes =
786 procProcessorPatchSize[proci];
787 const labelList& curProcessorPatchStarts =
788 procProcessorPatchStartIndex[proci];
790 procProcessorPatchSubPatchIDs[proci];
792 procProcessorPatchSubPatchStarts[proci];
796 label nInterProcPatches = 0;
797 forAll(curSubPatchIDs, procPatchi)
799 nInterProcPatches += curSubPatchIDs[procPatchi].
size();
803 curPatchSizes.
size() + nInterProcPatches,
810 forAll(curPatchSizes, patchi)
824 ) - 1 - meshPatch.
start(),
832 forAll(curProcessorPatchSizes, procPatchi)
834 const labelList& subPatchID = curSubPatchIDs[procPatchi];
835 const labelList& subStarts = curSubStarts[procPatchi];
837 label curStart = curProcessorPatchStarts[procPatchi];
842 i < subPatchID.
size() - 1
843 ? subStarts[i+1] - subStarts[i]
844 : curProcessorPatchSizes[procPatchi] - subStarts[i];
846 if (subPatchID[i] == -1)
857 curNeighbourProcessors[procPatchi]
862 isA<nonConformalCyclicPolyPatch>
871 refCast<const nonConformalCyclicPolyPatch>
884 curNeighbourProcessors[procPatchi],
899 refCast<const cyclicPolyPatch>
912 curNeighbourProcessors[procPatchi],
919 <<
"Sub patch ID set for non-cyclic patch type" 944 zonePoints[zoneI].setCapacity(pz[zoneI].size()/
nProcs());
949 forAll(curPointLabels, pointi)
951 label curPoint = curPointLabels[pointi];
953 label zoneI = pointToZone[curPoint];
958 zonePoints[zoneI].
append(pointi);
960 else if (zoneI == -2)
965 label index = pz[zoneI].whichPoint(curPoint);
969 zonePoints[zoneI].
append(pointi);
986 zonePoints[zoneI].shrink()
1013 zoneFaces[zoneI].setCapacity(procSize);
1014 zoneFaceFlips[zoneI].setCapacity(procSize);
1020 forAll(curFaceLabels, facei)
1024 label curF =
mag(curFaceLabels[facei]) - 1;
1026 label zoneI = faceToZone[curF];
1031 zoneFaces[zoneI].
append(facei);
1033 label index = fz[zoneI].whichFace(curF);
1035 bool flip = fz[zoneI].flipMap()[index];
1037 if (curFaceLabels[facei] < 0)
1042 zoneFaceFlips[zoneI].append(flip);
1044 else if (zoneI == -2)
1049 label index = fz[zoneI].whichFace(curF);
1053 zoneFaces[zoneI].
append(facei);
1055 bool flip = fz[zoneI].flipMap()[index];
1057 if (curFaceLabels[facei] < 0)
1062 zoneFaceFlips[zoneI].append(flip);
1077 zoneFaces[zoneI].shrink(),
1078 zoneFaceFlips[zoneI].shrink(),
1104 zoneCells[zoneI].setCapacity(cz[zoneI].size()/
nProcs());
1107 forAll(curCellLabels, celli)
1109 label curCelli = curCellLabels[celli];
1111 label zoneI = cellToZone[curCelli];
1116 zoneCells[zoneI].
append(celli);
1118 else if (zoneI == -2)
1123 label index = cz[zoneI].whichCell(curCelli);
1127 zoneCells[zoneI].
append(celli);
1142 zoneCells[zoneI].shrink(),
1159 <<
"Processor " << proci <<
nl 1160 <<
" Number of cells = " << procMesh.
nCells()
1163 maxProcCells =
max(maxProcCells, procMesh.
nCells());
1165 label nBoundaryFaces = 0;
1166 label nProcPatches = 0;
1167 label nProcFaces = 0;
1174 refCast<const processorPolyPatch>
1179 Info<<
" Number of faces shared with processor " 1183 nProcFaces += ppp.size();
1191 Info<<
" Number of processor patches = " << nProcPatches <<
nl 1192 <<
" Number of processor faces = " << nProcFaces <<
nl 1193 <<
" Number of boundary faces = " << nBoundaryFaces <<
endl;
1195 totProcFaces += nProcFaces;
1196 totProcPatches += nProcPatches;
1197 maxProcPatches =
max(maxProcPatches, nProcPatches);
1198 maxProcFaces =
max(maxProcFaces, nProcFaces);
1204 scalar avgProcPatches = scalar(totProcPatches)/
nProcs();
1205 scalar avgProcFaces = scalar(totProcFaces)/
nProcs();
1208 if (totProcPatches == 0)
1212 if (totProcFaces == 0)
1218 <<
"Number of processor faces = " << totProcFaces/2 <<
nl 1219 <<
"Max number of cells = " << maxProcCells
1220 <<
" (" << 100.0*(maxProcCells-avgProcCells)/avgProcCells
1221 <<
"% above average " << avgProcCells <<
")" <<
nl 1222 <<
"Max number of processor patches = " << maxProcPatches
1223 <<
" (" << 100.0*(maxProcPatches-avgProcPatches)/avgProcPatches
1224 <<
"% above average " << avgProcPatches <<
")" <<
nl 1225 <<
"Max number of faces between processors = " << maxProcFaces
1226 <<
" (" << 100.0*(maxProcFaces-avgProcFaces)/avgProcFaces
1227 <<
"% above average " << avgProcFaces <<
")" <<
nl
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Neighbour processor patch.
void append(T *)
Append an element at the end of the list.
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
bool set(const label) const
Is element set.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
labelList pointLabels(nPoints, -1)
const meshCellZones & cellZones() const
Return cell zones.
void addFvPatches(const List< polyPatch *> &, const bool validBoundary=true)
Add boundary patches. Constructor helper.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void setPointsInstance(const fileName &)
Set the instance for the points files.
const cellList & cells() const
const PtrList< Time > & procTimes() const
Access the processor run times.
const cyclicPolyPatch & nbrPatch() const
UList< label > labelUList
const meshPointZones & pointZones() const
Return point zones.
Neighbour processor patch.
virtual const pointField & points() const
Return raw points.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
void decompose()
Decompose the complete mesh to create the processor meshes and.
A List obtained as a section of another List.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
const labelUList & faceCells() const
Return face-cell addressing.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void append(const T &)
Append an element at the end of the list.
virtual const labelList & faceOwner() const
Return face owner.
static autoPtr< decompositionMethod > NewDecomposer(const dictionary &decompositionDict)
Return a reference to the selected decomposition method.
List< label > labelList
A List of labels.
virtual const faceList & faces() const
Return raw faces.
int neighbProcNo() const
Return neighbour processor number.
static dictionary decomposeParDict(const Time &time)
Read and return the decomposeParDict.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of List.
writeOption writeOpt() const
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
A cell is defined as a list of faces with extra functionality.
const meshFaceZones & faceZones() const
Return face zones.
Mesh data needed to do the Finite Volume discretisation.
label start() const
Return start label of this patch in the polyMesh face list.
void clearStorage()
Clear the list and delete storage.
dimensioned< scalar > mag(const dimensioned< Type > &)
List< Key > toc() const
Return the table of contents.
A patch is a list of labels that address the faces in the global face list.
const fvMesh & completeMesh() const
Access the global mesh.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void clearAddressing()
Clear addressing.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
const Time & completeTime() const
Access the complete run time.
label nProcs() const
Return the number of processors in the decomposition.