50 #ifndef _ZOLTAN2_ORDERINGPROBLEM_HPP_ 51 #define _ZOLTAN2_ORDERINGPROBLEM_HPP_ 60 #ifdef HAVE_ZOLTAN2_OVIS 66 using Teuchos::rcp_dynamic_cast;
90 template<
typename Adapter>
96 typedef typename Adapter::gno_t
gno_t;
97 typedef typename Adapter::lno_t
lno_t;
98 typedef typename Adapter::user_t
user_t;
101 #ifdef HAVE_ZOLTAN2_MPI 102 typedef Teuchos::OpaqueWrapper<MPI_Comm> mpiWrapper_t;
110 const RCP<
const Teuchos::Comm<int> > &comm) :
114 createOrderingProblem();
117 #ifdef HAVE_ZOLTAN2_MPI 122 rcp<
const Comm<int> >(
new Teuchos::MpiComm<int>(
123 Teuchos::opaqueWrapper(mpicomm))))
137 RCP<Teuchos::StringValidator> order_method_Validator =
138 Teuchos::rcp(
new Teuchos::StringValidator(
139 Teuchos::tuple<std::string>(
"rcm",
"minimum_degree",
"natural",
140 "random",
"sorted_degree",
"scotch",
"nd" )));
141 pl.set(
"order_method",
"rcm",
"order algorithm",
142 order_method_Validator);
144 RCP<Teuchos::StringValidator> order_method_type_Validator =
145 Teuchos::rcp(
new Teuchos::StringValidator(
146 Teuchos::tuple<std::string>(
"local",
"global",
"both" )));
147 pl.set(
"order_method_type",
"local",
"local or global or both",
148 order_method_type_Validator);
150 RCP<Teuchos::StringValidator> order_package_Validator = Teuchos::rcp(
151 new Teuchos::StringValidator(
152 Teuchos::tuple<std::string>(
"amd",
"package2",
"package3" )));
153 pl.set(
"order_package",
"amd",
"package to use in ordering",
154 order_package_Validator);
173 void solve(
bool updateInputData=
true);
180 if(localOrderingSolution_ == Teuchos::null) {
181 throw std::logic_error(
"OrderingProblem was not created with local" 182 " ordering. Set parameter order_method_type to local or both." 183 " Or use getGlobalOrderingSolution()." );
185 return setupSolution(localOrderingSolution_);
193 if(globalOrderingSolution_ == Teuchos::null) {
194 throw std::logic_error(
"OrderingProblem was not created with global" 195 " ordering. Set parameter order_method_type to global or both." 196 " Or use getLocalOrderingSolution()." );
198 return setupSolution(globalOrderingSolution_);
202 template<
typename ordering_solution_t>
203 ordering_solution_t *setupSolution(RCP<ordering_solution_t> solution) {
207 if (!(solution->havePerm()))
208 solution->computePerm();
209 if (!(solution->haveInverse()))
210 solution->computeInverse();
211 return solution.getRawPtr();
214 void createOrderingProblem();
217 RCP<LocalOrderingSolution<lno_t> > localOrderingSolution_;
218 RCP<GlobalOrderingSolution<gno_t> > globalOrderingSolution_;
223 template <
typename Adapter>
228 size_t nVtx = this->
baseModel_->getLocalNumObjects();
233 std::string method_type = this->
params_->template
234 get<std::string>(
"order_method_type",
"local");
236 if(method_type ==
"local" || method_type ==
"both") {
239 if(method_type ==
"global" || method_type ==
"both") {
249 std::string method = this->
params_->template
250 get<std::string>(
"order_method",
"rcm");
259 #define ZOLTAN2_COMPUTE_ORDERING \ 260 if(localOrderingSolution_ != Teuchos::null) { \ 261 alg.localOrder(localOrderingSolution_); \ 263 if(globalOrderingSolution_ != Teuchos::null) { \ 264 alg.globalOrder(globalOrderingSolution_); \ 267 if (method.compare(
"rcm") == 0) {
271 else if (method.compare(
"natural") == 0) {
276 else if (method.compare(
"random") == 0) {
281 else if (method.compare(
"sorted_degree") == 0) {
286 else if (method.compare(
"minimum_degree") == 0) {
287 std::string pkg = this->
params_->template get<std::string>(
288 "order_package",
"amd");
289 if (pkg.compare(
"amd") == 0)
296 else if (method.compare(
"scotch") == 0) {
302 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL_WOLF 303 else if (method.compare(
"nd") == 0) {
327 template <
typename Adapter>
331 using Teuchos::ParameterList;
339 std::string method = this->
params_->template
340 get<std::string>(
"order_method",
"rcm");
342 if ((method == std::string(
"rcm")) ||
343 (method == std::string(
"sorted_degree")) ||
344 (method == std::string(
"minimum_degree"))) {
348 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL_WOLF 349 if ((method == std::string(
"nd")))
358 std::bitset<NUM_MODEL_FLAGS> graphFlags;
359 std::bitset<NUM_MODEL_FLAGS> idFlags;
383 this->
baseModel_ = rcp_implicit_cast<
const Model<base_adapter_t> >(
391 <<
" Model type " << modelType <<
" not yet supported." RCP< GraphModel< base_adapter_t > > graphModel_
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
RCP< const base_adapter_t > baseInputAdapter_
ModelType
An identifier for the general type of model.
virtual ~OrderingProblem()
Destructor.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the OrderingSolution class.
RCP< const Comm< int > > comm_
RCP< IdentifierModel< base_adapter_t > > identifierModel_
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.
RCP< const Comm< int > > getComm()
Return the communicator used by the problem.
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
RCP< CoordinateModel< base_adapter_t > > coordinateModel_
Defines the Zoltan2_EvaluateOrdering.hpp class.
GlobalOrderingSolution< gno_t > * getGlobalOrderingSolution()
Get the global ordering solution to the problem.
GraphModel defines the interface required for graph models.
The base class for all model classes.
RCP< ParameterList > params_
IdentifierModel defines the interface for all identifier models.
Defines the GraphModel interface.
RCP< const Model< base_adapter_t > > baseModel_
static void getValidParameters(ParameterList &pl)
Set up validators specific to this Problem.
model represents graph within only one rank
RCP< const Environment > envConst_
#define __func__zoltan2__
LocalOrderingSolution< lno_t > * getLocalOrderingSolution()
Get the local ordering solution to the problem.