Debian Codegraph @

packages/muelu/research/max/XpetraSplitting/Xpetra_RegionAMG_decl.hpp

raw
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 * Xpetra_RegionAMG_decl.hpp
12 *
13 * Created on: August 17, 2017
14 * Author: Massimiliano Lupo Pasini ([email protected])
15 */
16
17 #ifndef XPETRA_REGIONAMG_DECL_HPP
18 #define XPETRA_REGIONAMG_DECL_HPP
19
20 // Xpetra
21 #include <Xpetra_Operator.hpp>
22 #include "Xpetra_MatrixSplitting.hpp"
23 #include "Xpetra_Level_def.hpp"
24
25 // MueLu
26 #include <MueLu.hpp>
27 #include <MueLu_TpetraOperator.hpp>
28 #include <MueLu_CreateTpetraPreconditioner.hpp>
29 #include <MueLu_Utilities.hpp>
30
31 namespace Xpetra {
32
33 /*!
34 * class RegionAMG
35 *
36 * This class inherits from Xpetra::Operator because the goal is to allow its usage
37 * as a preconditioner for a Belos-type linear solver
38 *
39 * RegionAMG is a class used to split a composite stiffness matrix into region matrices.
40 * Each region matrix is associated with a geometric region of the discretized domain.
41 * Therefore, the splitting operates in a domain decomposition fashion.
42 * Since there are infinitely many ways to split a given composite matrix,
43 * we explains here below the rationale behind the approach adopted in this class.
44 * */
45
46 template <class Scalar = MultiVector<>::scalar_type,
47 class LocalOrdinal = typename MultiVector<Scalar>::local_ordinal_type,
48 class GlobalOrdinal = typename MultiVector<Scalar, LocalOrdinal>::global_ordinal_type,
49 class Node = typename MultiVector<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
50 class RegionAMG : Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
51 typedef Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
52 typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal> multivector_type;
53 typedef Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> matrix_type;
54 typedef MatrixSplitting<Scalar, LocalOrdinal, GlobalOrdinal, Node, Xpetra::UseTpetra, false> tpetra_splitting;
55 typedef MueLu::Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node> Hierarchy;
56 typedef MultiVectorFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node> mv_factory_type;
57 typedef Level<Scalar, LocalOrdinal, GlobalOrdinal, Node> level;
58
59 public:
60 //! Constructors
61 //@{
62
63 RegionAMG() {
64 std::cout << "This version of constructor is not implemented yet" << std::endl;
65 };
66
67 //! This is the actual constructor we are interested in calling
68 RegionAMG(Teuchos::RCP<tpetra_splitting> matrixSplitting,
69 Teuchos::RCP<Xpetra::RegionHandler<Scalar, LocalOrdinal, GlobalOrdinal, Node> > regionHandler,
70 RCP<const Teuchos::Comm<int> > comm, Teuchos::ParameterList muelu,
71 GlobalOrdinal num_levels, GlobalOrdinal coarsening_factor);
72
73 //@}
74
75 GlobalOrdinal GetNumLevels() { return num_levels_; }
76
77 //! Methods to extract Map information
78 //@{
79 //! For now, the domain Map coincides with the Domain Map of the composite matrix at the fine level
80 virtual RCP<const map_type> getDomainMap() const { return domainMap_; }
81
82 //! For now, the domain Map coincides with the Range Map of the composite matrix at the fine level
83 virtual RCP<const map_type> getRangeMap() const { return rangeMap_; }
84
85 //@}
86
87 //! Apply method
88 //@{
89 //! N.B.: The implementation still has to be finished
90 virtual void
91 apply(const multivector_type& X, multivector_type& Y,
92 Teuchos::ETransp mode = Teuchos::NO_TRANS,
93 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
94 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
95 //@}
96
97 //! hasTransposeApply should not be needed
98 virtual bool hasTransposeApply() const { return false; }
99
100 private:
101 //! Private variables
102 //@{
103
104 // Total number of levels in the hierarchy
105 GlobalOrdinal num_levels_ = -1;
106
107 // Total number of regions
108 GlobalOrdinal num_regions_ = -1;
109
110 // Coarsening factor to transfer quantities across levels
111 int coarsening_factor_ = -1;
112
113 RCP<const Teuchos::Comm<int> > comm_;
114
115 Teuchos::ParameterList muelu_;
116
117 RCP<const map_type> domainMap_;
118 RCP<const map_type> rangeMap_;
119
120 // matrixSplitting associated with the composite matrix at the fine level
121 RCP<tpetra_splitting> matrixSplitting_;
122
123 // Array of MueLu hierarchies (one for each region)
124 Array<RCP<Hierarchy> > regionHierarchies_;
125
126 // Array of levels in the new hierarchy (each levels contains quantities associaed with every region for that level)
127 Array<RCP<level> > levels_;
128
129 //@}
130
131 //@Private Methods
132 //
133 // This methods construct the Hierarchy using the quantities stored in the MueLu::Hierarchy objects
134 // There are as many MueLu::Hierarchy objects as the number of geometric regions partitioning the domain
135 void SetUpHierarchy();
136
137 // This method is called in SetUpHierarchy and it is in chanrge of extracting quantities from MueLu::Hierarchy objects
138 // and store them inside Xpetra::Level objects
139 void DefineLevels();
140
141 // Method to create region input multivectors from the composite input multivector
142 void computeRegionX(const multivector_type&, Array<RCP<multivector_type> >) const;
143
144 // Method to create composite output multivector from region output multivectors
145 void computeCompositeY(Array<RCP<const multivector_type> >, multivector_type&) const;
146
147 // This method detects entries in region output mutlivectors associated with mesh nodes that lie on interregion interfaces
148 // and it scales them. The scaling factor is equal to the number of regions that the given degrees of freedom are shared by
149 void rescaleInterfaceEntries(Array<RCP<multivector_type> >) const;
150
151 virtual void regionToAllCoarsen(const level&, level&);
152
153 //@}
154 };
155
156 } // namespace Xpetra
157
158 #endif