50 #ifndef _ZOLTAN2_ORDERINGPROBLEM_HPP_
51 #define _ZOLTAN2_ORDERINGPROBLEM_HPP_
60 #ifdef HAVE_ZOLTAN2_OVIS
70 using Teuchos::rcp_dynamic_cast;
94 template<
typename Adapter>
105 #ifdef HAVE_ZOLTAN2_MPI
106 typedef Teuchos::OpaqueWrapper<MPI_Comm> mpiWrapper_t;
114 const RCP<
const Teuchos::Comm<int> > &comm) :
118 createOrderingProblem();
121 #ifdef HAVE_ZOLTAN2_MPI
126 rcp<const Comm<int> >(new Teuchos::MpiComm<int>(
127 Teuchos::opaqueWrapper(mpicomm))))
142 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
146 RCP<Teuchos::StringValidator> order_method_Validator =
147 Teuchos::rcp(
new Teuchos::StringValidator(
148 Teuchos::tuple<std::string>(
"rcm",
"metis",
"minimum_degree",
"natural",
149 "random",
"sorted_degree",
"scotch",
"nd" )));
150 pl.set(
"order_method",
"rcm",
"order algorithm",
151 order_method_Validator);
153 RCP<Teuchos::StringValidator> order_method_type_Validator =
154 Teuchos::rcp(
new Teuchos::StringValidator(
155 Teuchos::tuple<std::string>(
"local",
"global",
"both" )));
156 pl.set(
"order_method_type",
"local",
"local or global or both",
157 order_method_type_Validator);
159 RCP<Teuchos::StringValidator> order_package_Validator = Teuchos::rcp(
160 new Teuchos::StringValidator(
161 Teuchos::tuple<std::string>(
"amd",
"package2",
"package3" )));
162 pl.set(
"order_package",
"amd",
"package to use in ordering",
163 order_package_Validator);
165 RCP<Teuchos::StringValidator> rcm_root_selection_Validator = Teuchos::rcp(
166 new Teuchos::StringValidator(
167 Teuchos::tuple<std::string>(
"pseudoperipheral",
"first",
"smallest_degree" )));
168 pl.set(
"root_method",
"pseudoperipheral",
"method for selecting RCM root",
169 rcm_root_selection_Validator);
188 void solve(
bool updateInputData=
true);
195 if(localOrderingSolution_ == Teuchos::null) {
196 throw std::logic_error(
"OrderingProblem was not created with local"
197 " ordering. Set parameter order_method_type to local or both."
198 " Or use getGlobalOrderingSolution()." );
200 return setupSolution(localOrderingSolution_);
208 if(globalOrderingSolution_ == Teuchos::null) {
209 throw std::logic_error(
"OrderingProblem was not created with global"
210 " ordering. Set parameter order_method_type to global or both."
211 " Or use getLocalOrderingSolution()." );
213 return setupSolution(globalOrderingSolution_);
217 template<
typename ordering_solution_t>
218 ordering_solution_t *setupSolution(RCP<ordering_solution_t> solution) {
222 if (!(solution->havePerm()))
223 solution->computePerm();
224 if (!(solution->haveInverse()))
225 solution->computeInverse();
226 return solution.getRawPtr();
229 void createOrderingProblem();
232 RCP<LocalOrderingSolution<lno_t> > localOrderingSolution_;
233 RCP<GlobalOrderingSolution<gno_t> > globalOrderingSolution_;
235 size_t localNumObjects_;
239 template <
typename Adapter>
247 std::string method_type = this->params_->template
248 get<std::string>(
"order_method_type",
"local");
250 if(method_type ==
"local" || method_type ==
"both") {
253 if(method_type ==
"global" || method_type ==
"both") {
263 std::string method = this->params_->template
264 get<std::string>(
"order_method",
"rcm");
273 #define ZOLTAN2_COMPUTE_ORDERING \
274 if(localOrderingSolution_ != Teuchos::null) { \
275 alg.localOrder(localOrderingSolution_); \
277 if(globalOrderingSolution_ != Teuchos::null) { \
278 alg.globalOrder(globalOrderingSolution_); \
285 if (method.compare(
"rcm") == 0) {
287 this->comm_, this->envConst_, graphFlags);
290 else if (method.compare(
"natural") == 0) {
292 this->comm_, this->envConst_);
295 else if (method.compare(
"random") == 0) {
297 this->comm_, this->envConst_);
300 else if (method.compare(
"sorted_degree") == 0) {
302 this->comm_, this->envConst_,
306 else if (method.compare(
"metis") == 0) {
308 this->comm_, this->envConst_, graphFlags);
311 else if (method.compare(
"minimum_degree") == 0) {
312 std::string pkg = this->params_->template get<std::string>(
313 "order_package",
"amd");
314 if (pkg.compare(
"amd") == 0)
317 this->params_, this->comm_, this->envConst_, graphFlags);
321 else if (method.compare(
"scotch") == 0) {
323 this->baseInputAdapter_);
327 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
328 else if (method.compare(
"nd") == 0) {
351 template <
typename Adapter>
355 using Teuchos::ParameterList;
363 std::string method = this->params_->template
364 get<std::string>(
"order_method",
"rcm");
366 if ((method == std::string(
"rcm")) ||
367 (method == std::string(
"sorted_degree")) ||
368 (method == std::string(
"metis")) ||
369 (method == std::string(
"minimum_degree"))) {
373 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
374 if ((method == std::string(
"nd")))
390 const auto adapterType = this->baseInputAdapter_->adapterType();
400 localNumObjects_ = this->baseInputAdapter_->getLocalNumIDs();
406 const auto ia =
dynamic_cast<const GraphAdapter<user_t> *
>(&(*(this->baseInputAdapter_)));
407 localNumObjects_ = ia->getLocalNumVertices();
413 const auto ia =
dynamic_cast<const MeshAdapter<user_t> *
>(&(*(this->baseInputAdapter_)));
414 localNumObjects_ = ia->getLocalNumOf(ia->getPrimaryEntityType());
427 localNumObjects_ = this->baseInputAdapter_->getLocalNumIDs();
435 <<
" Model type " << modelType <<
" not yet supported."
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
ModelType
An identifier for the general type of model.
virtual ~OrderingProblem()
Destructor.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
map_t::global_ordinal_type gno_t
Defines the OrderingSolution class.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this algorithm.
OrderingProblem sets up ordering problems for the user.
algorithm requires no self edges
#define ZOLTAN2_COMPUTE_ORDERING
OrderingProblem(Adapter *A, ParameterList *p, const RCP< const Teuchos::Comm< int > > &comm)
OrderingProblem(Adapter *A, ParameterList *p)
Constructor that uses a default communicator.
Problem base class from which other classes (PartitioningProblem, ColoringProblem, OrderingProblem, MatchingProblem, etc.) derive.
void solve(bool updateInputData=true)
Direct the problem to create a solution.
Adapter::scalar_t scalar_t
Defines the Problem base class.
Adapter::base_adapter_t base_adapter_t
map_t::local_ordinal_type lno_t
Defines the Zoltan2_EvaluateOrdering.hpp class.
GlobalOrderingSolution< gno_t > * getGlobalOrderingSolution()
Get the global ordering solution to the problem.
Defines the GraphModel interface.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this Problem.
model represents graph within only one rank
#define __func__zoltan2__
LocalOrderingSolution< lno_t > * getLocalOrderingSolution()
Get the local ordering solution to the problem.
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t