52void 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",
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);
191void 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
244void Foam::multiLevelDecomp::subsetGlobalCellCells
246 const label nDomains,
267 map.distribute(oldToNew);
269 map.distribute(allDist);
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);
318void 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
445 oldPrefix =
Pout.prefix();
446 Pout.prefix() =
" " + oldPrefix;
456 domainLookup[domainI],
462 Pout.prefix() = oldPrefix;
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)
510 labelList nOutsideConnections(nCurrDomains, Foam::zero{});
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]++;
535 for (
const label nConnect : nOutsideConnections)
546 Pout<<
" Domain " << blockI <<
nl
547 <<
" Number of cells = " <<
nPoints <<
nl
548 <<
" Number of inter-domain patches = "
550 <<
" Number of inter-domain faces = " << nFaces
573 (selectionType::EXACT | selectionType::MANDATORY)
590 if (!meth.parallelAware())
607 labelList finalDecomp(cc.size(), Foam::zero{});
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A packed storage of objects of type <T> using an offset table for access.
List< SubListType > unpack() const
Return non-compact list of lists.
label size() const noexcept
The number of elements in table.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element.
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Abstract base class for domain decomposition.
selectionType
Selection type when handling the coefficients dictionary.
@ EXACT
No fallback to "coeffs" if main name not found.
@ MANDATORY
Fatal if dictionary could not be found.
decompositionMethod(const label numDomains)
Construct with specified number of domains, no coefficients or constraints.
static autoPtr< decompositionMethod > New(const dictionary &decompDict, const word ®ionName="")
Return a reference to the selected decomposition method, optionally region-specific.
static FOAM_NO_DANGLING_REFERENCE 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 list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
void clear()
Clear the dictionary.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
A keyword and a list of tokens is an 'entry'.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
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.
Class containing processor-to-processor mapping information.
Decompose given using consecutive application of decomposers.
multiLevelDecomp(const multiLevelDecomp &)=delete
No copy construct.
virtual bool parallelAware() const
Is parallel aware when all sub-methods are also parallel-aware.
Mesh consisting of general polyhedral cells.
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
Namespace for handling debugging switches.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
UIndirectList< label > labelUIndList
UIndirectList of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
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...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.