10 #ifndef _ZOLTAN2_ALGQUOTIENT_HPP_
11 #define _ZOLTAN2_ALGQUOTIENT_HPP_
33 template <
typename Adapter>
52 const RCP<
const Comm<int> > &problemComm__,
55 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
57 std::string errStr =
"cannot build CommGraphModel from IdentifierAdapter, ";
58 errStr +=
"AlgQuotient requires Graph Adapter";
59 throw std::runtime_error(errStr);
63 const RCP<
const Comm<int> > &problemComm__,
66 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
68 std::string errStr =
"cannot build CommGraphModel from VectorAdapter, ";
69 errStr +=
"AlgQuotient requires Graph Adapter";
70 throw std::runtime_error(errStr);
74 const RCP<
const Comm<int> > &problemComm__,
77 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
79 std::string errStr =
"cannot build CommGraphModel from MatrixAdapter, ";
80 errStr +=
"AlgQuotient has not been implemented for Matrix Adapter yet.";
81 throw std::runtime_error(errStr);
85 const RCP<
const Comm<int> > &problemComm__,
88 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
90 std::string errStr =
"cannot build CommGraphModel from MeshAdapter, ";
91 errStr +=
"AlgQuotient has not been implemented for Mesh Adapter yet.";
92 throw std::runtime_error(errStr);
96 const RCP<
const Comm<int> > &problemComm__,
99 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
101 this->innerAlgorithm =
109 pl.set(
"quotient_threshold", 1,
"threshold for the number of vertices on the active ranks",
118 const RCP<const Environment> env;
119 const RCP<const Comm<int> > problemComm;
120 const RCP<const base_adapter_t> adapter;
123 RCP<Algorithm<Adapter>> innerAlgorithm;
124 RCP<PartitioningSolution<Adapter>> quotientSolution;
130 template <
typename Adapter>
143 quotientSolution = rcp(soln);
146 this->innerAlgorithm->partition(quotientSolution);
151 migrateBack(solution);
153 env->memory(
"Zoltan2-Quotient: After creating solution");
164 template <
typename Adapter>
170 this->adapter, this->env, this->problemComm));
171 int me = problemComm->getRank();
172 int nActiveRanks = model->getNumActiveRanks();
173 int dRank = model->getDestinationRank();
176 Teuchos::ArrayRCP<part_t> parts(1);
177 RCP<CommRequest<int>> *requests =
new RCP<CommRequest<int>>[1];
178 requests[0] = Teuchos::ireceive<int, part_t>(*problemComm, parts, dRank);
179 if (me < nActiveRanks) {
181 const part_t *qtntSlnView = quotientSolution->getPartListView();
183 int sRank = model->getStartRank();
184 int eRank = model->getEndRank();
186 ArrayView<size_t> vtxdist;
187 model->getVertexDist(vtxdist);
188 for (
int i = sRank; i < eRank; i++)
189 Teuchos::send<int, part_t>(*problemComm, 1, &qtntSlnView[i - sRank], i);
191 Teuchos::waitAll<int>(*problemComm, Teuchos::arrayView(requests, 1));
194 size_t numLocalVertices = adapter->getLocalNumIDs();
195 Teuchos::ArrayRCP<part_t> extendedParts(numLocalVertices);
196 for(
size_t i = 0; i < numLocalVertices; i++)
197 extendedParts[i] = parts[0];
200 solution->setParts(extendedParts);
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
IdentifierAdapter defines the interface for identifiers.
CommGraphModel< typename Adapter::base_adapter_t > graphModel_t
void migrateBack(const RCP< PartitioningSolution< Adapter > > &solution)
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
MatrixAdapter defines the adapter interface for matrices.
GraphAdapter defines the interface for graph-based user data.
MeshAdapter defines the interface for mesh input.
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const MatrixAdapter< user_t, userCoord_t > > &adapter__, const modelFlag_t &graphFlags_)
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const MeshAdapter< user_t > > &adapter__, const modelFlag_t &graphFlags_)
Defines the PartitioningSolution class.
void partition(const RCP< PartitioningSolution< Adapter > > &solution)
Partitioning method.
SparseMatrixAdapter_t::part_t part_t
CommGraphModel defines the interface required for communication graph.
A PartitioningSolution is a solution to a partitioning problem.
VectorAdapter defines the interface for vector input.
Algorithm defines the base class for all algorithms.
static RCP< Teuchos::AnyNumberParameterEntryValidator > getAnyIntValidator()
Exists to make setting up validators less cluttered.
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const VectorAdapter< user_t > > &adapter__, const modelFlag_t &graphFlags_)
Adapter::userCoord_t userCoord_t
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const IdentifierAdapter< user_t > > &adapter__, const modelFlag_t &graphFlags_)
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const GraphAdapter< user_t, userCoord_t > > &adapter__, const modelFlag_t &graphFlags_)
static void getValidParameters(ParameterList &pl)
Set up validators specific to this algorithm.
A gathering of useful namespace methods.
Adapter::base_adapter_t base_adapter_t
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t