59 void Foam::multiLevelDecomp::createMethodsDict()
81 nTotal = (domains.empty() ? 0 : 1);
83 for (
const label
n : domains)
106 domains.setSize(old.size()+1);
111 domains[i+1] = old[i];
113 nTotal *= domains[0];
115 Info<<
" inferred level0 with " << domains[0]
116 <<
" domains" <<
nl <<
nl;
119 if (!nLevels || nTotal !=
nDomains())
122 <<
"Top level decomposition specifies " <<
nDomains()
123 <<
" domains which is not equal to the product of"
124 <<
" all sub domains " << nTotal
132 const dictionary& subMethodCoeffsDict
137 defaultMethod +
"Coeffs",
138 selectionType::NULL_DICT
142 for (
const label
n : domains)
144 const word levelName(
"level" +
Foam::name(nLevels++));
146 entry* dictptr = methodsDict_.set(levelName, dictionary());
148 dictionary&
dict = dictptr->dict();
149 dict.add(
"method", defaultMethod);
150 dict.add(
"numberOfSubdomains",
n);
153 if (subMethodCoeffsDict.size())
155 dict.add(subMethodCoeffsDict.dictName(), subMethodCoeffsDict);
167 for (
const entry& dEntry : coeffsDict_)
180 const bool addDefaultMethod
183 && !defaultMethod.empty()
186 entry*
e = methodsDict_.add(dEntry);
188 if (addDefaultMethod &&
e &&
e->isDict())
190 e->dict().add(
"method", defaultMethod);
198 void Foam::multiLevelDecomp::setMethods()
206 methods_.setSize(methodsDict_.size());
207 for (
const entry& dEntry : methodsDict_)
222 methods_.setSize(nLevels);
227 <<
"Decompose " <<
type() <<
" [" << nDomains() <<
"] in "
228 << nLevels <<
" levels:" <<
endl;
233 Info<<
" level " << i <<
" : " << methods_[i].type()
234 <<
" [" << methods_[i].nDomains() <<
"]" <<
endl;
236 nTotal *= methods_[i].nDomains();
239 if (nTotal != nDomains())
242 <<
"Top level decomposition specifies " << nDomains()
243 <<
" domains which is not equal to the product of"
244 <<
" all sub domains " << nTotal
252 void Foam::multiLevelDecomp::subsetGlobalCellCells
254 const label nDomains,
267 globalIndex globalCells(cellCells.size());
270 subCellCells = UIndirectList<labelList>(cellCells,
set);
273 List<Map<label>> compactMap;
274 mapDistribute map(globalCells, subCellCells, compactMap);
275 map.distribute(oldToNew);
277 map.distribute(allDist);
286 globalIndex globalSubCells(
set.size());
291 cutConnections.setSize(nDomains);
294 forAll(subCellCells, subCelli)
296 labelList& cCells = subCellCells[subCelli];
303 const label nbrCelli = oldToNew[cCells[i]];
306 cutConnections[allDist[cCells[i]]]++;
313 const label celli =
set[subCelli];
314 const label oldNbrCelli = cellCells[celli][i];
316 const label proci = globalCells.whichProcID(oldNbrCelli);
318 cCells[newI++] = globalSubCells.toGlobal(proci, nbrCelli);
321 cCells.setSize(newI);
326 void Foam::multiLevelDecomp::decompose
332 const label currLevel,
333 const label leafOffset,
340 methods_[currLevel].decompose
349 const label nextLevel = currLevel+1;
352 const label nCurrDomains = methods_[currLevel].nDomains();
362 for (label i = 0; i <= currLevel; ++i)
364 sizes *= methods_[i].nDomains();
368 sizes = this->nDomains() / sizes;
372 domainLookup[i] = i * sizes + leafOffset;
378 Info<<
"Distribute at level " << currLevel
379 <<
" to domains" <<
nl
386 const label orig = pointMap[i];
387 finalDecomp[orig] = domainLookup[dist[i]];
390 if (nextLevel < methods_.size())
400 Pout<<
"Decomposition at level " << currLevel <<
" :" <<
endl;
403 for (label domainI = 0; domainI < nCurrDomains; ++domainI)
410 scalarField subWeights(pointWeights, domainPoints);
415 subsetGlobalCellCells
433 for (
const label nConnect : nOutsideConnections)
445 Pout<<
" Domain " << domainI <<
nl
446 <<
" Number of cells = " <<
nPoints <<
nl
447 <<
" Number of inter-domain patches = " <<
nPatches
449 <<
" Number of inter-domain faces = " << nFaces <<
nl
462 domainLookup[domainI],
476 const label nNext = methods_[nextLevel].nDomains();
477 const label nTotal = nCurrDomains * nNext;
480 dictionary level0Dict;
481 for (
const entry& dEntry : methodsDict_)
485 level0Dict = dEntry.dict();
489 level0Dict.set(
"numberOfSubdomains", nTotal);
493 Pout<<
"Reference decomposition with " << level0Dict <<
" :"
511 for (label blockI = 0; blockI < nCurrDomains; ++blockI)
517 forAll(pointPoints, pointi)
519 if ((dist[pointi] / nNext) == blockI)
523 const labelList& pPoints = pointPoints[pointi];
527 const label distBlockI = dist[pPoints[i]] / nNext;
528 if (distBlockI != blockI)
530 nOutsideConnections[distBlockI]++;
545 for (
const label nConnect : nOutsideConnections)
556 Pout<<
" Domain " << blockI <<
nl
557 <<
" Number of cells = " <<
nPoints <<
nl
558 <<
" Number of inter-domain patches = "
560 <<
" Number of inter-domain faces = " << nFaces
571 Foam::multiLevelDecomp::multiLevelDecomp(
const dictionary& decompDict)
590 Foam::multiLevelDecomp::multiLevelDecomp
602 (selectionType::EXACT | selectionType::MANDATORY)
619 if (!meth.parallelAware())
637 calcCellCells(
mesh,
identity(cc.size()), cc.size(),
true, cellCells);