Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
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
19namespace Teuchos {
20class ParameterList;
21}
22
23namespace Ifpack2 {
24
38
39template <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>
42class OverlapGraph : public Teuchos::Describable {
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:
85 Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > OverlapGraph_;
86 Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > UserMatrixGraph_;
87 Teuchos::RCP<Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > OverlapRowMap_;
88 Teuchos::RCP<Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > OverlapImporter_;
89 int OverlapLevel_;
90 bool IsOverlapped_;
91};
92
93template <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 OverlapGraph_ = createOverlapGraph(UserMatrixGraph_, OverlapLevel_);
101}
102
103template <class LocalOrdinal, class GlobalOrdinal, class Node>
106 : UserMatrixGraph_(Source.UserMatrixGraph_)
107 , OverlapRowMap_(Source.OverlapRowMap_)
108 , OverlapLevel_(Source.OverlapLevel_)
109 , IsOverlapped_(Source.IsOverlapped_) {
110 using Teuchos::rcp;
111 typedef Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
112
113 if (IsOverlapped_) {
114 if (!OverlapGraph_.is_null()) {
115 OverlapGraph_ = rcp(new graph_type(*OverlapGraph_));
116 }
117 if (!OverlapRowMap_.is_null()) {
118 OverlapRowMap_ = rcp(new map_type(*OverlapRowMap_));
119 }
120 }
121}
122
123} // namespace Ifpack2
124
125#endif // IFPACK2_OVERLAPGRAPH_HPP
Construct an overlapped graph from a given nonoverlapping graph.
Definition Ifpack2_OverlapGraph.hpp:42
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
const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > & getOverlapImporter() const
Return the Import object.
Definition Ifpack2_OverlapGraph.hpp:72
const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > & getOverlapRowMap() const
Return the overlap graph's row Map.
Definition Ifpack2_OverlapGraph.hpp:68
int OverlapLevel() const
Return the level of overlap used to create this graph.
Definition Ifpack2_OverlapGraph.hpp:81
virtual ~OverlapGraph()
Destructor (virtual for memory safety of derived classes).
Definition Ifpack2_OverlapGraph.hpp:60
const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > & getOverlapGraph() const
Return the overlap graph.
Definition Ifpack2_OverlapGraph.hpp:64
Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > graph_type
The Tpetra::CrsGraph specialization that this class uses.
Definition Ifpack2_OverlapGraph.hpp:45
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40
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:39