Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_SparseContainer_decl.hpp
Go to the documentation of this file.
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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 //@HEADER
00041 */
00042 
00043 #ifndef IFPACK2_SPARSECONTAINER_DECL_HPP
00044 #define IFPACK2_SPARSECONTAINER_DECL_HPP
00045 
00048 
00049 #include "Ifpack2_Container.hpp"
00050 #include "Ifpack2_Details_MultiVectorLocalGatherScatter.hpp"
00051 #include "Tpetra_MultiVector.hpp"
00052 #include "Tpetra_Map.hpp"
00053 #include "Tpetra_RowMatrix.hpp"
00054 #include "Tpetra_CrsMatrix.hpp"
00055 #include "Teuchos_ParameterList.hpp"
00056 
00057 
00058 namespace Ifpack2 {
00059 
00128 template<typename MatrixType, typename InverseType>
00129 class SparseContainer : public Container<MatrixType> {
00130 public:
00132 
00133 
00140   typedef MatrixType matrix_type;
00146   typedef InverseType inverse_type;
00147 
00149   typedef typename MatrixType::scalar_type scalar_type;
00151   typedef typename MatrixType::local_ordinal_type local_ordinal_type;
00153   typedef typename MatrixType::global_ordinal_type global_ordinal_type;
00155   typedef typename MatrixType::node_type node_type;
00156 
00165   typedef typename Container<MatrixType>::row_matrix_type row_matrix_type;
00166 
00168 
00169 
00170 
00184   SparseContainer (const Teuchos::RCP<const row_matrix_type>& matrix,
00185                    const Teuchos::ArrayView<const local_ordinal_type>& localRows);
00186 
00188   virtual ~SparseContainer();
00189 
00191 
00192 
00193 
00198   virtual size_t getNumRows() const;
00199 
00201   virtual bool isInitialized() const;
00202 
00204   virtual bool isComputed() const;
00205 
00207   virtual void setParameters(const Teuchos::ParameterList& List);
00208 
00210 
00211 
00212 
00214   virtual void initialize();
00215 
00217   virtual void compute ();
00218 
00220   virtual void
00221   apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
00222          Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
00223          Teuchos::ETransp mode=Teuchos::NO_TRANS,
00224          scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(),
00225          scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const;
00226 
00228   virtual void
00229   weightedApply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
00230                  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
00231                  const Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& D,
00232                  Teuchos::ETransp mode=Teuchos::NO_TRANS,
00233                  scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(),
00234                  scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const;
00235 
00237 
00238 
00239 
00243   virtual std::ostream& print(std::ostream& os) const;
00244 
00246 
00247 
00248 
00250   virtual std::string description () const;
00251 
00253   virtual void
00254   describe (Teuchos::FancyOStream &out,
00255             const Teuchos::EVerbosityLevel verbLevel =
00256             Teuchos::Describable::verbLevel_default) const;
00257 
00259 private:
00260   typedef typename InverseType::scalar_type         InverseScalar;
00261   typedef typename InverseType::local_ordinal_type  InverseLocalOrdinal;
00262   typedef typename InverseType::global_ordinal_type InverseGlobalOrdinal;
00263   typedef typename InverseType::node_type           InverseNode;
00264 
00266   SparseContainer (const SparseContainer<MatrixType,InverseType>& rhs);
00267 
00269   void extract (const Teuchos::RCP<const row_matrix_type>& globalMatrix);
00270 
00282   void
00283   applyImpl (const Tpetra::MultiVector<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode>& X,
00284              Tpetra::MultiVector<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode>& Y,
00285              Teuchos::ETransp mode,
00286              InverseScalar alpha,
00287              InverseScalar beta) const;
00288 
00290   size_t numRows_;
00292   Teuchos::RCP<Tpetra::Map<InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > localMap_;
00294   Teuchos::RCP<Tpetra::CrsMatrix<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > diagBlock_;
00296   mutable Teuchos::RCP<Tpetra::MultiVector<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > Y_;
00298   mutable Teuchos::RCP<Tpetra::MultiVector<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > X_;
00300   bool IsInitialized_;
00302   bool IsComputed_;
00304   Teuchos::RCP<Teuchos::Comm<int> > localComm_;
00305 
00313   Teuchos::RCP<InverseType> Inverse_;
00314 
00316   Teuchos::ParameterList List_;
00317 };
00318 
00319 }// namespace Ifpack2
00320 
00321 
00322 
00323 #endif // IFPACK2_SPARSECONTAINER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends