MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_AlgebraicPermutationStrategy_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 /*
11  * MueLu_AlgebraicPermutationStrategy_decl.hpp
12  *
13  * Created on: Feb 20, 2013
14  * Author: tobias
15  */
16 
17 #ifndef MUELU_ALGEBRAICPERMUTATIONSTRATEGY_DECL_HPP_
18 #define MUELU_ALGEBRAICPERMUTATIONSTRATEGY_DECL_HPP_
19 
20 #include <Xpetra_Matrix_fwd.hpp>
21 #include <Xpetra_Vector_fwd.hpp>
24 #include <Xpetra_Export_fwd.hpp>
26 #include <Xpetra_Import_fwd.hpp>
27 
28 #include "MueLu_ConfigDefs.hpp"
29 #include "MueLu_Level.hpp"
30 #include "MueLu_BaseClass.hpp"
31 
32 namespace MueLu {
33 
34 // template struct for comparing pairs
35 template <class Scalar = DefaultScalar, class LocalOrdinal = DefaultGlobalOrdinal>
36 struct CompPairs {
37  CompPairs(const std::vector<Scalar>& v)
38  : vinternal_(v) {}
39  std::vector<Scalar> vinternal_;
41  // return vinternal_[a] < vinternal_[b];
43  }
44 };
45 
46 // template function for comparison
47 template <class Scalar, class LocalOrdinal>
48 CompPairs<Scalar, LocalOrdinal> CreateCmpPairs(const std::vector<Scalar>& v) {
50 }
51 
52 // template function for sorting permutations
53 template <class Scalar, class LocalOrdinal>
54 void sortingPermutation(const std::vector<Scalar>& values, std::vector<LocalOrdinal>& v) {
55  size_t size = values.size();
56  v.clear();
57  v.reserve(size);
58  for (size_t i = 0; i < size; ++i)
59  v.push_back(i);
60 
61  std::sort(v.begin(), v.end(), MueLu::CreateCmpPairs<Scalar, LocalOrdinal>(values));
62 }
63 
65 
71 template <class Scalar = DefaultScalar,
74  class Node = DefaultNode>
75 class AlgebraicPermutationStrategy : public BaseClass {
76 #undef MUELU_ALGEBRAICPERMUTATIONSTRATEGY_SHORT
77 #include "MueLu_UseShortNames.hpp"
78  public:
84 
86 
88 
103  void BuildPermutation(const Teuchos::RCP<Matrix>& A, const Teuchos::RCP<const Map>& permRowMap,
104  Level& currentLevel, const FactoryBase* genFactory) const;
105 
107 
108  private:
109 };
110 
111 } // namespace MueLu
112 
113 #define MUELU_ALGEBRAICPERMUTATIONSTRATEGY_SHORT
114 
115 #endif /* MUELU_ALGEBRAICPERMUTATIONSTRATEGY_DECL_HPP_ */
void BuildPermutation(const Teuchos::RCP< Matrix > &A, const Teuchos::RCP< const Map > &permRowMap, Level &currentLevel, const FactoryBase *genFactory) const
build permutation operators
MueLu::DefaultLocalOrdinal LocalOrdinal
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
void sortingPermutation(const std::vector< Scalar > &values, std::vector< LocalOrdinal > &v)
MueLu::DefaultNode Node
bool operator()(LocalOrdinal a, LocalOrdinal b)
MueLu::DefaultScalar Scalar
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
CompPairs(const std::vector< Scalar > &v)
Class which defines local permutations of matrix columns.
static magnitudeType magnitude(T a)
CompPairs< Scalar, LocalOrdinal > CreateCmpPairs(const std::vector< Scalar > &v)