37#ifndef MPICH_SKIP_MPICXX
38#define MPICH_SKIP_MPICXX
40#ifndef OMPI_SKIP_MPICXX
41#define OMPI_SKIP_MPICXX
44#include "kaHIP_interface.h"
69 { kahipDecomp::configs::FAST,
"fast" },
70 { kahipDecomp::configs::ECO,
"eco" },
71 { kahipDecomp::configs::STRONG,
"strong" },
72 { kahipDecomp::configs::FASTSOCIAL,
"fast-social" },
82 const labelList& adjncy,
83 const labelList& xadj,
84 const List<scalar>& cWeights,
90 double imbalance = 0.01;
94 #if WM_LABEL_SIZE == 64
95 if (xadj.size()-1 > INT_MAX)
98 <<
"Cannot decompose " << (xadj.size()-1) <<
" cells," <<
nl
99 <<
"Exceeded integer limit of " << INT_MAX <<
nl
104 int numCells =
Foam::max(0, (xadj.size()-1));
107 ConstPrecisionAdaptor<int, label, List> adjncy_param(adjncy);
108 ConstPrecisionAdaptor<int, label, List> xadj_param(xadj);
111 decomp.resize_nocopy(numCells);
113 PrecisionAdaptor<int, label, List> decomp_param(decomp,
false);
116 labelList adjncy_dummy, xadj_dummy, decomp_dummy;
119 adjncy_dummy.resize(1, 0);
120 adjncy_param.set(adjncy_dummy);
122 xadj_dummy.resize(2, 0);
123 xadj_param.set(xadj_dummy);
125 decomp_dummy.resize(1, 0);
126 decomp_param.clear();
127 decomp_param.set(decomp_dummy);
136 bool hasWeights = !cWeights.
empty();
139 const scalar minWeights = hasWeights ?
min(cWeights) : scalar(1);
145 <<
"Illegal minimum weight " << minWeights
149 else if (hasWeights && (cWeights.size() != numCells))
152 <<
"Number of weights (" << cWeights.size()
153 <<
") != number of cells (" << numCells <<
")"
158 List<int> cellWeights;
163 cellWeights.resize_nocopy(cWeights.size());
166 cellWeights[i] =
static_cast<int>
168 cWeights[i]/minWeights
177 Info<<
"kahipDecomp :"
179 <<
" imbalance=" << imbalance;
183 Info<<
" seed=" << seed;
187 std::map<std::string, std::vector<int>> sizingParams;
196 std::vector<int> vec;
197 vec.reserve(labels.size()+1);
202 for (const auto val : labels)
215 <<
"Mismatch in number of processors and "
229 sizingParams[
"hierarchy"] = std::move(vec);
230 Info<<
" hierarchy=" << flatOutput(labels);
236 coeffsDict_.readIfPresent(
"distance", labels)
240 std::vector<int> vec(labels.size());
247 sizingParams[
"distance"] = std::move(vec);
255 int nParts = nDomains_;
265 (cellWeights.empty() ?
nullptr : cellWeights.data()),
266 xadj_param.constCast().data(),
268 adjncy_param.constCast().data(),
275 decomp_param.ref().data(),
282 (cellWeights.empty() ?
nullptr : cellWeights.data()),
283 xadj_param.constCast().data(),
285 adjncy_param.constCast().data(),
292 decomp_param.ref().data()
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 const Field/List wrapper with possible data conversion.
void set(const Container< InputType > &input)
Set adaptor for different input, copying input if required.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
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 resize(const label len)
Adjust allocated size of list.
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.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
T * data() 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.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Domain decomposition using KaHIP http://algo2.iti.kit.edu/documents/kahip/.
kahipDecomp(const kahipDecomp &)=delete
No copy construct.
virtual label decomposeSerial(const labelList &adjncy, const labelList &xadj, const List< scalar > &cellWeights, labelList &decomp) const
Call kahip with options from dictionary.
configs
The predefined KaHIP configuration types.
static const Enum< configs > configNames
The selection names for predefined KaHIP configurations.
Domain decomposition using METIS-like data structures.
const dictionary & coeffsDict_
Coefficients for all derived methods.
metisLikeDecomp(const metisLikeDecomp &)=delete
No copy construct.
T & constCast() const
Return non-const reference to the object or to the contents of a (non-null) managed pointer,...
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.
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
#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< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
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.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
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.