MueLu Version of the Day
Loading...
Searching...
No Matches
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>
22#include <Xpetra_VectorFactory_fwd.hpp>
23#include <Xpetra_CrsMatrixWrap_fwd.hpp>
24#include <Xpetra_Export_fwd.hpp>
25#include <Xpetra_ExportFactory_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
32namespace MueLu {
33
34// template struct for comparing pairs
35template <class Scalar = DefaultScalar, class LocalOrdinal = DefaultGlobalOrdinal>
36struct CompPairs {
37 CompPairs(const std::vector<Scalar>& v)
38 : vinternal_(v) {}
39 std::vector<Scalar> vinternal_;
41 // return vinternal_[a] < vinternal_[b];
42 return Teuchos::ScalarTraits<Scalar>::magnitude(vinternal_[a]) > Teuchos::ScalarTraits<Scalar>::magnitude(vinternal_[b]);
43 }
44};
45
46// template function for comparison
47template <class Scalar, class LocalOrdinal>
48CompPairs<Scalar, LocalOrdinal> CreateCmpPairs(const std::vector<Scalar>& v) {
50}
51
52// template function for sorting permutations
53template <class Scalar, class LocalOrdinal>
54void 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
71template <class Scalar = DefaultScalar,
74 class Node = DefaultNode>
76#undef MUELU_ALGEBRAICPERMUTATIONSTRATEGY_SHORT
78 public:
85
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_ */
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
void BuildPermutation(const Teuchos::RCP< Matrix > &A, const Teuchos::RCP< const Map > &permRowMap, Level &currentLevel, const FactoryBase *genFactory) const
build permutation operators
Base class for MueLu classes.
Base class for factories (e.g., R, P, and A_coarse).
Class that holds all level-specific information.
Namespace for MueLu classes and methods.
void sortingPermutation(const std::vector< Scalar > &values, std::vector< LocalOrdinal > &v)
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar
CompPairs< Scalar, LocalOrdinal > CreateCmpPairs(const std::vector< Scalar > &v)
CompPairs(const std::vector< Scalar > &v)
bool operator()(LocalOrdinal a, LocalOrdinal b)