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);
135 pl.set(
"symmetrize",
false,
"Whether the input graph should be symmetrizes");
154 void solve(
bool updateInputData=
true);
161 if(localOrderingSolution_ == Teuchos::null) {
162 throw std::logic_error(
"OrderingProblem was not created with local"
163 " ordering. Set parameter order_method_type to local or both."
164 " Or use getGlobalOrderingSolution()." );
166 return setupSolution(localOrderingSolution_);
174 if(globalOrderingSolution_ == Teuchos::null) {
175 throw std::logic_error(
"OrderingProblem was not created with global"
176 " ordering. Set parameter order_method_type to global or both."
177 " Or use getLocalOrderingSolution()." );
179 return setupSolution(globalOrderingSolution_);
183 template<
typename ordering_solution_t>
184 ordering_solution_t *setupSolution(RCP<ordering_solution_t> solution) {
188 if (!(solution->havePerm()))
189 solution->computePerm();
190 if (!(solution->haveInverse()))
191 solution->computeInverse();
192 return solution.getRawPtr();
195 void createOrderingProblem();
198 RCP<LocalOrderingSolution<lno_t> > localOrderingSolution_;
199 RCP<GlobalOrderingSolution<gno_t> > globalOrderingSolution_;
201 size_t localNumObjects_;
205 template <
typename Adapter>
213 std::string method_type = this->params_->template
214 get<std::string>(
"order_method_type",
"local");
216 if(method_type ==
"local" || method_type ==
"both") {
219 if(method_type ==
"global" || method_type ==
"both") {
229 std::string method = this->params_->template
230 get<std::string>(
"order_method",
"rcm");
239 #define ZOLTAN2_COMPUTE_ORDERING \
240 if(localOrderingSolution_ != Teuchos::null) { \
241 alg.localOrder(localOrderingSolution_); \
243 if(globalOrderingSolution_ != Teuchos::null) { \
244 alg.globalOrder(globalOrderingSolution_); \
251 if (method.compare(
"rcm") == 0) {
253 this->comm_, this->envConst_, graphFlags);
256 else if (method.compare(
"natural") == 0) {
258 this->comm_, this->envConst_);
261 else if (method.compare(
"random") == 0) {
263 this->comm_, this->envConst_);
266 else if (method.compare(
"sorted_degree") == 0) {
268 this->comm_, this->envConst_,
272 else if (method.compare(
"metis") == 0) {
274 this->comm_, this->envConst_, graphFlags);
277 else if (method.compare(
"minimum_degree") == 0) {
278 std::string pkg = this->params_->template get<std::string>(
279 "order_package",
"amd");
280 if (pkg.compare(
"amd") == 0)
283 this->params_, this->comm_, this->envConst_, graphFlags);
287 else if (method.compare(
"scotch") == 0) {
289 this->baseInputAdapter_);
293 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
294 else if (method.compare(
"nd") == 0) {
317 template <
typename Adapter>
321 using Teuchos::ParameterList;
329 std::string method = this->params_->template
330 get<std::string>(
"order_method",
"rcm");
332 if ((method == std::string(
"rcm")) ||
333 (method == std::string(
"sorted_degree")) ||
334 (method == std::string(
"metis")) ||
335 (method == std::string(
"minimum_degree"))) {
339 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
340 if ((method == std::string(
"nd")))
356 const auto adapterType = this->baseInputAdapter_->adapterType();
366 localNumObjects_ = this->baseInputAdapter_->getLocalNumIDs();
372 const auto ia =
dynamic_cast<const GraphAdapter<user_t> *
>(&(*(this->baseInputAdapter_)));
373 localNumObjects_ = ia->getLocalNumVertices();
379 const auto ia =
dynamic_cast<const MeshAdapter<user_t> *
>(&(*(this->baseInputAdapter_)));
380 localNumObjects_ = ia->getLocalNumOf(ia->getPrimaryEntityType());
393 localNumObjects_ = this->baseInputAdapter_->getLocalNumIDs();
401 <<
" 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