|
Ifpack2 Templated Preconditioning Package
Version 1.0
|
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_CREATEOVERLAPGRAPH_HPP 00031 #define IFPACK2_CREATEOVERLAPGRAPH_HPP 00032 00033 #include "Ifpack2_ConfigDefs.hpp" 00034 #include "Tpetra_CrsGraph.hpp" 00035 #include "Tpetra_Import.hpp" 00036 #include "Teuchos_RefCountPtr.hpp" 00037 00038 00039 namespace Ifpack2 { 00040 00042 00045 template<class LocalOrdinal, class GlobalOrdinal, class Node> 00046 Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> > CreateOverlapGraph(const Teuchos::RCP<const Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> >& input_graph, int OverlapLevel) 00047 { 00048 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> GraphType; 00049 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> MapType; 00050 typedef Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> ImportType; 00051 00052 TEUCHOS_TEST_FOR_EXCEPTION(OverlapLevel < 0, std::runtime_error, "Ifpack2::CreateOverlapGraph: OverlapLevel must be >= 0."); 00053 00054 Teuchos::RCP<GraphType> OverlapGraph; 00055 00056 const int numProcs = input_graph->getMap()->getComm()->getSize(); 00057 if (OverlapLevel == 0 || numProcs < 2) return input_graph; 00058 00059 Teuchos::RCP<const MapType> OverlapRowMap = input_graph->getRowMap(); 00060 00061 Teuchos::RCP<const GraphType> OldGraph; 00062 Teuchos::RCP<const MapType> OldRowMap; 00063 const Teuchos::RCP<const MapType> DomainMap = input_graph->getDomainMap(); 00064 const Teuchos::RCP<const MapType> RangeMap = input_graph->getRangeMap(); 00065 00066 for (int level=1; level <= OverlapLevel; level++) { 00067 OldGraph = OverlapGraph; 00068 OldRowMap = OverlapRowMap; 00069 00070 Teuchos::RCP<const ImportType> OverlapImporter = OldGraph->getImporter(); 00071 OverlapRowMap = OverlapImporter->getTargetMap(); 00072 if (level<OverlapLevel) { 00073 OverlapGraph = Teuchos::rcp( new GraphType(OverlapRowMap, 0) ); 00074 } 00075 else { 00076 // On last iteration, we want to filter out all columns except those that 00077 // correspond to rows in the graph. This assures that our matrix is square 00078 OverlapGraph = Teuchos::rcp( new GraphType(OverlapRowMap, OverlapRowMap, 0) ); 00079 } 00080 00081 OverlapGraph->doImport(*input_graph, *OverlapImporter, Tpetra::INSERT); 00082 OverlapGraph->fillComplete(DomainMap, RangeMap); 00083 } 00084 00085 return OverlapGraph; 00086 } 00087 00088 }//namespace Ifpack2 00089 00090 #endif // IFPACK2_CREATEOVERLAPGRAPH_HPP
1.7.6.1