48 void Foam::domainDecomposition::mark
55 for (
const label pointi : zoneElems)
57 if (elementToZone[pointi] == -1)
60 elementToZone[pointi] = zoneI;
62 else if (elementToZone[pointi] >= 0)
65 elementToZone[pointi] = -2;
76 const fileName& decompDictFile
80 facesInstancePointsPtr_
82 pointsInstance() != facesInstance()
98 decompDictFile_(decompDictFile),
101 decompositionMethod::nDomains
103 decompositionModel::
New
111 cellToProc_(nCells()),
112 procPointAddressing_(nProcs_),
113 procFaceAddressing_(nProcs_),
114 procCellAddressing_(nProcs_),
115 procPatchSize_(nProcs_),
116 procPatchStartIndex_(nProcs_),
117 procNeighbourProcessors_(nProcs_),
118 procProcessorPatchSize_(nProcs_),
119 procProcessorPatchStartIndex_(nProcs_),
120 procProcessorPatchSubPatchIDs_(nProcs_),
121 procProcessorPatchSubPatchStarts_(nProcs_)
123 updateParameters(this->model());
137 const dictionary& params
140 params.readIfPresent(
"distributed", distributed_);
146 Info<<
"\nConstructing processor meshes" <<
endl;
159 forAll(pointZones(), zonei)
161 mark(pointZones()[zonei], zonei, pointToZone);
165 labelList faceToZone(faces().size(), -1);
167 forAll(faceZones(), zonei)
169 mark(faceZones()[zonei], zonei, faceToZone);
175 forAll(cellZones(), zonei)
177 mark(cellZones()[zonei], zonei, cellToZone);
181 PtrList<const cellSet> cellSets;
182 PtrList<const faceSet> faceSets;
183 PtrList<const pointSet> pointSets;
187 IOobjectList objects(*
this, facesInstance(),
"polyMesh/sets");
189 IOobjectList cSets(objects.lookupClass(cellSet::typeName));
192 cellSets.append(
new cellSet(*iter()));
196 IOobjectList fSets(objects.lookupClass(faceSet::typeName));
199 faceSets.append(
new faceSet(*iter()));
203 IOobjectList pSets(objects.lookupClass(pointSet::typeName));
206 pointSets.append(
new pointSet(*iter()));
213 hexRef8Data baseMeshData
229 label maxProcCells = 0;
230 label totProcFaces = 0;
231 label maxProcPatches = 0;
232 label totProcPatches = 0;
233 label maxProcFaces = 0;
237 for (label proci = 0; proci < nProcs_; proci++)
240 const labelList& curPointLabels = procPointAddressing_[proci];
248 forAll(curPointLabels, pointi)
250 procPoints[pointi] = meshPoints[curPointLabels[pointi]];
252 pointLookup[curPointLabels[pointi]] = pointi;
256 const labelList& curFaceLabels = procFaceAddressing_[proci];
258 const faceList& meshFaces = faces();
262 faceList procFaces(curFaceLabels.size());
264 forAll(curFaceLabels, facei)
269 label curF =
mag(curFaceLabels[facei]) - 1;
271 faceLookup[curF] = facei;
276 if (curFaceLabels[facei] >= 0)
279 origFaceLabels = meshFaces[curF];
283 origFaceLabels = meshFaces[curF].reverseFace();
287 face& procFaceLabels = procFaces[facei];
289 procFaceLabels.
setSize(origFaceLabels.size());
291 forAll(origFaceLabels, pointi)
293 procFaceLabels[pointi] = pointLookup[origFaceLabels[pointi]];
298 const labelList& curCellLabels = procCellAddressing_[proci];
302 cellList procCells(curCellLabels.size());
304 forAll(curCellLabels, celli)
306 const labelList& origCellLabels = meshCells[curCellLabels[celli]];
308 cell& curCell = procCells[celli];
310 curCell.
setSize(origCellLabels.size());
312 forAll(origCellLabels, cellFacei)
314 curCell[cellFacei] = faceLookup[origCellLabels[cellFacei]];
320 fileName processorCasePath
322 time().caseName()/(
"processor" +
Foam::name(proci))
334 processorDb.setTime(time());
346 autoPtr<polyMesh> procMeshPtr;
348 if (facesInstancePointsPtr_)
353 facesInstancePointsPtr_(),
367 std::move(facesInstancePoints),
368 std::move(procFaces),
384 std::move(procPoints),
385 std::move(procFaces),
389 polyMesh& procMesh = procMeshPtr();
393 const labelList& curPatchSizes = procPatchSize_[proci];
395 const labelList& curPatchStarts = procPatchStartIndex_[proci];
397 const labelList& curNeighbourProcessors =
398 procNeighbourProcessors_[proci];
400 const labelList& curProcessorPatchSizes =
401 procProcessorPatchSize_[proci];
403 const labelList& curProcessorPatchStarts =
404 procProcessorPatchStartIndex_[proci];
407 procProcessorPatchSubPatchIDs_[proci];
410 procProcessorPatchSubPatchStarts_[proci];
416 label nInterProcPatches = 0;
417 forAll(curSubPatchIDs, procPatchi)
419 nInterProcPatches += curSubPatchIDs[procPatchi].size();
422 PtrList<polyPatch> procPatches
424 curPatchSizes.size() + nInterProcPatches
429 forAll(curPatchSizes, patchi)
433 const polyPatch& meshPatch = meshPatches[patchi];
435 fvFieldDecomposer::patchFieldDecomposer patchMapper
440 curPatchSizes[patchi],
441 curPatchStarts[patchi]
452 procMesh.boundaryMesh(),
454 patchMapper.directAddressing(),
455 curPatchStarts[patchi]
462 forAll(curProcessorPatchSizes, procPatchi)
464 const labelList& subPatchID = curSubPatchIDs[procPatchi];
465 const labelList& subStarts = curSubStarts[procPatchi];
467 label curStart = curProcessorPatchStarts[procPatchi];
473 i < subPatchID.size()-1
474 ? subStarts[i+1] - subStarts[i]
475 : curProcessorPatchSizes[procPatchi] - subStarts[i]
478 if (subPatchID[i] == -1)
484 new processorPolyPatch
489 procMesh.boundaryMesh(),
491 curNeighbourProcessors[procPatchi]
497 const coupledPolyPatch& pcPatch
498 = refCast<const coupledPolyPatch>
500 boundaryMesh()[subPatchID[i]]
506 new processorCyclicPolyPatch
511 procMesh.boundaryMesh(),
513 curNeighbourProcessors[procPatchi],
526 procMesh.addPatches(procPatches);
537 List<DynamicList<label>> zonePoints(pz.size());
542 zonePoints[zonei].setCapacity(pz[zonei].size()/nProcs_);
547 forAll(curPointLabels, pointi)
549 label curPoint = curPointLabels[pointi];
551 label zonei = pointToZone[curPoint];
556 zonePoints[zonei].append(pointi);
558 else if (zonei == -2)
563 label index = pz[zonei].whichPoint(curPoint);
567 zonePoints[zonei].append(pointi);
573 procMesh.pointZones().clearAddressing();
574 procMesh.pointZones().setSize(zonePoints.size());
577 procMesh.pointZones().set
582 procMesh.pointZones(),
584 zonePoints[zonei].shrink()
603 List<DynamicList<label>> zoneFaces(fz.size());
604 List<DynamicList<bool>> zoneFaceFlips(fz.size());
609 label procSize = fz[zonei].size() / nProcs_;
611 zoneFaces[zonei].setCapacity(procSize);
612 zoneFaceFlips[zonei].setCapacity(procSize);
618 forAll(curFaceLabels, facei)
622 label curF =
mag(curFaceLabels[facei]) - 1;
624 label zonei = faceToZone[curF];
629 zoneFaces[zonei].append(facei);
631 label index = fz[zonei].whichFace(curF);
633 bool flip = fz[zonei].flipMap()[index];
635 if (curFaceLabels[facei] < 0)
640 zoneFaceFlips[zonei].append(flip);
642 else if (zonei == -2)
647 label index = fz[zonei].whichFace(curF);
651 zoneFaces[zonei].append(facei);
653 bool flip = fz[zonei].flipMap()[index];
655 if (curFaceLabels[facei] < 0)
660 zoneFaceFlips[zonei].append(flip);
666 procMesh.faceZones().clearAddressing();
667 procMesh.faceZones().setSize(zoneFaces.size());
670 procMesh.faceZones().set
675 zoneFaces[zonei].shrink(),
676 zoneFaceFlips[zonei].shrink(),
697 List<DynamicList<label>> zoneCells(cz.size());
702 zoneCells[zonei].setCapacity(cz[zonei].size()/nProcs_);
705 forAll(curCellLabels, celli)
707 label curCelli = curCellLabels[celli];
709 label zonei = cellToZone[curCelli];
714 zoneCells[zonei].append(celli);
716 else if (zonei == -2)
721 label index = cz[zonei].whichCell(curCelli);
725 zoneCells[zonei].append(celli);
731 procMesh.cellZones().clearAddressing();
732 procMesh.cellZones().setSize(zoneCells.size());
735 procMesh.cellZones().set
740 zoneCells[zonei].shrink(),
760 if (facesInstancePointsPtr_)
774 std::move(procPoints)
776 pointsInstancePoints.write();
785 const cellSet& cs = cellSets[i];
786 cellSet
set(procMesh, cs.name(), cs.size()/nProcs_);
789 if (cs.found(curCellLabels[i]))
798 const faceSet& cs = faceSets[i];
799 faceSet
set(procMesh, cs.name(), cs.size()/nProcs_);
802 if (cs.found(
mag(curFaceLabels[i])-1))
811 const pointSet& cs = pointSets[i];
812 pointSet
set(procMesh, cs.name(), cs.size()/nProcs_);
815 if (cs.found(curPointLabels[i]))
839 procCellAddressing_[proci],
840 procPointAddressing_[proci]
845 Info<<
nl <<
"Processor " << proci;
847 if (procMesh.nCells())
856 Info<<
"Number of cells = " << procMesh.nCells() <<
nl;
858 maxProcCells =
max(maxProcCells, procMesh.nCells());
860 label nBoundaryFaces = 0;
862 label nProcFaces = 0;
864 forAll(procMesh.boundaryMesh(), patchi)
866 if (isA<processorPolyPatch>(procMesh.boundaryMesh()[patchi]))
868 const processorPolyPatch& ppp =
869 refCast<const processorPolyPatch>
871 procMesh.boundaryMesh()[patchi]
874 Info<<
" Number of faces shared with processor "
875 << ppp.neighbProcNo() <<
" = " << ppp.size() <<
endl;
878 nProcFaces += ppp.size();
882 nBoundaryFaces += procMesh.boundaryMesh()[patchi].size();
886 if (procMesh.nCells() && (nBoundaryFaces || nProcFaces))
889 <<
" Number of processor faces = " << nProcFaces <<
nl
890 <<
" Number of boundary faces = " << nBoundaryFaces <<
nl;
893 totProcFaces += nProcFaces;
896 maxProcFaces =
max(maxProcFaces, nProcFaces);
903 "pointProcAddressing",
904 procMesh.facesInstance(),
910 procPointAddressing_[proci]
912 pointProcAddressing.write();
918 "faceProcAddressing",
919 procMesh.facesInstance(),
925 procFaceAddressing_[proci]
933 "cellProcAddressing",
934 procMesh.facesInstance(),
940 procCellAddressing_[proci]
942 cellProcAddressing.write();
946 label nMeshPatches = curPatchSizes.size();
948 procBoundaryAddressing.setSize(nMeshPatches+
nProcPatches, -1);
954 "boundaryProcAddressing",
955 procMesh.facesInstance(),
961 procBoundaryAddressing
963 boundaryProcAddressing.write();
966 scalar avgProcCells = scalar(nCells())/nProcs_;
967 scalar avgProcPatches = scalar(totProcPatches)/nProcs_;
968 scalar avgProcFaces = scalar(totProcFaces)/nProcs_;
971 if (totProcPatches == 0)
975 if (totProcFaces == 0)
981 <<
"Number of processor faces = " << totProcFaces/2 <<
nl
982 <<
"Max number of cells = " << maxProcCells
983 <<
" (" << 100.0*(maxProcCells-avgProcCells)/avgProcCells
984 <<
"% above average " << avgProcCells <<
")" <<
nl
985 <<
"Max number of processor patches = " << maxProcPatches
986 <<
" (" << 100.0*(maxProcPatches-avgProcPatches)/avgProcPatches
987 <<
"% above average " << avgProcPatches <<
")" <<
nl
988 <<
"Max number of faces between processors = " << maxProcFaces
989 <<
" (" << 100.0*(maxProcFaces-avgProcFaces)/avgProcFaces
990 <<
"% above average " << avgProcFaces <<
")" <<
nl