Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_TriDiContainer_decl.hpp
Go to the documentation of this file.
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Templated 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 #ifndef IFPACK2_TRIDICONTAINER_DECL_HPP
43 #define IFPACK2_TRIDICONTAINER_DECL_HPP
44 
47 
48 #include "Ifpack2_Container.hpp"
49 #include "Tpetra_MultiVector.hpp"
50 #include "Tpetra_Map.hpp"
51 #include "Tpetra_RowMatrix.hpp"
54 #include <type_traits>
55 #include <string>
56 
57 namespace Ifpack2 {
58 
103 
104 template<class MatrixType, class LocalScalarType>
106 : public ContainerImpl<MatrixType, LocalScalarType>
107 {
109 
110 private:
116  using matrix_type = MatrixType;
118 
120  using typename Container<MatrixType>::SC;
122  using typename Container<MatrixType>::LO;
124  using typename Container<MatrixType>::GO;
126  using typename Container<MatrixType>::NO;
127  using LSC = LocalScalarType;
128 
129  using typename Container<MatrixType>::mv_type;
130  using typename Container<MatrixType>::map_type;
131  using typename Container<MatrixType>::vector_type;
132  using typename Container<MatrixType>::import_type;
133 
134  using typename Container<MatrixType>::ISC;
135  using typename ContainerImpl<MatrixType, LocalScalarType>::LISC;
136  using typename Container<MatrixType>::HostView;
137  using local_mv_type = Tpetra::MultiVector<LSC, LO, GO, NO>;
138  using HostViewLocal = typename Kokkos::View<LSC**, Kokkos::HostSpace>;
139  using typename ContainerImpl<MatrixType, LocalScalarType>::HostSubviewLocal;
140  using typename ContainerImpl<MatrixType, LocalScalarType>::ConstHostSubviewLocal;
141  using typename ContainerImpl<MatrixType, LocalScalarType>::block_crs_matrix_type;
142  static_assert (std::is_same<MatrixType, Tpetra::RowMatrix<SC, LO, GO, NO>>::value,
143  "Ifpack2::TriDiContainer: MatrixType must be a Tpetra::RowMatrix specialization.");
144 
153  using typename Container<MatrixType>::row_matrix_type;
155 public:
157 
158 
170  const Teuchos::Array<Teuchos::Array<LO> >& partitions,
171  const Teuchos::RCP<const import_type>& importer,
172  bool pointIndexed);
173 
175 
177  virtual ~TriDiContainer ();
178 
180 
182 
184 
186 
188  virtual void initialize ();
189 
191  virtual void compute ();
192 
193  void clearBlocks();
194 
195  void solveBlock(ConstHostSubviewLocal X,
196  HostSubviewLocal Y,
197  int blockIndex,
198  Teuchos::ETransp mode,
199  LSC alpha,
200  LSC beta) const;
201 
203 
205 
209  virtual std::ostream& print (std::ostream& os) const;
210 
212 
214 
216  virtual std::string description () const;
217 
219  virtual void
221  const Teuchos::EVerbosityLevel verbLevel =
223 
225 
227  static std::string getName();
228 private:
230  void extract();
231 
235  void factor ();
236 
238  std::vector<Teuchos::SerialTriDiMatrix<int, LSC>> diagBlocks_;
239 
241  mutable Teuchos::Array<int> ipiv_;
242 
244  Teuchos::Array<LSC> scalars_;
245 
247  Teuchos::Array<int> scalarOffsets_;
248 };
249 
250 } // namespace Ifpack2
251 
252 #endif // IFPACK2_TRIDICONTAINER_DECL_HPP
Store and solve a local TriDi linear problem.
Definition: Ifpack2_TriDiContainer_decl.hpp:105
virtual std::string description() const
A one-line description of this object.
Definition: Ifpack2_TriDiContainer_def.hpp:395
static std::string getName()
Get the name of this container type for Details::constructContainer()
Definition: Ifpack2_TriDiContainer_def.hpp:433
virtual void compute()
Extract the local diagonal block and prepare the solver.
Definition: Ifpack2_TriDiContainer_def.hpp:116
typename Kokkos::ArithTraits< SC >::val_type ISC
Internal representation of Scalar in Kokkos::View.
Definition: Ifpack2_Container_decl.hpp:135
The implementation of the numerical features of Container (Jacobi, Gauss-Seidel, SGS). This class allows a custom scalar type (LocalScalarType) to be used for storing blocks and solving the block systems. Hiding this template parameter from the Container interface simplifies the BlockRelaxation and ContainerFactory classes.
Definition: Ifpack2_Container_decl.hpp:343
virtual ~TriDiContainer()
Destructor (declared virtual for memory safety of derived classes).
Definition: Ifpack2_TriDiContainer_def.hpp:102
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to the given FancyOStream.
Definition: Ifpack2_TriDiContainer_def.hpp:418
virtual std::ostream & print(std::ostream &os) const
Print information about this object to the given output stream.
Definition: Ifpack2_TriDiContainer_def.hpp:386
typename mv_type::dual_view_type::t_host HostView
Definition: Ifpack2_Container_decl.hpp:139
static const EVerbosityLevel verbLevel_default
TriDiContainer(const Teuchos::RCP< const row_matrix_type > &matrix, const Teuchos::Array< Teuchos::Array< LO > > &partitions, const Teuchos::RCP< const import_type > &importer, bool pointIndexed)
Constructor.
Definition: Ifpack2_TriDiContainer_def.hpp:60
virtual void initialize()
Do all set-up operations that only require matrix structure.
Definition: Ifpack2_TriDiContainer_def.hpp:105
void solveBlock(ConstHostSubviewLocal X, HostSubviewLocal Y, int blockIndex, Teuchos::ETransp mode, LSC alpha, LSC beta) const
Definition: Ifpack2_TriDiContainer_def.hpp:282