14 #ifndef _ZOLTAN2_ORDERINGPROBLEM_HPP_
15 #define _ZOLTAN2_ORDERINGPROBLEM_HPP_
24 #ifdef HAVE_ZOLTAN2_OVIS
34 using Teuchos::rcp_dynamic_cast;
58 template<
typename Adapter>
69 #ifdef HAVE_ZOLTAN2_MPI
70 typedef Teuchos::OpaqueWrapper<MPI_Comm> mpiWrapper_t;
78 const RCP<
const Teuchos::Comm<int> > &comm) :
82 createOrderingProblem();
85 #ifdef HAVE_ZOLTAN2_MPI
90 rcp<const Comm<int> >(new Teuchos::MpiComm<int>(
91 Teuchos::opaqueWrapper(mpicomm))))
106 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
110 RCP<Teuchos::StringValidator> order_method_Validator =
111 Teuchos::rcp(
new Teuchos::StringValidator(
112 Teuchos::tuple<std::string>(
"rcm",
"metis",
"minimum_degree",
"natural",
113 "random",
"sorted_degree",
"scotch",
"nd" )));
114 pl.set(
"order_method",
"rcm",
"order algorithm",
115 order_method_Validator);
117 RCP<Teuchos::StringValidator> order_method_type_Validator =
118 Teuchos::rcp(
new Teuchos::StringValidator(
119 Teuchos::tuple<std::string>(
"local",
"global",
"both" )));
120 pl.set(
"order_method_type",
"local",
"local or global or both",
121 order_method_type_Validator);
123 RCP<Teuchos::StringValidator> order_package_Validator = Teuchos::rcp(
124 new Teuchos::StringValidator(
125 Teuchos::tuple<std::string>(
"amd",
"package2",
"package3" )));
126 pl.set(
"order_package",
"amd",
"package to use in ordering",
127 order_package_Validator);
129 RCP<Teuchos::StringValidator> rcm_root_selection_Validator = Teuchos::rcp(
130 new Teuchos::StringValidator(
131 Teuchos::tuple<std::string>(
"pseudoperipheral",
"first",
"smallest_degree" )));
132 pl.set(
"root_method",
"pseudoperipheral",
"method for selecting RCM root",
133 rcm_root_selection_Validator);
152 void solve(
bool updateInputData=
true);
159 if(localOrderingSolution_ == Teuchos::null) {
160 throw std::logic_error(
"OrderingProblem was not created with local"
161 " ordering. Set parameter order_method_type to local or both."
162 " Or use getGlobalOrderingSolution()." );
164 return setupSolution(localOrderingSolution_);
172 if(globalOrderingSolution_ == Teuchos::null) {
173 throw std::logic_error(
"OrderingProblem was not created with global"
174 " ordering. Set parameter order_method_type to global or both."
175 " Or use getLocalOrderingSolution()." );
177 return setupSolution(globalOrderingSolution_);
181 template<
typename ordering_solution_t>
182 ordering_solution_t *setupSolution(RCP<ordering_solution_t> solution) {
186 if (!(solution->havePerm()))
187 solution->computePerm();
188 if (!(solution->haveInverse()))
189 solution->computeInverse();
190 return solution.getRawPtr();
193 void createOrderingProblem();
196 RCP<LocalOrderingSolution<lno_t> > localOrderingSolution_;
197 RCP<GlobalOrderingSolution<gno_t> > globalOrderingSolution_;
199 size_t localNumObjects_;
203 template <
typename Adapter>
211 std::string method_type = this->params_->template
212 get<std::string>(
"order_method_type",
"local");
214 if(method_type ==
"local" || method_type ==
"both") {
217 if(method_type ==
"global" || method_type ==
"both") {
227 std::string method = this->params_->template
228 get<std::string>(
"order_method",
"rcm");
237 #define ZOLTAN2_COMPUTE_ORDERING \
238 if(localOrderingSolution_ != Teuchos::null) { \
239 alg.localOrder(localOrderingSolution_); \
241 if(globalOrderingSolution_ != Teuchos::null) { \
242 alg.globalOrder(globalOrderingSolution_); \
249 if (method.compare(
"rcm") == 0) {
251 this->comm_, this->envConst_, graphFlags);
254 else if (method.compare(
"natural") == 0) {
256 this->comm_, this->envConst_);
259 else if (method.compare(
"random") == 0) {
261 this->comm_, this->envConst_);
264 else if (method.compare(
"sorted_degree") == 0) {
266 this->comm_, this->envConst_,
270 else if (method.compare(
"metis") == 0) {
272 this->comm_, this->envConst_, graphFlags);
275 else if (method.compare(
"minimum_degree") == 0) {
276 std::string pkg = this->params_->template get<std::string>(
277 "order_package",
"amd");
278 if (pkg.compare(
"amd") == 0)
281 this->params_, this->comm_, this->envConst_, graphFlags);
285 else if (method.compare(
"scotch") == 0) {
287 this->baseInputAdapter_);
291 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
292 else if (method.compare(
"nd") == 0) {
315 template <
typename Adapter>
319 using Teuchos::ParameterList;
327 std::string method = this->params_->template
328 get<std::string>(
"order_method",
"rcm");
330 if ((method == std::string(
"rcm")) ||
331 (method == std::string(
"sorted_degree")) ||
332 (method == std::string(
"metis")) ||
333 (method == std::string(
"minimum_degree"))) {
337 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
338 if ((method == std::string(
"nd")))
354 const auto adapterType = this->baseInputAdapter_->adapterType();
364 localNumObjects_ = this->baseInputAdapter_->getLocalNumIDs();
370 const auto ia =
dynamic_cast<const GraphAdapter<user_t> *
>(&(*(this->baseInputAdapter_)));
371 localNumObjects_ = ia->getLocalNumVertices();
377 const auto ia =
dynamic_cast<const MeshAdapter<user_t> *
>(&(*(this->baseInputAdapter_)));
378 localNumObjects_ = ia->getLocalNumOf(ia->getPrimaryEntityType());
391 localNumObjects_ = this->baseInputAdapter_->getLocalNumIDs();
399 <<
" 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