40 #ifndef MPICH_SKIP_MPICXX 41 #define MPICH_SKIP_MPICXX 43 #ifndef OMPI_SKIP_MPICXX 44 #define OMPI_SKIP_MPICXX 48 #pragma GCC diagnostic ignored "-Wold-style-cast" 65 sizeof(Foam::label) <=
sizeof(SCOTCH_Num),
66 "SCOTCH_Num is too small for Foam::label, check your scotch headers" 89 static inline void check(
const int retVal,
const char* what)
94 <<
"Call to scotch routine " << what
95 <<
" failed (" << retVal <<
")\n" 112 Foam::label Foam::ptscotchDecomp::decompose
116 const List<scalar>& cWeights,
120 const SCOTCH_Num numCells =
Foam::max(0, (xadj.size()-1));
123 ConstPrecisionAdaptor<SCOTCH_Num, label, List> adjncy_param(adjncy);
124 ConstPrecisionAdaptor<SCOTCH_Num, label, List> xadj_param(xadj);
127 decomp.resize_nocopy(numCells);
129 PrecisionAdaptor<SCOTCH_Num, label, List> decomp_param(decomp,
false);
132 labelList adjncy_dummy, xadj_dummy, decomp_dummy;
135 adjncy_dummy.
resize(1, 0);
136 adjncy_param.set(adjncy_dummy);
138 xadj_dummy.resize(2, 0);
139 xadj_param.set(xadj_dummy);
141 decomp_dummy.resize(1, 0);
142 decomp_param.clear();
143 decomp_param.set(decomp_dummy);
149 Pout<<
"ptscotchDecomp : " << numCells <<
" cells" <<
endl;
160 Pout<<
"Dumping Scotch graph file to " << str.
name() <<
endl 161 <<
"Use this in combination with dgpart." <<
endl;
163 const label numConnect = adjncy.size();
164 const label nTotCells =
returnReduce(numCells, sumOp<label>());
165 const label nTotConnect =
returnReduce(numConnect, sumOp<label>());
175 str << nTotCells <<
' ' << nTotConnect <<
nl;
179 str << numCells <<
' ' << numConnect <<
nl;
183 str <<
"0 000" <<
nl;
185 for (label celli = 0; celli < numCells; ++celli)
187 const label beg = xadj[celli];
188 const label
end = xadj[celli+1];
192 for (label i = beg; i <
end; ++i)
194 str <<
' ' << adjncy[i];
202 SCOTCH_randomReset();
208 SCOTCH_Strat stradat;
211 SCOTCH_stratInit(&stradat),
219 <<
"ptscotchDecomp : Using strategy " << strategy <<
endl;
221 SCOTCH_stratDgraphMap(&stradat, strategy.c_str());
235 const scalar minWeights = hasWeights ?
gMin(cWeights) : scalar(1);
241 <<
"Illegal minimum weight " << minWeights
245 else if (hasWeights && (cWeights.size() != numCells))
248 <<
"Number of cell weights " << cWeights.size()
249 <<
" does not equal number of cells " << numCells
254 List<SCOTCH_Num> velotab;
258 scalar rangeScale(1);
260 const scalar velotabSum =
gSum(cWeights)/minWeights;
262 const scalar upperRange =
static_cast<scalar
> 267 if (velotabSum > upperRange)
271 rangeScale = 0.9*upperRange/velotabSum;
274 <<
"Sum of weights overflows SCOTCH_Num: " << velotabSum
275 <<
", compressing by factor " << rangeScale <<
endl;
281 velotab.resize(cWeights.size());
285 velotab[i] =
static_cast<SCOTCH_Num
> 287 ((cWeights[i]/minWeights - 1)*rangeScale) + 1
295 velotab.resize(1, 1);
306 velotab.resize(numCells);
315 velotab =
static_cast<SCOTCH_Num
>(1);
327 SCOTCH_Dgraph grafdat;
330 SCOTCH_dgraphInit(&grafdat, MPI_COMM_WORLD),
336 Pout<<
"SCOTCH_dgraphBuild with:" <<
nl 337 <<
"numCells : " << numCells <<
nl 338 <<
"xadj : " <<
name(xadj_param().cdata()) <<
nl 339 <<
"velotab : " <<
name(velotab.cdata()) <<
nl 340 <<
"adjncySize : " << adjncy_param().size() <<
nl 341 <<
"adjncy : " <<
name(adjncy_param().cdata()) <<
nl 355 xadj_param.constCast().data(),
358 (xadj_param.constCast().data()+1),
366 adjncy_param.constCast().data(),
375 Pout<<
"SCOTCH_dgraphCheck" <<
endl;
379 SCOTCH_dgraphCheck(&grafdat),
395 SCOTCH_archInit(&archdat),
399 List<SCOTCH_Num> procWeights;
403 && !procWeights.empty()
409 <<
"processorWeights (" << procWeights.size()
410 <<
") != number of domains (" <<
nDomains_ <<
")" <<
nl 415 <<
"ptscotchDecomp : Using procesor weights " 416 << procWeights <<
endl;
420 SCOTCH_archCmpltw(&archdat,
nDomains_, procWeights.cdata()),
427 List<SCOTCH_Num> domains;
428 List<scalar> dWeights;
446 <<
"Ignoring multi-level decomposition since" 447 <<
" not supported by ptscotch." 448 <<
" It is supported by scotch" <<
endl;
465 int oldExcepts = fedisableexcept
484 decomp_param.ref().data()
490 feenableexcept(oldExcepts);
510 SCOTCH_dgraphExit(&grafdat);
511 SCOTCH_stratExit(&stradat);
512 SCOTCH_archExit(&archdat);
553 <<
"Number of cell centres (" <<
points.
size()
554 <<
") != number of cells (" <<
mesh.
nCells() <<
")" 563 CompactListList<label> cellCells;
593 <<
"Agglomeration size (" << agglom.
size()
594 <<
") != number of cells (" <<
mesh.
nCells() <<
")" 603 CompactListList<label> cellCells;
636 graphPath_ =
"ptscotch";
638 if (!cellCentres.
empty() && (cellCentres.
size() != globalCellCells.
size()))
641 <<
"Number of cell centres (" << cellCentres.
size()
642 <<
") != number of cells (" << globalCellCells.
size() <<
")" 672 graphPath_ =
"ptscotch";
674 if (!cellCentres.
empty() && (cellCentres.
size() != globalCellCells.
size()))
677 <<
"Number of cell centres (" << cellCentres.
size()
678 <<
") != number of cells (" << globalCellCells.
size() <<
")" selectionType
Selection type when handling the coefficients dictionary.
void size(const label n)
Older name for setAddressableSize.
const labelList & offsets() const noexcept
Return the offset table (= size()+1)
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)
label size() const noexcept
The primary size (the number of rows/sublists)
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.
Type gMin(const FieldField< Field, Type > &f)
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)
static CompactListList< T > pack(const UList< SubListType > &lists, const bool checkOverflow=false)
Construct by packing together the list of lists.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
const Time & time() const
Return the top-level database.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
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.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
ptscotchDecomp(const ptscotchDecomp &)=delete
No copy construct.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Type gSum(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
Abstract base class for domain decomposition.
#define DebugInfo
Report an information message using Foam::Info.
A packed storage of objects of type <T> using an offset table for access.
int debug
Static debugging option.
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...
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)
#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))
label nCells() const noexcept
Number of mesh cells.
const List< T > & values() const noexcept
Return the packed values.
Mesh consisting of general polyhedral cells.
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.
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...
List< label > labelList
A List of labels.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...