Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_OverlapGraph.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
4 //
5 // Copyright 2009 NTESS and the Ifpack2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef IFPACK2_OVERLAPGRAPH_HPP
11 #define IFPACK2_OVERLAPGRAPH_HPP
12 
13 #include "Ifpack2_ConfigDefs.hpp"
14 #include "Tpetra_CrsGraph.hpp"
15 #include "Tpetra_Import.hpp"
16 #include "Teuchos_RCP.hpp"
17 #include "Ifpack2_CreateOverlapGraph.hpp"
18 
19 namespace Teuchos {
20  class ParameterList;
21 }
22 
23 namespace Ifpack2 {
24 
38 
39 template<class LocalOrdinal = typename Tpetra::CrsGraph<>::local_ordinal_type,
40  class GlobalOrdinal = typename Tpetra::CrsGraph<LocalOrdinal>::global_ordinal_type,
41  class Node = typename Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal>::node_type>
43 public:
45  typedef Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> graph_type;
46 
53  OverlapGraph (const Teuchos::RCP<const graph_type>& UserMatrixGraph_in,
54  int OverlapLevel_in);
55 
58 
60  virtual ~OverlapGraph () {}
61 
63  const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node>&
64  getOverlapGraph () const { return *OverlapGraph_; }
65 
67  const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node>&
68  getOverlapRowMap () const {return *OverlapRowMap_; }
69 
71  const Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node>&
72  getOverlapImporter () const { return *OverlapImporter_; }
73 
81  int OverlapLevel () const { return OverlapLevel_; }
83 
84 protected:
89  int OverlapLevel_;
90  bool IsOverlapped_;
91 };
92 
93 template<class LocalOrdinal, class GlobalOrdinal, class Node>
95 OverlapGraph (const Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> >& UserMatrixGraph_in,
96  int OverlapLevel_in)
97  : UserMatrixGraph_ (UserMatrixGraph_in),
98  OverlapLevel_ (OverlapLevel_in),
99  IsOverlapped_ (OverlapLevel_in > 0 && UserMatrixGraph_in->getDomainMap ()->isDistributed ())
100 {
101  OverlapGraph_ = createOverlapGraph (UserMatrixGraph_, OverlapLevel_);
102 }
103 
104 template<class LocalOrdinal, class GlobalOrdinal, class Node>
107  : UserMatrixGraph_ (Source.UserMatrixGraph_),
108  OverlapRowMap_ (Source.OverlapRowMap_),
109  OverlapLevel_ (Source.OverlapLevel_),
110  IsOverlapped_ (Source.IsOverlapped_)
111 {
112  using Teuchos::rcp;
113  typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> map_type;
114 
115  if (IsOverlapped_) {
116  if (! OverlapGraph_.is_null ()) {
117  OverlapGraph_ = rcp (new graph_type (*OverlapGraph_));
118  }
119  if (! OverlapRowMap_.is_null ()) {
120  OverlapRowMap_ = rcp (new map_type (*OverlapRowMap_));
121  }
122  }
123 }
124 
125 }//namespace Ifpack2
126 
127 #endif // IFPACK2_OVERLAPGRAPH_HPP
const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > & getOverlapImporter() const
Return the Import object.
Definition: Ifpack2_OverlapGraph.hpp:72
Construct an overlapped graph from a given nonoverlapping graph.
Definition: Ifpack2_OverlapGraph.hpp:42
Teuchos::RCP< const GraphType > createOverlapGraph(const Teuchos::RCP< const GraphType > &inputGraph, const int overlapLevel)
Construct an overlapped graph for use with Ifpack2 preconditioners.
Definition: Ifpack2_CreateOverlapGraph.hpp:40
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > & getOverlapRowMap() const
Return the overlap graph&#39;s row Map.
Definition: Ifpack2_OverlapGraph.hpp:68
const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > & getOverlapGraph() const
Return the overlap graph.
Definition: Ifpack2_OverlapGraph.hpp:64
int OverlapLevel() const
Return the level of overlap used to create this graph.
Definition: Ifpack2_OverlapGraph.hpp:81
OverlapGraph(const Teuchos::RCP< const graph_type > &UserMatrixGraph_in, int OverlapLevel_in)
Constructor that takes a graph and the level of overlap.
Definition: Ifpack2_OverlapGraph.hpp:95
Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > graph_type
The Tpetra::CrsGraph specialization that this class uses.
Definition: Ifpack2_OverlapGraph.hpp:45
virtual ~OverlapGraph()
Destructor (virtual for memory safety of derived classes).
Definition: Ifpack2_OverlapGraph.hpp:60
bool is_null() const