51 void Foam::multiLevelDecomp::createMethodsDict()
73 nTotal = (domains.empty() ? 0 : 1);
75 for (
const label
n : domains)
98 domains.setSize(old.size()+1);
103 domains[i+1] = old[i];
105 nTotal *= domains[0];
107 Info<<
" inferred level0 with " << domains[0]
108 <<
" domains" <<
nl <<
nl;
111 if (!nLevels || nTotal !=
nDomains())
114 <<
"Top level decomposition specifies " <<
nDomains()
115 <<
" domains which is not equal to the product of"
116 <<
" all sub domains " << nTotal
124 const dictionary& subMethodCoeffsDict
129 defaultMethod +
"Coeffs",
130 selectionType::NULL_DICT
134 for (
const label
n : domains)
136 const word levelName(
"level" +
Foam::name(nLevels++));
138 entry* dictptr = methodsDict_.set(levelName, dictionary());
140 dictionary&
dict = dictptr->dict();
141 dict.add(
"method", defaultMethod);
142 dict.add(
"numberOfSubdomains",
n);
145 if (subMethodCoeffsDict.size())
147 dict.add(subMethodCoeffsDict.dictName(), subMethodCoeffsDict);
159 for (
const entry& dEntry : coeffsDict_)
172 const bool addDefaultMethod
175 && !defaultMethod.empty()
178 entry*
e = methodsDict_.add(dEntry);
180 if (addDefaultMethod &&
e &&
e->isDict())
182 e->dict().add(
"method", defaultMethod);
190 void Foam::multiLevelDecomp::setMethods()
198 methods_.setSize(methodsDict_.size());
199 for (
const entry& dEntry : methodsDict_)
214 methods_.setSize(nLevels);
219 <<
"Decompose " <<
type() <<
" [" << nDomains() <<
"] in "
220 << nLevels <<
" levels:" <<
endl;
225 Info<<
" level " << i <<
" : " << methods_[i].type()
226 <<
" [" << methods_[i].nDomains() <<
"]" <<
endl;
228 nTotal *= methods_[i].nDomains();
231 if (nTotal != nDomains())
234 <<
"Top level decomposition specifies " << nDomains()
235 <<
" domains which is not equal to the product of"
236 <<
" all sub domains " << nTotal
244 void Foam::multiLevelDecomp::subsetGlobalCellCells
246 const label nDomains,
259 globalIndex globalCells(cellCells.size());
262 subCellCells = UIndirectList<labelList>(cellCells,
set);
265 List<Map<label>> compactMap;
266 mapDistribute map(globalCells, subCellCells, compactMap);
267 map.distribute(oldToNew);
269 map.distribute(allDist);
278 globalIndex globalSubCells(
set.size());
283 cutConnections.setSize(nDomains);
286 forAll(subCellCells, subCelli)
288 labelList& cCells = subCellCells[subCelli];
295 const label nbrCelli = oldToNew[cCells[i]];
298 cutConnections[allDist[cCells[i]]]++;
305 const label celli =
set[subCelli];
306 const label oldNbrCelli = cellCells[celli][i];
308 const label proci = globalCells.whichProcID(oldNbrCelli);
310 cCells[newI++] = globalSubCells.toGlobal(proci, nbrCelli);
313 cCells.setSize(newI);
318 void Foam::multiLevelDecomp::decompose
324 const label currLevel,
325 const label leafOffset,
332 methods_[currLevel].decompose
341 const label nextLevel = currLevel+1;
344 const label nCurrDomains = methods_[currLevel].nDomains();
354 for (label i = 0; i <= currLevel; ++i)
356 sizes *= methods_[i].nDomains();
360 sizes = this->nDomains() / sizes;
364 domainLookup[i] = i * sizes + leafOffset;
370 Info<<
"Distribute at level " << currLevel
371 <<
" to domains" <<
nl
378 const label orig = pointMap[i];
379 finalDecomp[orig] = domainLookup[dist[i]];
382 if (nextLevel < methods_.size())
392 Pout<<
"Decomposition at level " << currLevel <<
" :" <<
endl;
395 for (label domainI = 0; domainI < nCurrDomains; ++domainI)
402 scalarField subWeights(pointWeights, domainPoints);
407 subsetGlobalCellCells
425 for (
const label nConnect : nOutsideConnections)
437 Pout<<
" Domain " << domainI <<
nl
438 <<
" Number of cells = " <<
nPoints <<
nl
439 <<
" Number of inter-domain patches = " <<
nPatches
441 <<
" Number of inter-domain faces = " << nFaces <<
nl
454 domainLookup[domainI],
468 const label nNext = methods_[nextLevel].nDomains();
469 const label nTotal = nCurrDomains * nNext;
472 dictionary level0Dict;
473 for (
const entry& dEntry : methodsDict_)
477 level0Dict = dEntry.dict();
481 level0Dict.set(
"numberOfSubdomains", nTotal);
485 Pout<<
"Reference decomposition with " << level0Dict <<
" :"
503 for (label blockI = 0; blockI < nCurrDomains; ++blockI)
509 forAll(pointPoints, pointi)
511 if ((dist[pointi] / nNext) == blockI)
515 const labelList& pPoints = pointPoints[pointi];
519 const label distBlockI = dist[pPoints[i]] / nNext;
520 if (distBlockI != blockI)
522 nOutsideConnections[distBlockI]++;
537 for (
const label nConnect : nOutsideConnections)
548 Pout<<
" Domain " << blockI <<
nl
549 <<
" Number of cells = " <<
nPoints <<
nl
550 <<
" Number of inter-domain patches = "
552 <<
" Number of inter-domain faces = " << nFaces
563 Foam::multiLevelDecomp::multiLevelDecomp
565 const dictionary& decompDict,
575 (selectionType::EXACT | selectionType::MANDATORY)
592 if (!meth.parallelAware())
604 const polyMesh&
mesh,
609 CompactListList<label> cellCells;
610 calcCellCells(
mesh,
identity(cc.size()), cc.size(),
true, cellCells);