Zoltan2
Loading...
Searching...
No Matches
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
18namespace Zoltan2{
19
24
25template <typename Adapter>
26class 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
Defines the IdentifierModel interface.
Defines the OrderingSolution class.
#define HELLO
int localOrder(const RCP< LocalOrderingSolution< lno_t > > &solution)
Ordering method.
int globalOrder(const RCP< GlobalOrderingSolution< gno_t > > &)
Ordering method.
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__)
Algorithm defines the base class for all algorithms.
IdentifierModel defines the interface for all identifier models.
Created by mbenlioglu on Aug 31, 2020.
std::bitset< NUM_MODEL_FLAGS > modelFlag_t