73 typedef typename Adapter::part_t
part_t;
74 typedef typename Adapter::user_t
user_t;
76 typedef CommGraphModel<typename Adapter::base_adapter_t>
graphModel_t;
87 const RCP<
const Comm<int> > &problemComm__,
88 const RCP<
const IdentifierAdapter<user_t> > &adapter__,
90 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
92 std::string errStr =
"cannot build CommGraphModel from IdentifierAdapter, ";
93 errStr +=
"AlgQuotient requires Graph Adapter";
94 throw std::runtime_error(errStr);
98 const RCP<
const Comm<int> > &problemComm__,
99 const RCP<
const VectorAdapter<user_t> > &adapter__,
101 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
103 std::string errStr =
"cannot build CommGraphModel from VectorAdapter, ";
104 errStr +=
"AlgQuotient requires Graph Adapter";
105 throw std::runtime_error(errStr);
109 const RCP<
const Comm<int> > &problemComm__,
110 const RCP<
const MatrixAdapter<user_t,userCoord_t> > &adapter__,
112 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
114 std::string errStr =
"cannot build CommGraphModel from MatrixAdapter, ";
115 errStr +=
"AlgQuotient has not been implemented for Matrix Adapter yet.";
116 throw std::runtime_error(errStr);
120 const RCP<
const Comm<int> > &problemComm__,
121 const RCP<
const MeshAdapter<user_t> > &adapter__,
123 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
125 std::string errStr =
"cannot build CommGraphModel from MeshAdapter, ";
126 errStr +=
"AlgQuotient has not been implemented for Mesh Adapter yet.";
127 throw std::runtime_error(errStr);
131 const RCP<
const Comm<int> > &problemComm__,
132 const RCP<
const GraphAdapter<user_t,userCoord_t> > &adapter__,
134 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
136 this->innerAlgorithm =
137 rcp(
new AlgParMETIS<Adapter, graphModel_t>(env, problemComm, adapter, graphFlags));
144 pl.set(
"quotient_threshold", 1,
"threshold for the number of vertices on the active ranks",
148 void partition(
const RCP<PartitioningSolution<Adapter> > &solution);
149 void migrateBack(
const RCP<PartitioningSolution<Adapter> > &solution);
153 const RCP<const Environment> env;
154 const RCP<const Comm<int> > problemComm;
155 const RCP<const base_adapter_t> adapter;
158 RCP<Algorithm<Adapter>> innerAlgorithm;
159 RCP<PartitioningSolution<Adapter>> quotientSolution;
167 const RCP<PartitioningSolution<Adapter> > &solution
173 PartitioningSolution<Adapter> *soln = NULL;
175 soln =
new PartitioningSolution<Adapter>(env, problemComm, 1);
178 quotientSolution = rcp(soln);
181 this->innerAlgorithm->partition(quotientSolution);
186 migrateBack(solution);
188 env->memory(
"Zoltan2-Quotient: After creating solution");
201 const RCP<PartitioningSolution<Adapter> > &solution
204 const auto model = rcp(
new CommGraphModel<base_adapter_t>(
205 this->adapter, this->env, this->problemComm));
206 int me = problemComm->getRank();
207 int nActiveRanks = model->getNumActiveRanks();
208 int dRank = model->getDestinationRank();
211 Teuchos::ArrayRCP<part_t> parts(1);
212 RCP<CommRequest<int>> *requests =
new RCP<CommRequest<int>>[1];
213 requests[0] = Teuchos::ireceive<int, part_t>(*problemComm, parts, dRank);
214 if (me < nActiveRanks) {
216 const part_t *qtntSlnView = quotientSolution->getPartListView();
218 int sRank = model->getStartRank();
219 int eRank = model->getEndRank();
221 ArrayView<size_t> vtxdist;
222 model->getVertexDist(vtxdist);
223 for (
int i = sRank; i < eRank; i++)
224 Teuchos::send<int, part_t>(*problemComm, 1, &qtntSlnView[i - sRank], i);
226 Teuchos::waitAll<int>(*problemComm, Teuchos::arrayView(requests, 1));
229 size_t numLocalVertices = adapter->getLocalNumIDs();
230 Teuchos::ArrayRCP<part_t> extendedParts(numLocalVertices);
231 for(
size_t i = 0; i < numLocalVertices; i++)
232 extendedParts[i] = parts[0];
235 solution->setParts(extendedParts);
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_)
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_)