14#ifndef _ZOLTAN2_ORDERINGPROBLEM_HPP_
15#define _ZOLTAN2_ORDERINGPROBLEM_HPP_
24#ifdef HAVE_ZOLTAN2_OVIS
34using Teuchos::rcp_dynamic_cast;
58template<
typename Adapter>
64 typedef typename Adapter::gno_t
gno_t;
65 typedef typename Adapter::lno_t
lno_t;
66 typedef typename Adapter::user_t
user_t;
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_;
203template <
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) {
254 else if (method.compare(
"natural") == 0) {
259 else if (method.compare(
"random") == 0) {
264 else if (method.compare(
"sorted_degree") == 0) {
270 else if (method.compare(
"metis") == 0) {
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)
285 else if (method.compare(
"scotch") == 0) {
291#ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
292 else if (method.compare(
"nd") == 0) {
315template <
typename Adapter>
316void OrderingProblem<Adapter>::createOrderingProblem()
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();
378 localNumObjects_ = ia->
getLocalNumOf(ia->getPrimaryEntityType());
391 localNumObjects_ = this->baseInputAdapter_->getLocalNumIDs();
399 <<
" Model type " << modelType <<
" not yet supported."
Defines the Zoltan2_EvaluateOrdering.hpp class.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
#define __func__zoltan2__
Defines the GraphModel interface.
#define ZOLTAN2_COMPUTE_ORDERING
Defines the OrderingSolution class.
Defines the Problem base class.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this algorithm.
GraphAdapter defines the interface for graph-based user data.
virtual size_t getLocalNumVertices() const =0
Returns the number of vertices on this process.
MeshAdapter defines the interface for mesh input.
virtual size_t getLocalNumOf(MeshEntityType etype) const =0
Returns the global number of mesh entities of MeshEntityType.
OrderingProblem sets up ordering problems for the user.
Adapter::scalar_t scalar_t
virtual ~OrderingProblem()
Destructor.
Adapter::base_adapter_t base_adapter_t
void solve(bool updateInputData=true)
Direct the problem to create a solution.
LocalOrderingSolution< lno_t > * getLocalOrderingSolution()
Get the local ordering solution to the problem.
OrderingProblem(Adapter *A, ParameterList *p, const RCP< const Teuchos::Comm< int > > &comm)
static void getValidParameters(ParameterList &pl)
Set up validators specific to this Problem.
OrderingProblem(Adapter *A, ParameterList *p)
Constructor that uses a default communicator.
GlobalOrderingSolution< gno_t > * getGlobalOrderingSolution()
Get the global ordering solution to the problem.
RCP< const Environment > envConst_
RCP< const base_adapter_t > baseInputAdapter_
Problem(const Adapter *input, ParameterList *params, const RCP< const Comm< int > > &comm)
Constructor where Teuchos communicator is specified.
RCP< ParameterList > params_
RCP< const Comm< int > > comm_
Created by mbenlioglu on Aug 31, 2020.
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
ModelType
An identifier for the general type of model.
@ GraphAdapterType
graph data
@ MatrixAdapterType
matrix data
@ MeshAdapterType
mesh data
@ REMOVE_SELF_EDGES
algorithm requires no self edges
@ BUILD_LOCAL_GRAPH
model represents graph within only one rank