45 #ifndef _ZOLTAN2_ALGQUOTIENT_HPP_
46 #define _ZOLTAN2_ALGQUOTIENT_HPP_
68 template <
typename Adapter>
87 const RCP<
const Comm<int> > &problemComm__,
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__,
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__,
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__,
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__,
134 env(env__), problemComm(problemComm__), adapter(adapter__), graphFlags(graphFlags_)
136 this->innerAlgorithm =
144 pl.set(
"quotient_threshold", 1,
"threshold for the number of vertices on the active ranks",
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;
165 template <
typename Adapter>
178 quotientSolution = rcp(soln);
181 this->innerAlgorithm->partition(quotientSolution);
186 migrateBack(solution);
188 env->memory(
"Zoltan2-Quotient: After creating solution");
199 template <
typename Adapter>
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);
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