45 #ifndef _ZOLTAN2_ALGQUOTIENT_HPP_
46 #define _ZOLTAN2_ALGQUOTIENT_HPP_
68 template <
typename Adapter>
87 const RCP<
const Comm<int> > &problemComm__,
89 env(env__), problemComm(problemComm__), adapter(adapter__)
91 std::string errStr =
"cannot build CommGraphModel from IdentifierAdapter, ";
92 errStr +=
"AlgQuotient requires Graph Adapter";
93 throw std::runtime_error(errStr);
97 const RCP<
const Comm<int> > &problemComm__,
99 env(env__), problemComm(problemComm__), adapter(adapter__)
101 std::string errStr =
"cannot build CommGraphModel from VectorAdapter, ";
102 errStr +=
"AlgQuotient requires Graph Adapter";
103 throw std::runtime_error(errStr);
107 const RCP<
const Comm<int> > &problemComm__,
109 env(env__), problemComm(problemComm__), adapter(adapter__)
111 std::string errStr =
"cannot build CommGraphModel from MatrixAdapter, ";
112 errStr +=
"AlgQuotient has not been implemented for Matrix Adapter yet.";
113 throw std::runtime_error(errStr);
117 const RCP<
const Comm<int> > &problemComm__,
119 env(env__), problemComm(problemComm__), adapter(adapter__)
121 std::string errStr =
"cannot build CommGraphModel from MeshAdapter, ";
122 errStr +=
"AlgQuotient has not been implemented for Mesh Adapter yet.";
123 throw std::runtime_error(errStr);
127 const RCP<
const Comm<int> > &problemComm__,
129 env(env__), problemComm(problemComm__), adapter(adapter__)
141 pl.set(
"quotient_threshold", 1,
"threshold for the number of vertices on the active ranks",
152 const RCP<const Environment> env;
153 const RCP<const Comm<int> > problemComm;
154 const RCP<const base_adapter_t> adapter;
155 RCP<graphModel_t> model;
157 RCP<Algorithm<Adapter>> innerAlgorithm;
158 RCP<PartitioningSolution<Adapter>> quotientSolution;
164 template <
typename Adapter>
165 void AlgQuotient<Adapter>::buildModel()
167 this->env->debug(
DETAILED_STATUS,
" building communication graph model");
168 this->model = rcp(
new CommGraphModel<base_adapter_t>(
169 this->adapter, this->env, this->problemComm));
174 template <
typename Adapter>
187 quotientSolution = rcp(soln);
190 this->innerAlgorithm->partition(quotientSolution);
195 migrateBack(solution);
197 env->memory(
"Zoltan2-Quotient: After creating solution");
208 template <
typename Adapter>
213 int me = problemComm->getRank();
214 int nActiveRanks = model->getNumActiveRanks();
215 int dRank = model->getDestinationRank();
218 Teuchos::ArrayRCP<part_t> parts(1);
219 RCP<CommRequest<int>> *requests =
new RCP<CommRequest<int>>[1];
220 requests[0] = Teuchos::ireceive<int, part_t>(*problemComm, parts, dRank);
221 if(me < nActiveRanks){
223 const part_t *qtntSlnView = quotientSolution->getPartListView();
225 int sRank = model->getStartRank();
226 int eRank = model->getEndRank();
228 ArrayView<size_t> vtxdist;
229 model->getVertexDist(vtxdist);
230 for(
int i = sRank; i < eRank; i++)
231 Teuchos::send<int, part_t>(*problemComm, 1, &qtntSlnView[i-sRank], i);
233 Teuchos::waitAll<int>(*problemComm, Teuchos::arrayView(requests, 1));
236 size_t numLocalVertices = adapter->getLocalNumIDs();
237 Teuchos::ArrayRCP<part_t> extendedParts(numLocalVertices);
238 for(
size_t i = 0; i < numLocalVertices; i++)
239 extendedParts[i] = parts[0];
242 solution->setParts(extendedParts);
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the PartitioningSolution class.
A gathering of useful namespace methods.
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const MeshAdapter< user_t > > &adapter__)
CommGraphModel< typename Adapter::base_adapter_t > graphModel_t
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const VectorAdapter< user_t > > &adapter__)
void partition(const RCP< PartitioningSolution< Adapter > > &solution)
Partitioning method.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this algorithm.
void migrateBack(const RCP< PartitioningSolution< Adapter > > &solution)
Adapter::base_adapter_t base_adapter_t
Adapter::userCoord_t userCoord_t
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const IdentifierAdapter< user_t > > &adapter__)
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const GraphAdapter< user_t, userCoord_t > > &adapter__)
AlgQuotient(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const MatrixAdapter< user_t, userCoord_t > > &adapter__)
Algorithm defines the base class for all algorithms.
CommGraphModel defines the interface required for communication graph.
static RCP< Teuchos::AnyNumberParameterEntryValidator > getAnyIntValidator()
Exists to make setting up validators less cluttered.
GraphAdapter defines the interface for graph-based user data.
IdentifierAdapter defines the interface for identifiers.
MatrixAdapter defines the adapter interface for matrices.
MeshAdapter defines the interface for mesh input.
A PartitioningSolution is a solution to a partitioning problem.
VectorAdapter defines the interface for vector input.
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
Created by mbenlioglu on Aug 31, 2020.
@ DETAILED_STATUS
sub-steps, each method's entry and exit
SparseMatrixAdapter_t::part_t part_t