|
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_SPARSECONTAINER_DECL_HPP 00031 #define IFPACK2_SPARSECONTAINER_DECL_HPP 00032 00033 #include "Ifpack2_Container.hpp" 00034 #include "Tpetra_MultiVector.hpp" 00035 #include "Tpetra_Map.hpp" 00036 #include "Tpetra_RowMatrix.hpp" 00037 #include "Tpetra_CrsMatrix.hpp" 00038 #include "Teuchos_ParameterList.hpp" 00039 #include "Teuchos_RefCountPtr.hpp" 00040 00041 00069 namespace Ifpack2 { 00070 00071 template<typename MatrixType, typename InverseType > 00072 class SparseContainer : public Container<MatrixType,InverseType> { 00073 00074 public: 00075 typedef typename MatrixType::scalar_type MatrixScalar; 00076 typedef typename MatrixType::local_ordinal_type MatrixLocalOrdinal; 00077 typedef typename MatrixType::global_ordinal_type MatrixGlobalOrdinal; 00078 typedef typename MatrixType::node_type MatrixNode; 00079 00080 typedef typename InverseType::scalar_type InverseScalar; 00081 typedef typename InverseType::local_ordinal_type InverseLocalOrdinal; 00082 typedef typename InverseType::global_ordinal_type InverseGlobalOrdinal; 00083 typedef typename InverseType::node_type InverseNode; 00084 00086 00087 SparseContainer(const size_t NumRows, const size_t NumVectors = 1); 00088 00090 virtual ~SparseContainer(); 00092 00094 00095 virtual size_t getNumRows() const; 00096 00097 // Returns the number of vectors in X/Y. 00098 // virtual size_t getNumVectors() const; 00099 00101 00110 virtual MatrixLocalOrdinal & ID(const size_t i); 00111 00113 virtual bool isInitialized() const; 00114 00116 virtual bool isComputed() const; 00117 00119 virtual void setParameters(const Teuchos::ParameterList& List); 00120 00122 00124 00131 virtual void initialize(); 00133 virtual void compute(const Teuchos::RCP<const Tpetra::RowMatrix<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode> >& Matrix); 00134 00136 00138 virtual void apply(const Tpetra::MultiVector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& X, 00139 Tpetra::MultiVector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& Y, 00140 Teuchos::ETransp mode=Teuchos::NO_TRANS, 00141 MatrixScalar alpha=Teuchos::ScalarTraits< MatrixScalar >::one(), 00142 MatrixScalar beta=Teuchos::ScalarTraits< MatrixScalar >::zero()); 00143 00145 00149 virtual void weightedApply(const Tpetra::MultiVector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& X, 00150 Tpetra::MultiVector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& Y, 00151 const Tpetra::Vector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& D, 00152 Teuchos::ETransp mode=Teuchos::NO_TRANS, 00153 MatrixScalar alpha=Teuchos::ScalarTraits< MatrixScalar >::one(), 00154 MatrixScalar beta=Teuchos::ScalarTraits< MatrixScalar >::zero()); 00155 00156 00158 00160 00161 virtual void destroy(); 00163 00165 virtual std::ostream& print(std::ostream& os) const; 00166 00168 00169 00171 virtual std::string description() const; 00172 00174 virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const; 00175 00177 00178 private: 00179 // private copy constructor 00180 SparseContainer(const SparseContainer<MatrixType,InverseType>& rhs); 00181 00183 virtual void setNumVectors(const size_t NumVectors); 00184 00186 virtual void extract(const Teuchos::RCP<const Tpetra::RowMatrix<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode> >& Matrix); 00187 00189 size_t NumRows_; 00191 size_t NumVectors_; 00193 Teuchos::RCP<Tpetra::Map<InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > Map_; 00195 Teuchos::RCP<Tpetra::CrsMatrix<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > Matrix_; 00197 mutable Teuchos::RCP<Tpetra::MultiVector<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > Y_; 00199 mutable Teuchos::RCP<Tpetra::MultiVector<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > X_; 00201 std::vector<MatrixLocalOrdinal> GID_; 00203 bool IsInitialized_; 00205 bool IsComputed_; 00207 Teuchos::RCP<Teuchos::Comm<int> > LocalComm_; 00209 Teuchos::RCP<InverseType> Inverse_; 00210 00211 Teuchos::ParameterList List_; 00212 00213 }; 00214 00215 }// namespace Ifpack2 00216 00217 00218 00219 #endif // IFPACK2_SPARSECONTAINER_HPP
1.7.6.1