Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_Experimental_RBILUK_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 
45 
46 #ifndef IFPACK2_EXPERIMENTALCRSRBILUK_DECL_HPP
47 #define IFPACK2_EXPERIMENTALCRSRBILUK_DECL_HPP
48 
49 #include <Tpetra_BlockCrsMatrix.hpp>
50 
51 #include <Ifpack2_RILUK.hpp>
52 
53 namespace Ifpack2 {
54 
55 namespace Experimental {
56 
127 template<class MatrixType>
128 class RBILUK : virtual public Ifpack2::RILUK< Tpetra::RowMatrix< typename MatrixType::scalar_type,
129  typename MatrixType::local_ordinal_type, typename MatrixType::global_ordinal_type, typename MatrixType::node_type> >
130 {
131  public:
132 
134 
135  typedef typename MatrixType::scalar_type scalar_type;
137 
138  //typedef typename MatrixType::impl_scalar_type impl_scalar_type;
139  typedef typename Kokkos::ArithTraits<typename MatrixType::scalar_type>::val_type impl_scalar_type;
140 
142  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
143  typedef typename MatrixType::local_ordinal_type LO;
144 
146  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
147  typedef typename MatrixType::global_ordinal_type GO;
148 
150  typedef typename MatrixType::node_type node_type;
151 
154 
156  typedef Tpetra::RowMatrix<scalar_type,
160 
162  typedef Tpetra::CrsMatrix<scalar_type,
166 
167  using crs_graph_type = Tpetra::CrsGraph<local_ordinal_type,
169  node_type>;
170 
171  typedef Tpetra::BlockCrsMatrix<scalar_type,
174  node_type> block_crs_matrix_type;
175 
176  template <class NewMatrixType> friend class RBILUK;
177 
178  typedef typename block_crs_matrix_type::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type;
179  typedef typename block_crs_matrix_type::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
180  typedef typename block_crs_matrix_type::nonconst_values_host_view_type nonconst_values_host_view_type;
181 
183 
185 
186  typedef typename block_crs_matrix_type::local_matrix_device_type local_matrix_device_type;
187  typedef typename block_crs_matrix_type::local_matrix_host_type local_matrix_host_type;
188  typedef typename local_matrix_device_type::StaticCrsGraphType::row_map_type lno_row_view_t;
189  typedef typename local_matrix_device_type::StaticCrsGraphType::entries_type lno_nonzero_view_t;
190  typedef typename local_matrix_device_type::values_type scalar_nonzero_view_t;
191  typedef typename local_matrix_device_type::StaticCrsGraphType::device_type::memory_space TemporaryMemorySpace;
192  typedef typename local_matrix_device_type::StaticCrsGraphType::device_type::memory_space PersistentMemorySpace;
193  typedef typename local_matrix_device_type::StaticCrsGraphType::device_type::execution_space HandleExecSpace;
194  typedef typename KokkosKernels::Experimental::KokkosKernelsHandle
195  <typename lno_row_view_t::const_value_type, typename lno_nonzero_view_t::const_value_type, typename scalar_nonzero_view_t::value_type,
196  HandleExecSpace, TemporaryMemorySpace,PersistentMemorySpace > kk_handle_type;
197  //typedef typename KokkosKernels::Experimental::KokkosKernelsHandle
198  // <typename lno_row_view_t::non_const_value_type, typename lno_nonzero_view_t::non_const_value_type, typename scalar_nonzero_view_t::value_type,
199  // HandleExecSpace, TemporaryMemorySpace,PersistentMemorySpace > kk_handle_type;//test
200  Teuchos::RCP<kk_handle_type> KernelHandle_;
201 
203 
205 
210 
215 
216  private:
219  RBILUK (const RBILUK<MatrixType> & src);
220 
221  public:
222 
224  virtual ~RBILUK ();
226 
228  void initialize ();
229 
238  void compute ();
239 
241 
242 
243  // Declare that we intend to overload RILUK::setMatrix, not hide it.
244  // This avoids build warnings that the method below "hides
245  // overloaded virtual function" (e.g., Clang 3.5).
246  //
247  // NOTE: If the base class of this class changes, e.g., if its
248  // template parameter changes, then be sure to change the code below
249  // to refer to the proper base class.
250  using RILUK<Tpetra::RowMatrix<typename MatrixType::scalar_type,
251  typename MatrixType::local_ordinal_type,
252  typename MatrixType::global_ordinal_type,
253  typename MatrixType::node_type> >::setMatrix;
254 
277  void
279 
281 
283 
285  std::string description () const;
286 
288 
290 
320  void
321  apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
322  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
327 
328 public:
329 
332 
334  const block_crs_matrix_type& getLBlock () const;
335 
337  const block_crs_matrix_type& getDBlock () const;
338 
340  const block_crs_matrix_type& getUBlock () const;
341 
342 private:
343  typedef Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> MV;
346  typedef typename block_crs_matrix_type::little_block_type little_block_type;
347  typedef typename block_crs_matrix_type::little_block_host_type little_block_host_type;
348  typedef typename block_crs_matrix_type::little_vec_type little_vec_type;
349  typedef typename block_crs_matrix_type::little_host_vec_type little_host_vec_type;
350  typedef typename block_crs_matrix_type::const_host_little_vec_type const_host_little_vec_type;
351 
352  using local_inds_host_view_type = typename block_crs_matrix_type::local_inds_host_view_type;
353  using values_host_view_type = typename block_crs_matrix_type::values_host_view_type;
354  using local_inds_device_view_type = typename block_crs_matrix_type::local_inds_device_view_type;
355  using values_device_view_type = typename block_crs_matrix_type::values_device_view_type;
356 
357  void allocate_L_and_U_blocks();
358  void initAllValues ();
359 
361  local_ordinal_type blockSize_;
362 
369 
371  Teuchos::RCP<block_crs_matrix_type> D_block_inverse_;
372 };
373 
374 
375 } // namepsace Experimental
376 
377 } // namespace Ifpack2
378 
379 #endif /* IFPACK2_EXPERIMENTALCRSRBILUK_DECL_HPP */
void initialize()
Initialize by computing the symbolic incomplete factorization.
Definition: Ifpack2_Experimental_RBILUK_def.hpp:347
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:146
virtual ~RBILUK()
Destructor (declared virtual for memory safety).
Definition: Ifpack2_Experimental_RBILUK_def.hpp:136
const block_crs_matrix_type & getUBlock() const
Return the U factor of the ILU factorization.
Definition: Ifpack2_Experimental_RBILUK_def.hpp:193
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:136
void apply(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const
Apply the (inverse of the) incomplete factorization to X, resulting in Y.
Definition: Ifpack2_Experimental_RBILUK_def.hpp:1010
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:153
ILU(k) factorization of a given Tpetra::RowMatrix.
Definition: Ifpack2_RILUK_decl.hpp:245
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:150
Tpetra::CrsMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > crs_matrix_type
Tpetra::CrsMatrix specialization used by this class for representing L and U.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:165
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:142
const block_crs_matrix_type & getDBlock() const
Return the diagonal entries of the ILU factorization.
Definition: Ifpack2_Experimental_RBILUK_def.hpp:179
void compute()
Compute the (numeric) incomplete factorization.
Definition: Ifpack2_Experimental_RBILUK_def.hpp:595
Teuchos::RCP< const block_crs_matrix_type > getBlockMatrix() const
Get the input matrix.
void setMatrix(const Teuchos::RCP< const block_crs_matrix_type > &A)
Change the matrix to be preconditioned.
Definition: Ifpack2_Experimental_RBILUK_def.hpp:141
const block_crs_matrix_type & getLBlock() const
Return the L factor of the ILU factorization.
Definition: Ifpack2_Experimental_RBILUK_def.hpp:165
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
Tpetra::RowMatrix specialization used by this class.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:159
std::string description() const
A one-line description of this object.
Definition: Ifpack2_Experimental_RBILUK_def.hpp:1205
ILU(k) factorization of a given Tpetra::BlockCrsMatrix.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:128