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())
392 Pout<<
"Decomposition at level " << currLevel <<
" :" <<
endl;
395 for (label domainI = 0; domainI < nCurrDomains; ++domainI)
405 subWeights =
scalarField(pointWeights, domainPoints);
412 subsetGlobalCellCells
430 for (
const label nConnect : nOutsideConnections)
442 Pout<<
" Domain " << domainI <<
nl 443 <<
" Number of cells = " <<
nPoints <<
nl 444 <<
" Number of inter-domain patches = " <<
nPatches 446 <<
" Number of inter-domain faces = " << nFaces <<
nl 459 domainLookup[domainI],
473 const label nNext = methods_[nextLevel].nDomains();
474 const label nTotal = nCurrDomains * nNext;
478 for (
const entry& dEntry : methodsDict_)
482 level0Dict = dEntry.dict();
486 level0Dict.set(
"numberOfSubdomains", nTotal);
490 Pout<<
"Reference decomposition with " << level0Dict <<
" :" 508 for (label blockI = 0; blockI < nCurrDomains; ++blockI)
514 forAll(pointPoints, pointi)
516 if ((dist[pointi] / nNext) == blockI)
520 const labelList& pPoints = pointPoints[pointi];
524 const label distBlockI = dist[pPoints[i]] / nNext;
525 if (distBlockI != blockI)
527 nOutsideConnections[distBlockI]++;
542 for (
const label nConnect : nOutsideConnections)
553 Pout<<
" Domain " << blockI <<
nl 554 <<
" Number of cells = " <<
nPoints <<
nl 555 <<
" Number of inter-domain patches = " 557 <<
" Number of inter-domain faces = " << nFaces
570 const dictionary& decompDict,
580 (selectionType::EXACT | selectionType::MANDATORY)
597 if (!meth.parallelAware())
609 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.
static void calcCellCells(const polyMesh &mesh, const labelList &agglom, const label nLocalCoarse, const bool parallel, CompactListList< label > &cellCells)
Determine (local or global) cellCells from mesh agglomeration.
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.
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.
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
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.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
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 ...
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.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
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.
static constexpr const zero Zero
Global zero (0)