| 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_Level_decl.hpp |
| 12 |
* |
| 13 |
* Created on: August 17, 2017 |
| 14 |
* Author: Massimiliano Lupo Pasini ([email protected]) |
| 15 |
*/ |
| 16 |
#ifndef XPETRA_LEVEL_DECL_HPP |
| 17 |
#define XPETRA_LEVEL_DECL_HPP |
| 18 |
|
| 19 |
namespace Xpetra { |
| 20 |
|
| 21 |
template <class Scalar = MultiVector<>::scalar_type, |
| 22 |
class LocalOrdinal = typename MultiVector<Scalar>::local_ordinal_type, |
| 23 |
class GlobalOrdinal = typename MultiVector<Scalar, LocalOrdinal>::global_ordinal_type, |
| 24 |
class Node = typename MultiVector<Scalar, LocalOrdinal, GlobalOrdinal>::node_type> |
| 25 |
class Level { |
| 26 |
typedef Map<LocalOrdinal, GlobalOrdinal, Node> map_type; |
| 27 |
typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal> vector_type; |
| 28 |
typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal> multivector_type; |
| 29 |
typedef Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> matrix_type; |
| 30 |
|
| 31 |
public: |
| 32 |
//! Constructors/destructors |
| 33 |
//@{ |
| 34 |
// Constructor |
| 35 |
Level(int, int); |
| 36 |
|
| 37 |
// Default destructor |
| 38 |
virtual ~Level(){}; |
| 39 |
|
| 40 |
//@} |
| 41 |
|
| 42 |
//! Public methods |
| 43 |
//@{ |
| 44 |
virtual void |
| 45 |
apply(const multivector_type& X, multivector_type& Y, |
| 46 |
Teuchos::ETransp mode = Teuchos::NO_TRANS, |
| 47 |
Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(), |
| 48 |
Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const {}; |
| 49 |
|
| 50 |
virtual bool hasTransposeApply() const { return false; } |
| 51 |
|
| 52 |
//! Get methods |
| 53 |
//@{ |
| 54 |
|
| 55 |
//! Extract the number of regions instantiated in the level |
| 56 |
int GetNumRegions() const; |
| 57 |
|
| 58 |
GlobalOrdinal GetNumRegionNodes(GlobalOrdinal region_idx) const { return regionA_[region_idx]->getCrsGraph()->getGlobalNumRows(); }; |
| 59 |
|
| 60 |
RCP<matrix_type> GetRegionMatrix(GlobalOrdinal region_idx) const { return regionA_[region_idx]; }; |
| 61 |
|
| 62 |
//! Extract regionToAll from the level |
| 63 |
Array<Array<std::tuple<GlobalOrdinal, GlobalOrdinal> > > GetRegionToAll() const; |
| 64 |
|
| 65 |
// Extract the level ID |
| 66 |
GlobalOrdinal GetLevelID() const { return levelID_; } |
| 67 |
|
| 68 |
//! Take a region index and returns the composite index for a given mesh node |
| 69 |
GlobalOrdinal GetCompositeIndex(int, GlobalOrdinal) const; |
| 70 |
|
| 71 |
//@} |
| 72 |
|
| 73 |
//@} |
| 74 |
|
| 75 |
//! Set up methods |
| 76 |
//@{ |
| 77 |
//! Set the region galerkin operators |
| 78 |
void SetA(Array<RCP<matrix_type> >&); |
| 79 |
|
| 80 |
//! Set the region prolongators |
| 81 |
void SetP(Array<RCP<matrix_type> >&); |
| 82 |
|
| 83 |
//! Set the region restrioctions |
| 84 |
void SetR(Array<RCP<matrix_type> >&); |
| 85 |
|
| 86 |
//! Set the region smoothers |
| 87 |
void SetSmoother(Array<RCP<multivector_type> >&); |
| 88 |
|
| 89 |
//! Set the regionToAll structure for the current level by using information coming from the finer level |
| 90 |
void SetRegionToAll(Array<Array<std::tuple<GlobalOrdinal, GlobalOrdinal> > >); |
| 91 |
|
| 92 |
//@} |
| 93 |
|
| 94 |
//! Check method |
| 95 |
//@{ |
| 96 |
//! Control that algebraic quantities have matching dimensions |
| 97 |
void checkConsistency() const; |
| 98 |
//@} |
| 99 |
|
| 100 |
//! Constrcution of region smoothers |
| 101 |
//@{ |
| 102 |
void ComputeRegionJacobi(); |
| 103 |
//@} |
| 104 |
|
| 105 |
private: |
| 106 |
//! Private variables |
| 107 |
//@{ |
| 108 |
GlobalOrdinal levelID_ = -1; |
| 109 |
GlobalOrdinal num_regions_ = -1; |
| 110 |
|
| 111 |
//! Region operators |
| 112 |
Array<RCP<matrix_type> > regionA_; |
| 113 |
|
| 114 |
//! Region grid transfers |
| 115 |
Array<RCP<matrix_type> > regionP_; |
| 116 |
Array<RCP<matrix_type> > regionR_; |
| 117 |
|
| 118 |
//! Smoother |
| 119 |
Array<RCP<vector_type> > regionSmoother_; |
| 120 |
|
| 121 |
//! Auxiliary quantities to handle regions at each coarsening level |
| 122 |
Array<Array<std::tuple<GlobalOrdinal, GlobalOrdinal> > > level_regionToAll_; |
| 123 |
|
| 124 |
//@} |
| 125 |
}; |
| 126 |
|
| 127 |
} // namespace Xpetra |
| 128 |
|
| 129 |
#endif |