Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_OverlapGraph.hpp
00001 /*@HEADER
00002 // ***********************************************************************
00003 // 
00004 //       Ifpack2: Tempated Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2009) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 //@HEADER
00028 */
00029 
00030 #ifndef IFPACK2_OVERLAPGRAPH_HPP
00031 #define IFPACK2_OVERLAPGRAPH_HPP
00032 
00033 #include "Ifpack2_ConfigDefs.hpp"
00034 #include "Tpetra_CrsGraph.hpp"
00035 #include "Tpetra_Import.hpp"
00036 #include "Teuchos_RCP.hpp"
00037 #include "Ifpack2_CreateOverlapGraph.hpp"
00038 
00039 namespace Teuchos {
00040   class ParameterList;
00041 }
00042 
00043 namespace Ifpack2 {
00044 
00046 
00047 template<class LocalOrdinal, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
00048 class OverlapGraph : public Teuchos::Describable {
00049 
00050  public:
00052 
00053 
00057   OverlapGraph(const Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> >& UserMatrixGraph_in, int OverlapLevel_in);
00058 
00060 
00065 //  Ifpack2_OverlapGraph(const Teuchos::RCP<const Tpetra_RowMatrix>& UserMatrix_in, int OverlapLevel_in);
00066   
00068   OverlapGraph(const OverlapGraph<LocalOrdinal,GlobalOrdinal,Node> & Source);
00069 
00071   virtual ~OverlapGraph() {};
00073 
00075     
00077   /* This method is only available if the configure argument
00078      '--enable-ifpack-teuchos' was used.
00079      This method recognizes the name: level_overlap, which is case insensitive.
00080      The ParameterEntry must have type int.
00081   */
00082   int SetParameters(const Teuchos::ParameterList& parameterlist,
00083                     bool cerr_warning_if_unused=false);
00084 
00086   const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> & getOverlapGraph() const {return(*OverlapGraph_);}
00087     
00089   const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> & getOverlapRowMap() const {return(*OverlapRowMap_);}
00090     
00092   const Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> & getOverlapImporter() const {return(*OverlapImporter_);}
00093     
00095 
00100   int OverlapLevel() const {return(OverlapLevel_);}
00102 
00104 
00105 //  void Print(ostream& os) const {
00106 //    os << endl;
00107 //    if (UserMatrix_!=Teuchos::null) 
00108 //      os << "Overlap Graph created using the user's Tpetra_RowMatrix object" << endl;
00109 //    else
00110 //      os << "Overlap Graph created using the user's Tpetra_CrsGraph object" << endl;
00111 //    
00112 //    os << " Level of Overlap = " << OverlapLevel_ << endl;
00113 //    OverlapGraph_->Print(os);
00114 //    return;
00115 //  }
00117 
00118  protected:
00119 
00120   int ConstructOverlapGraph(const Teuchos::RCP<Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> >& UserMatrixGraph);
00121   Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> > OverlapGraph_;
00122   Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> > UserMatrixGraph_;
00123 //  Teuchos::RCP<const Tpetra_RowMatrix> UserMatrix_;
00124   Teuchos::RCP<Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > OverlapRowMap_;
00125   Teuchos::RCP<Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> > OverlapImporter_;
00126   int OverlapLevel_;
00127   bool IsOverlapped_;
00128 };
00129 
00130 template<class LocalOrdinal, class GlobalOrdinal, class Node>
00131 OverlapGraph<LocalOrdinal,GlobalOrdinal,Node>::OverlapGraph(const Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> >& UserMatrixGraph_in, int OverlapLevel_in)
00132  : UserMatrixGraph_(UserMatrixGraph_in),
00133    OverlapLevel_(OverlapLevel_in),
00134    IsOverlapped_(OverlapLevel_in>0 && UserMatrixGraph_in->getDomainMap()->isDistributed())
00135 {
00136   OverlapGraph_ = CreateOverlapGraph(UserMatrixGraph_, OverlapLevel_);
00137 }
00138 
00139 template<class LocalOrdinal, class GlobalOrdinal, class Node>
00140 OverlapGraph<LocalOrdinal,GlobalOrdinal,Node>::OverlapGraph(const OverlapGraph<LocalOrdinal,GlobalOrdinal,Node>& Source)
00141  : UserMatrixGraph_(Source.UserMatrixGraph_),
00142    OverlapRowMap_(Source.OverlapRowMap_),
00143    OverlapLevel_(Source.OverlapLevel_),
00144    IsOverlapped_(Source.IsOverlapped_)
00145 {
00146   if (IsOverlapped_) {
00147     if (OverlapGraph_!=Teuchos::null) OverlapGraph_ = Teuchos::rcp(new Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node>(*OverlapGraph_));
00148     if (OverlapRowMap_!=Teuchos::null) OverlapRowMap_ = Teuchos::rcp(new Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node>(*OverlapRowMap_));
00149   }
00150 }
00151 
00152 }//namespace Ifpack2
00153 
00154 #endif // IFPACK2_OVERLAPGRAPH_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends