39 #ifndef MPICH_SKIP_MPICXX 40 #define MPICH_SKIP_MPICXX 42 #ifndef OMPI_SKIP_MPICXX 43 #define OMPI_SKIP_MPICXX 60 sizeof(Foam::label) <=
sizeof(SCOTCH_Num),
61 "SCOTCH_Num is too small for Foam::label, check your scotch headers" 84 static inline void check(
const int retVal,
const char* what)
89 <<
"Call to scotch routine " << what
90 <<
" failed (" << retVal <<
")\n" 128 labelList adjncy_dummy, xadj_dummy, decomp_dummy;
131 adjncy_dummy.
resize(1, 0);
132 adjncy_param.
set(adjncy_dummy);
135 xadj_param.
set(xadj_dummy);
137 decomp_dummy.
resize(1, 0);
138 decomp_param.
clear();
139 decomp_param.
set(decomp_dummy);
146 OFstream str(graphPath_ +
".grf");
148 Info<<
"Dumping Scotch graph file to " << str.name() <<
nl 149 <<
"Use this in combination with gpart." <<
endl;
151 const label numConnect = adjncy.
size();
158 str << numCells <<
' ' << numConnect <<
nl;
162 str <<
"0 000" <<
nl;
164 for (label celli = 0; celli < numCells; ++celli)
166 const label beg = xadj[celli];
167 const label
end = xadj[celli+1];
171 for (label i = beg; i <
end; ++i)
173 str <<
' ' << adjncy[i];
181 SCOTCH_randomReset();
187 SCOTCH_Strat stradat;
190 SCOTCH_stratInit(&stradat),
197 DebugInfo <<
"scotchDecomp : Using strategy " << strategy <<
endl;
199 SCOTCH_stratGraphMap(&stradat, strategy.c_str());
211 bool hasWeights = !cWeights.
empty();
214 const scalar minWeights = hasWeights ?
min(cWeights) : scalar(1);
220 <<
"Illegal minimum weight " << minWeights
224 else if (hasWeights && (cWeights.
size() != numCells))
227 <<
"Number of cell weights " << cWeights.
size()
228 <<
" does not equal number of cells " << numCells
233 List<SCOTCH_Num> velotab;
237 scalar rangeScale(1);
239 const scalar velotabSum =
sum(cWeights)/minWeights;
241 const scalar upperRange =
static_cast<scalar
> 246 if (velotabSum > upperRange)
250 rangeScale = 0.9*upperRange/velotabSum;
253 <<
"Sum of weights overflows SCOTCH_Num: " << velotabSum
254 <<
", compressing by factor " << rangeScale <<
endl;
259 velotab.resize(cWeights.
size());
263 velotab[i] =
static_cast<SCOTCH_Num
> 265 ((cWeights[i]/minWeights - 1)*rangeScale) + 1
276 velotab.resize(numCells);
277 velotab =
static_cast<SCOTCH_Num
>(1);
285 SCOTCH_Graph grafdat;
288 SCOTCH_graphInit(&grafdat),
299 xadj_param().cdata(),
306 adjncy_param().cdata(),
313 SCOTCH_graphCheck(&grafdat),
325 SCOTCH_archInit(&archdat),
329 List<SCOTCH_Num> procWeights;
333 List<SCOTCH_Num> domains;
334 List<scalar> dWeights;
339 && !procWeights.empty()
345 <<
"processorWeights (" << procWeights.size()
346 <<
") != number of domains (" <<
nDomains_ <<
")" <<
nl 351 <<
"scotchDecomp : Using procesor weights " 352 << procWeights <<
endl;
356 SCOTCH_archCmpltw(&archdat,
nDomains_, procWeights.cdata()),
369 for (
const label
n : domains)
376 const label sz = domains.size();
377 domains.setSize(sz+1);
378 dWeights.setSize(sz+1);
379 for (label i = sz-1; i >= 0; i--)
381 domains[i+1] = domains[i];
382 dWeights[i+1] = dWeights[i];
388 <<
"Top level decomposition specifies " <<
nDomains()
389 <<
" domains which is not equal to the product of" 390 <<
" all sub domains " << nTotal
395 dWeights[0] = scalar(1);
400 const scalar minWeights =
min(dWeights);
403 List<SCOTCH_Num> weights(dWeights.size());
407 weights[i] =
static_cast<SCOTCH_Num
> 409 (dWeights[i]/minWeights - 1) + 1
418 SCOTCH_Num(domains.size()),
477 int oldExcepts = fedisableexcept
492 decomp_param.
ref().data()
498 feenableexcept(oldExcepts);
514 SCOTCH_graphExit(&grafdat);
515 SCOTCH_stratExit(&stradat);
516 SCOTCH_archExit(&archdat);
590 graphPath_ =
"scotch.grf";
609 graphPath_ =
"scotch.grf";
void size(const label n)
Older name for setAddressableSize.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
label nDomains_
Number of domains for the decomposition.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static Foam::fileName getGraphPathBase(const polyMesh &mesh)
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
A non-const Field/List wrapper with possible data conversion.
const Time & time() const
Return the top-level database.
const dictionary & coeffsDict_
Coefficients for all derived methods.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
virtual labelList decompose(const polyMesh &mesh, const pointField &points=pointField::null(), const scalarField &pointWeights=scalarField::null()) const
Return for every coordinate the wanted processor number.
A class for handling words, derived from Foam::string.
scotchDecomp(const scotchDecomp &)=delete
No copy construct.
A const Field/List wrapper with possible data conversion.
Domain decomposition using METIS-like data structures.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
virtual labelList decompose(const polyMesh &mesh, const pointField &points=pointField::null(), const scalarField &pointWeights=scalarField::null()) const
Return for every coordinate the wanted processor number.
label nDomains() const noexcept
Number of domains.
#define DebugInfo
Report an information message using Foam::Info.
A packed storage of objects of type <T> using an offset table for access.
void set(Container< InputType > &input, const bool doCopy=true)
Set adaptor for different input, copying input as required.
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...
Container< Type > & ref() const
Return non-const reference to the contents of a non-null managed pointer.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
defineTypeNameAndDebug(combustionModel, 0)
static void check(const int retVal, const char *what)
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
#define WarningInFunction
Report a warning using Foam::Warning.
const word & name() const
Return reference to name.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
messageStream Info
Information stream (stdout output on master, null elsewhere)
Mesh consisting of general polyhedral cells.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
void set(const Container< InputType > &input)
Set adaptor for different input, copying input if required.
virtual label decomposeSerial(const labelList &adjncy, const labelList &xadj, const List< scalar > &cWeights, labelList &decomp) const
Decompose non-parallel.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...