52 void Foam::multiLevelDecomp::createMethodsDict()
74 nTotal = (domains.empty() ? 0 : 1);
76 for (
const label
n : domains)
99 domains.setSize(old.size()+1);
104 domains[i+1] = old[i];
106 nTotal *= domains[0];
108 Info<<
" inferred level0 with " << domains[0]
109 <<
" domains" <<
nl <<
nl;
112 if (!nLevels || nTotal !=
nDomains())
115 <<
"Top level decomposition specifies " <<
nDomains()
116 <<
" domains which is not equal to the product of" 117 <<
" all sub domains " << nTotal
130 defaultMethod +
"Coeffs",
131 selectionType::NULL_DICT
135 for (
const label
n : domains)
137 const word levelName(
"level" +
Foam::name(nLevels++));
139 entry* dictptr = methodsDict_.set(levelName,
dictionary());
142 dict.add(
"method", defaultMethod);
143 dict.add(
"numberOfSubdomains",
n);
146 if (subMethodCoeffsDict.size())
148 dict.add(subMethodCoeffsDict.dictName(), subMethodCoeffsDict);
160 for (
const entry& dEntry : coeffsDict_)
173 const bool addDefaultMethod
176 && !defaultMethod.empty()
179 entry*
e = methodsDict_.add(dEntry);
181 if (addDefaultMethod &&
e &&
e->isDict())
183 e->dict().add(
"method", defaultMethod);
191 void Foam::multiLevelDecomp::setMethods()
198 methods_.resize_null(methodsDict_.size());
199 for (
const entry& dEntry : methodsDict_)
214 methods_.resize(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,
256 const 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 const globalIndex globalSubCells(
set.size());
283 cutConnections.resize_nocopy(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())
389 Pout<<
"Decomposition at level " << currLevel <<
" :" <<
endl;
392 for (label domainI = 0; domainI < nCurrDomains; ++domainI)
402 subWeights =
scalarField(pointWeights, domainPoints);
409 subsetGlobalCellCells
427 for (
const label nConnect : nOutsideConnections)
439 Pout<<
" Domain " << domainI <<
nl 440 <<
" Number of cells = " <<
nPoints <<
nl 441 <<
" Number of inter-domain patches = " <<
nPatches 443 <<
" Number of inter-domain faces = " << nFaces <<
nl 456 domainLookup[domainI],
470 const label nNext = methods_[nextLevel].nDomains();
471 const label nTotal = nCurrDomains * nNext;
475 for (
const entry& dEntry : methodsDict_)
479 level0Dict = dEntry.dict();
483 level0Dict.set(
"numberOfSubdomains", nTotal);
487 Pout<<
"Reference decomposition with " << level0Dict <<
" :" 505 for (label blockI = 0; blockI < nCurrDomains; ++blockI)
511 forAll(pointPoints, pointi)
513 if ((dist[pointi] / nNext) == blockI)
517 const labelList& pPoints = pointPoints[pointi];
521 const label distBlockI = dist[pPoints[i]] / nNext;
522 if (distBlockI != blockI)
524 nOutsideConnections[distBlockI]++;
539 for (
const label nConnect : nOutsideConnections)
550 Pout<<
" Domain " << blockI <<
nl 551 <<
" Number of cells = " <<
nPoints <<
nl 552 <<
" Number of inter-domain patches = " 554 <<
" Number of inter-domain faces = " << nFaces
567 const dictionary& decompDict,
577 (selectionType::EXACT | selectionType::MANDATORY)
594 if (!meth.parallelAware())
606 const polyMesh&
mesh,
614 CompactListList<label> cellCells;
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
UIndirectList< label > labelUIndList
UIndirectList of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
List< labelList > labelListList
List of labelList.
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
#define forAll(list, i)
Loop across all elements in list.
label size() const noexcept
The number of elements in table.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
List< SubListType > unpack() const
Return non-compact list of lists.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const string & prefix() const noexcept
Return the stream prefix.
Abstract base class for domain decomposition.
static const dictionary & findCoeffsDict(const dictionary &dict, const word &coeffsName, int select=selectionType::DEFAULT)
Locate coeffsName dictionary or the fallback "coeffs" dictionary within an enclosing dictionary...
label nDomains() const noexcept
Number of domains.
A packed storage of objects of type <T> using an offset table for access.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
static autoPtr< decompositionMethod > New(const dictionary &decompDict, const word ®ionName="")
Return a reference to the selected decomposition method, optionally region-specific.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
multiLevelDecomp(const multiLevelDecomp &)=delete
No copy construct.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
messageStream Info
Information stream (stdout output on master, null elsewhere)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
static void calcCellCells(const polyMesh &mesh, const labelUList &agglom, const label nLocalCoarse, const bool parallel, CompactListList< label > &cellCells)
Determine (local or global) cellCells from mesh agglomeration.
virtual bool parallelAware() const
Is parallel aware when all sub-methods are also parallel-aware.
List< label > labelList
A List of labels.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements. After completion all processors have the same data.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.