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 //
4 // Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
43 #ifndef IFPACK2_OVERLAPGRAPH_HPP
44 #define IFPACK2_OVERLAPGRAPH_HPP
45 
46 #include "Ifpack2_ConfigDefs.hpp"
47 #include "Tpetra_CrsGraph.hpp"
48 #include "Tpetra_Import.hpp"
49 #include "Teuchos_RCP.hpp"
50 #include "Ifpack2_CreateOverlapGraph.hpp"
51 
52 namespace Teuchos {
53  class ParameterList;
54 }
55 
56 namespace Ifpack2 {
57 
71 
72 template<class LocalOrdinal = typename Tpetra::CrsGraph<>::local_ordinal_type,
73  class GlobalOrdinal = typename Tpetra::CrsGraph<LocalOrdinal>::global_ordinal_type,
74  class Node = typename Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal>::node_type>
76 public:
78  typedef Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> graph_type;
79 
86  OverlapGraph (const Teuchos::RCP<const graph_type>& UserMatrixGraph_in,
87  int OverlapLevel_in);
88 
91 
93  virtual ~OverlapGraph () {}
94 
96  const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node>&
97  getOverlapGraph () const { return *OverlapGraph_; }
98 
100  const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node>&
101  getOverlapRowMap () const {return *OverlapRowMap_; }
102 
104  const Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node>&
105  getOverlapImporter () const { return *OverlapImporter_; }
106 
114  int OverlapLevel () const { return OverlapLevel_; }
116 
117 protected:
122  int OverlapLevel_;
123  bool IsOverlapped_;
124 };
125 
126 template<class LocalOrdinal, class GlobalOrdinal, class Node>
128 OverlapGraph (const Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> >& UserMatrixGraph_in,
129  int OverlapLevel_in)
130  : UserMatrixGraph_ (UserMatrixGraph_in),
131  OverlapLevel_ (OverlapLevel_in),
132  IsOverlapped_ (OverlapLevel_in > 0 && UserMatrixGraph_in->getDomainMap ()->isDistributed ())
133 {
134  OverlapGraph_ = createOverlapGraph (UserMatrixGraph_, OverlapLevel_);
135 }
136 
137 template<class LocalOrdinal, class GlobalOrdinal, class Node>
140  : UserMatrixGraph_ (Source.UserMatrixGraph_),
141  OverlapRowMap_ (Source.OverlapRowMap_),
142  OverlapLevel_ (Source.OverlapLevel_),
143  IsOverlapped_ (Source.IsOverlapped_)
144 {
145  using Teuchos::rcp;
146  typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> map_type;
147 
148  if (IsOverlapped_) {
149  if (! OverlapGraph_.is_null ()) {
150  OverlapGraph_ = rcp (new graph_type (*OverlapGraph_));
151  }
152  if (! OverlapRowMap_.is_null ()) {
153  OverlapRowMap_ = rcp (new map_type (*OverlapRowMap_));
154  }
155  }
156 }
157 
158 }//namespace Ifpack2
159 
160 #endif // IFPACK2_OVERLAPGRAPH_HPP
const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > & getOverlapImporter() const
Return the Import object.
Definition: Ifpack2_OverlapGraph.hpp:105
Construct an overlapped graph from a given nonoverlapping graph.
Definition: Ifpack2_OverlapGraph.hpp:75
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:73
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:101
const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > & getOverlapGraph() const
Return the overlap graph.
Definition: Ifpack2_OverlapGraph.hpp:97
int OverlapLevel() const
Return the level of overlap used to create this graph.
Definition: Ifpack2_OverlapGraph.hpp:114
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:128
Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > graph_type
The Tpetra::CrsGraph specialization that this class uses.
Definition: Ifpack2_OverlapGraph.hpp:78
virtual ~OverlapGraph()
Destructor (virtual for memory safety of derived classes).
Definition: Ifpack2_OverlapGraph.hpp:93
bool is_null() const