Zoltan2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Zoltan2_AlgNatural.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Zoltan2: A package of combinatorial algorithms for scientific computing
4 //
5 // Copyright 2012 NTESS and the Zoltan2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef _ZOLTAN2_ALGNATURAL_HPP_
11 #define _ZOLTAN2_ALGNATURAL_HPP_
12 
13 #include <Zoltan2_Algorithm.hpp>
16 
17 
18 namespace Zoltan2{
19 
24 
25 template <typename Adapter>
26 class AlgNatural : public Algorithm<Adapter>
27 {
28  private:
29 
30  const RCP<const typename Adapter::base_adapter_t> adapter;
31  const RCP<Teuchos::ParameterList> pl;
32  const RCP<const Teuchos::Comm<int> > comm;
33  const RCP<const Environment> env;
34 
35  public:
36 
37  typedef typename Adapter::lno_t lno_t;
38  typedef typename Adapter::gno_t gno_t;
39 
41  const RCP<const typename Adapter::base_adapter_t> &adapter__,
42  const RCP<Teuchos::ParameterList> &pl__,
43  const RCP<const Teuchos::Comm<int> > &comm__,
44  const RCP<const Environment> &env__
45  ) : adapter(adapter__), pl(pl__), comm(comm__), env(env__)
46  {
47  }
48 
49  int globalOrder(const RCP<GlobalOrderingSolution<gno_t> > &/* solution */) {
50  throw std::logic_error("AlgNatural does not yet support global ordering.");
51  }
52 
53  int localOrder(const RCP<LocalOrderingSolution<lno_t> > &solution)
54  {
55 
56  int ierr= 0;
57 
58  HELLO;
59 
60  // Local permutation only for now.
61 
62  // Set identity permutation.
63  modelFlag_t modelFlags;
64  const auto model = rcp(new IdentifierModel<Adapter>(adapter, env, comm, modelFlags));
65  const size_t n = model->getLocalNumIdentifiers();
66  lno_t *perm = solution->getPermutationView();
67  if (perm){
68  for (size_t i=0; i<n; i++){
69  perm[i] = i;
70  }
71  }
72  else
73  // TODO: throw exception?
74  ierr = -1;
75 
76  solution->setHavePerm(true);
77  return ierr;
78 
79  }
80 
81 };
82 }
83 #endif
#define HELLO
int localOrder(const RCP< LocalOrderingSolution< lno_t > > &solution)
Ordering method.
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
map_t::global_ordinal_type gno_t
Definition: mapRemotes.cpp:27
Defines the OrderingSolution class.
Defines the IdentifierModel interface.
Algorithm defines the base class for all algorithms.
map_t::local_ordinal_type lno_t
Definition: mapRemotes.cpp:26
AlgNatural(const RCP< const typename Adapter::base_adapter_t > &adapter__, const RCP< Teuchos::ParameterList > &pl__, const RCP< const Teuchos::Comm< int > > &comm__, const RCP< const Environment > &env__)
IdentifierModel defines the interface for all identifier models.
int globalOrder(const RCP< GlobalOrderingSolution< gno_t > > &)
Ordering method.