Ifpack2 Templated Preconditioning Package  Version 1.0
Ifpack2_OverlapGraph.hpp
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Tempated 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 
59 
60 template<class LocalOrdinal, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
61 class OverlapGraph : public Teuchos::Describable {
62 
63  public:
65 
70  OverlapGraph(const Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> >& UserMatrixGraph_in, int OverlapLevel_in);
71 
73 
78 // Ifpack2_OverlapGraph(const Teuchos::RCP<const Tpetra_RowMatrix>& UserMatrix_in, int OverlapLevel_in);
79 
82 
84  virtual ~OverlapGraph() {};
86 
88 
90  /* This method is only available if the configure argument
91  '--enable-ifpack-teuchos' was used.
92  This method recognizes the name: level_overlap, which is case insensitive.
93  The ParameterEntry must have type int.
94  */
95  int SetParameters(const Teuchos::ParameterList& parameterlist,
96  bool cerr_warning_if_unused=false);
97 
99  const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> & getOverlapGraph() const {return(*OverlapGraph_);}
100 
102  const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> & getOverlapRowMap() const {return(*OverlapRowMap_);}
103 
105  const Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> & getOverlapImporter() const {return(*OverlapImporter_);}
106 
108 
113  int OverlapLevel() const {return(OverlapLevel_);}
115 
117 
118 // void Print(ostream& os) const {
119 // os << endl;
120 // if (UserMatrix_!=Teuchos::null)
121 // os << "Overlap Graph created using the user's Tpetra_RowMatrix object" << endl;
122 // else
123 // os << "Overlap Graph created using the user's Tpetra_CrsGraph object" << endl;
124 //
125 // os << " Level of Overlap = " << OverlapLevel_ << endl;
126 // OverlapGraph_->Print(os);
127 // return;
128 // }
130 
131  protected:
132 
133  int ConstructOverlapGraph(const Teuchos::RCP<Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> >& UserMatrixGraph);
134  Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> > OverlapGraph_;
135  Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> > UserMatrixGraph_;
136 // Teuchos::RCP<const Tpetra_RowMatrix> UserMatrix_;
137  Teuchos::RCP<Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > OverlapRowMap_;
138  Teuchos::RCP<Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> > OverlapImporter_;
139  int OverlapLevel_;
140  bool IsOverlapped_;
141 };
142 
143 template<class LocalOrdinal, class GlobalOrdinal, class Node>
144 OverlapGraph<LocalOrdinal,GlobalOrdinal,Node>::OverlapGraph(const Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> >& UserMatrixGraph_in, int OverlapLevel_in)
145  : UserMatrixGraph_(UserMatrixGraph_in),
146  OverlapLevel_(OverlapLevel_in),
147  IsOverlapped_(OverlapLevel_in>0 && UserMatrixGraph_in->getDomainMap()->isDistributed())
148 {
149  OverlapGraph_ = CreateOverlapGraph(UserMatrixGraph_, OverlapLevel_);
150 }
151 
152 template<class LocalOrdinal, class GlobalOrdinal, class Node>
154  : UserMatrixGraph_(Source.UserMatrixGraph_),
155  OverlapRowMap_(Source.OverlapRowMap_),
156  OverlapLevel_(Source.OverlapLevel_),
157  IsOverlapped_(Source.IsOverlapped_)
158 {
159  if (IsOverlapped_) {
160  if (OverlapGraph_!=Teuchos::null) OverlapGraph_ = Teuchos::rcp(new Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node>(*OverlapGraph_));
161  if (OverlapRowMap_!=Teuchos::null) OverlapRowMap_ = Teuchos::rcp(new Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node>(*OverlapRowMap_));
162  }
163 }
164 
165 }//namespace Ifpack2
166 
167 #endif // IFPACK2_OVERLAPGRAPH_HPP
const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > & getOverlapImporter() const
Returns the overlap graph object.
Definition: Ifpack2_OverlapGraph.hpp:105
Ifpack2::OverlapGraph constructs an overlapped graph.
Definition: Ifpack2_OverlapGraph.hpp:61
Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > CreateOverlapGraph(const Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &input_graph, int OverlapLevel)
Constructs an overlapped graph for use with Ifpack2 preconditioners.
Definition: Ifpack2_CreateOverlapGraph.hpp:60
const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > & getOverlapRowMap() const
Returns the RowMap associated with the overlap graph.
Definition: Ifpack2_OverlapGraph.hpp:102
Definition: Ifpack2_BlockRelaxation_decl.hpp:64
const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > & getOverlapGraph() const
Returns the overlap graph object.
Definition: Ifpack2_OverlapGraph.hpp:99
int OverlapLevel() const
Returns the level of overlap used to create this graph.
Definition: Ifpack2_OverlapGraph.hpp:113
Ifpack2::Container: a pure virtual class for creating and solving local linear problems.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:67
OverlapGraph(const Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &UserMatrixGraph_in, int OverlapLevel_in)
Constructor using Tpetra::CrsGraph.
Definition: Ifpack2_OverlapGraph.hpp:144
virtual ~OverlapGraph()
Destructor.
Definition: Ifpack2_OverlapGraph.hpp:84