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"
84static 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),
195 if (
coeffsDict_.readIfPresent(
"strategy", strategy))
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
>
243 std::numeric_limits<SCOTCH_Num>::max()-1
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;
338 coeffsDict_.readIfPresent(
"processorWeights", procWeights)
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";
if(maxValue - minValue< SMALL)
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.
A const Field/List wrapper with possible data conversion.
void set(const Container< InputType > &input)
Set adaptor for different input, copying input if required.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void setSize(label n)
Alias for resize().
void resize(const label len)
Adjust allocated size of list.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
virtual const fileName & name() const override
Read/write access to the name of the stream.
A non-const Field/List wrapper with possible data conversion.
void set(Container< InputType > &input, const bool doCopy=true)
Set adaptor for different input, copying input as required.
fileName path() const
The path for the case = rootPath/caseName.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
void size(const label n)
Older name for setAddressableSize.
Abstract base class for domain decomposition.
selectionType
Selection type when handling the coefficients dictionary.
label nDomains_
Number of domains for the decomposition.
label nDomains() const noexcept
Number of domains.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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...
A class for handling file names.
const Time & time() const
Return the top-level database.
const word & name() const
Return reference to name.
Domain decomposition using METIS-like data structures.
const dictionary & coeffsDict_
Coefficients for all derived methods.
metisLikeDecomp(const metisLikeDecomp &)=delete
No copy construct.
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.
Mesh consisting of general polyhedral cells.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Scotch domain decomposition.
virtual label decomposeSerial(const labelList &adjncy, const labelList &xadj, const List< scalar > &cWeights, labelList &decomp) const
Decompose non-parallel.
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.
scotchDecomp(const scotchDecomp &)=delete
No copy construct.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
static void check(const int retVal, const char *what)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static Foam::fileName getGraphPathBase(const polyMesh &mesh)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.