50 #ifndef _ZOLTAN2_PARTITIONINGHELPERS_HPP_
51 #define _ZOLTAN2_PARTITIONINGHELPERS_HPP_
79 template <
typename SolutionAdapter,
typename DataAdapter>
82 const DataAdapter *
const data,
83 ArrayRCP<typename DataAdapter::gno_t> &imports
92 if (numParts >
size_t(numProcs)) {
94 sprintf(msg,
"Number of parts %lu exceeds number of ranks %d; "
95 "%s requires a MappingSolution for this case\n",
96 numParts, numProcs, __func__);
97 throw std::logic_error(msg);
100 size_t localNumIds = data->getLocalNumIDs();
101 const typename DataAdapter::gno_t *gids = NULL;
102 data->getIDsView(gids);
107 Array<int> counts(numProcs, 0);
108 for (
size_t i=0; i < localNumIds; i++)
111 Array<gno_t> offsets(numProcs+1, 0);
112 for (
int i=1; i <= numProcs; i++){
113 offsets[i] = offsets[i-1] + counts[i-1];
116 Array<typename DataAdapter::gno_t> gidList(localNumIds);
117 for (
size_t i=0; i < localNumIds; i++) {
118 gno_t idx = offsets[parts[i]];
119 gidList[idx] = gids[i];
120 offsets[parts[i]] = idx + 1;
123 Array<int> recvCounts(numProcs, 0);
127 gidList(), counts(), imports, recvCounts());
131 return imports.size();
136 #endif // _ZOLTAN2_PARTITIONINGHELPERS_HPP_
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
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.