Ifpack2 Templated Preconditioning Package  Version 1.0
Ifpack2_SparseContainer_decl.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_SPARSECONTAINER_DECL_HPP
44 #define IFPACK2_SPARSECONTAINER_DECL_HPP
45 
46 #include "Ifpack2_Container.hpp"
47 #include "Tpetra_MultiVector.hpp"
48 #include "Tpetra_Map.hpp"
49 #include "Tpetra_RowMatrix.hpp"
50 #include "Tpetra_CrsMatrix.hpp"
51 #include "Teuchos_ParameterList.hpp"
52 #include "Teuchos_RefCountPtr.hpp"
53 
54 
82 namespace Ifpack2 {
83 
84 template<typename MatrixType, typename InverseType >
85 class SparseContainer : public Container<MatrixType,InverseType> {
86 
87 public:
88  typedef typename MatrixType::scalar_type MatrixScalar;
89  typedef typename MatrixType::local_ordinal_type MatrixLocalOrdinal;
90  typedef typename MatrixType::global_ordinal_type MatrixGlobalOrdinal;
91  typedef typename MatrixType::node_type MatrixNode;
92 
93  typedef typename InverseType::scalar_type InverseScalar;
94  typedef typename InverseType::local_ordinal_type InverseLocalOrdinal;
95  typedef typename InverseType::global_ordinal_type InverseGlobalOrdinal;
96  typedef typename InverseType::node_type InverseNode;
97 
99  SparseContainer(const size_t NumRows, const size_t NumVectors = 1);
101 
103  virtual ~SparseContainer();
105 
107  virtual size_t getNumRows() const;
109 
110  // Returns the number of vectors in X/Y.
111  // virtual size_t getNumVectors() const;
112 
114 
123  virtual MatrixLocalOrdinal & ID(const size_t i);
124 
126  virtual bool isInitialized() const;
127 
129  virtual bool isComputed() const;
130 
132  virtual void setParameters(const Teuchos::ParameterList& List);
133 
135 
137 
144  virtual void initialize();
146  virtual void compute(const Teuchos::RCP<const Tpetra::RowMatrix<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode> >& Matrix);
147 
149 
151  virtual void apply(const Tpetra::MultiVector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& X,
152  Tpetra::MultiVector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& Y,
153  Teuchos::ETransp mode=Teuchos::NO_TRANS,
154  MatrixScalar alpha=Teuchos::ScalarTraits< MatrixScalar >::one(),
155  MatrixScalar beta=Teuchos::ScalarTraits< MatrixScalar >::zero());
156 
158 
162  virtual void weightedApply(const Tpetra::MultiVector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& X,
163  Tpetra::MultiVector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& Y,
164  const Tpetra::Vector<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode>& D,
165  Teuchos::ETransp mode=Teuchos::NO_TRANS,
166  MatrixScalar alpha=Teuchos::ScalarTraits< MatrixScalar >::one(),
167  MatrixScalar beta=Teuchos::ScalarTraits< MatrixScalar >::zero());
168 
169 
171 
173  virtual void destroy();
176 
178  virtual std::ostream& print(std::ostream& os) const;
179 
181 
182 
184  virtual std::string description() const;
185 
187  virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
188 
190 
191 private:
192  // private copy constructor
193  SparseContainer(const SparseContainer<MatrixType,InverseType>& rhs);
194 
196  virtual void setNumVectors(const size_t NumVectors);
197 
199  virtual void extract(const Teuchos::RCP<const Tpetra::RowMatrix<MatrixScalar,MatrixLocalOrdinal,MatrixGlobalOrdinal,MatrixNode> >& Matrix);
200 
202  size_t NumRows_;
204  size_t NumVectors_;
206  Teuchos::RCP<Tpetra::Map<InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > Map_;
208  Teuchos::RCP<Tpetra::CrsMatrix<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > Matrix_;
210  mutable Teuchos::RCP<Tpetra::MultiVector<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > Y_;
212  mutable Teuchos::RCP<Tpetra::MultiVector<InverseScalar,InverseLocalOrdinal,InverseGlobalOrdinal,InverseNode> > X_;
214  std::vector<MatrixLocalOrdinal> GID_;
216  bool IsInitialized_;
218  bool IsComputed_;
220  Teuchos::RCP<Teuchos::Comm<int> > LocalComm_;
222  Teuchos::RCP<InverseType> Inverse_;
223 
224  Teuchos::ParameterList List_;
225 
226 };
227 
228 }// namespace Ifpack2
229 
230 
231 
232 #endif // IFPACK2_SPARSECONTAINER_HPP
Ifpack2::Container: a pure virtual class for creating and solving local linear problems.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:67