14 #ifndef _ZOLTAN2_PARTITIONINGHELPERS_HPP_
15 #define _ZOLTAN2_PARTITIONINGHELPERS_HPP_
43 template <
typename SolutionAdapter,
typename DataAdapter>
46 const DataAdapter *
const data,
47 ArrayRCP<typename DataAdapter::gno_t> &imports
56 if (numParts >
size_t(numProcs)) {
58 sprintf(msg,
"Number of parts %lu exceeds number of ranks %d; "
59 "%s requires a MappingSolution for this case\n",
60 numParts, numProcs, __func__);
61 throw std::logic_error(msg);
64 size_t localNumIds = data->getLocalNumIDs();
66 data->getIDsView(gids);
71 Array<int> counts(numProcs, 0);
72 for (
size_t i=0; i < localNumIds; i++)
75 Array<gno_t> offsets(numProcs+1, 0);
76 for (
int i=1; i <= numProcs; i++){
77 offsets[i] = offsets[i-1] + counts[i-1];
80 Array<typename DataAdapter::gno_t> gidList(localNumIds);
81 for (
size_t i=0; i < localNumIds; i++) {
82 gno_t idx = offsets[parts[i]];
83 gidList[idx] = gids[i];
84 offsets[parts[i]] = idx + 1;
87 Array<int> recvCounts(numProcs, 0);
91 gidList(), counts(), imports, recvCounts());
95 return imports.size();
100 #endif // _ZOLTAN2_PARTITIONINGHELPERS_HPP_
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
map_t::global_ordinal_type gno_t
Defines the PartitioningSolution class.
size_t getImportList(const PartitioningSolution< SolutionAdapter > &solution, const DataAdapter *const data, ArrayRCP< typename DataAdapter::gno_t > &imports)
From a PartitioningSolution, get a list of IDs to be imported. Assumes part numbers in PartitioningSo...
SparseMatrixAdapter_t::part_t part_t
A PartitioningSolution is a solution to a partitioning problem.
const RCP< const Comm< int > > & getCommunicator() const
Return the communicator associated with the solution.
const part_t * getPartListView() const
Returns the part list corresponding to the global ID list.
size_t getActualGlobalNumberOfParts() const
Returns the actual global number of parts provided in setParts().
const RCP< const Environment > & getEnvironment() const
Return the environment associated with the solution.
AlltoAll communication methods.