Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
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
53namespace Ifpack2 {
54
55namespace Experimental {
56
127template<class MatrixType>
128class 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
136 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
153 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
154
156 typedef Tpetra::RowMatrix<scalar_type,
160
162 typedef Tpetra::CrsMatrix<scalar_type,
166
167 typedef Tpetra::BlockCrsMatrix<scalar_type,
170 node_type> block_crs_matrix_type;
171
172 template <class NewMatrixType> friend class RBILUK;
173
175
177
178 typedef typename crs_matrix_type::local_matrix_device_type local_matrix_device_type;
179 typedef typename local_matrix_device_type::StaticCrsGraphType::row_map_type lno_row_view_t;
180 typedef typename local_matrix_device_type::StaticCrsGraphType::entries_type lno_nonzero_view_t;
181 typedef typename local_matrix_device_type::values_type scalar_nonzero_view_t;
182 typedef typename local_matrix_device_type::StaticCrsGraphType::device_type::memory_space TemporaryMemorySpace;
183 typedef typename local_matrix_device_type::StaticCrsGraphType::device_type::memory_space PersistentMemorySpace;
184 typedef typename local_matrix_device_type::StaticCrsGraphType::device_type::execution_space HandleExecSpace;
185 typedef typename KokkosKernels::Experimental::KokkosKernelsHandle
186 <typename lno_row_view_t::const_value_type, typename lno_nonzero_view_t::const_value_type, typename scalar_nonzero_view_t::value_type,
187 HandleExecSpace, TemporaryMemorySpace,PersistentMemorySpace > kk_handle_type;
188 //typedef typename KokkosKernels::Experimental::KokkosKernelsHandle
189 // <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,
190 // HandleExecSpace, TemporaryMemorySpace,PersistentMemorySpace > kk_handle_type;//test
191 Teuchos::RCP<kk_handle_type> KernelHandle_;
192
194
196
197
200 RBILUK (const Teuchos::RCP<const row_matrix_type>& A_in);
201
205 RBILUK (const Teuchos::RCP<const block_crs_matrix_type>& A_in);
206
207 private:
210 RBILUK (const RBILUK<MatrixType> & src);
211
212 public:
213
215 virtual ~RBILUK ();
217
219 void initialize ();
220
229 void compute ();
230
232
233
234 // Declare that we intend to overload RILUK::setMatrix, not hide it.
235 // This avoids build warnings that the method below "hides
236 // overloaded virtual function" (e.g., Clang 3.5).
237 //
238 // NOTE: If the base class of this class changes, e.g., if its
239 // template parameter changes, then be sure to change the code below
240 // to refer to the proper base class.
241 using RILUK<Tpetra::RowMatrix<typename MatrixType::scalar_type,
242 typename MatrixType::local_ordinal_type,
243 typename MatrixType::global_ordinal_type,
244 typename MatrixType::node_type> >::setMatrix;
245
268 void
269 setMatrix (const Teuchos::RCP<const block_crs_matrix_type>& A);
270
272
274
276 std::string description () const;
277
279
281
311 void
312 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
313 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
314 Teuchos::ETransp mode = Teuchos::NO_TRANS,
315 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one (),
316 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero ()) const;
318
319public:
320
322 Teuchos::RCP<const block_crs_matrix_type> getBlockMatrix () const;
323
325 const block_crs_matrix_type& getLBlock () const;
326
328 const block_crs_matrix_type& getDBlock () const;
329
331 const block_crs_matrix_type& getUBlock () const;
332
333private:
334 typedef Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> MV;
335 typedef Teuchos::ScalarTraits<impl_scalar_type> STS;
336 typedef Teuchos::ScalarTraits<magnitude_type> STM;
337 typedef typename block_crs_matrix_type::little_block_type little_block_type;
338 typedef typename block_crs_matrix_type::little_block_host_type little_block_host_type;
339 typedef typename block_crs_matrix_type::little_vec_type little_vec_type;
340 typedef typename block_crs_matrix_type::little_host_vec_type little_host_vec_type;
341 typedef typename block_crs_matrix_type::const_host_little_vec_type const_host_little_vec_type;
342
343 using local_inds_host_view_type = typename block_crs_matrix_type::local_inds_host_view_type;
344 using values_host_view_type = typename block_crs_matrix_type::values_host_view_type;
345 using local_inds_device_view_type = typename block_crs_matrix_type::local_inds_device_view_type;
346 using values_device_view_type = typename block_crs_matrix_type::values_device_view_type;
347
348 void allocate_L_and_U_blocks();
349 void initAllValues (const block_crs_matrix_type& A);
350
352 Teuchos::RCP<const row_matrix_type> A_;
353
355 Teuchos::RCP<const block_crs_matrix_type> A_block_;
356
358 local_ordinal_type blockSize_;
359
361 Teuchos::RCP<block_crs_matrix_type> L_block_;
363 Teuchos::RCP<block_crs_matrix_type> U_block_;
365 Teuchos::RCP<block_crs_matrix_type> D_block_;
366
368 Teuchos::RCP<block_crs_matrix_type> D_block_inverse_;
369};
370
371
372} // namepsace Experimental
373
374} // namespace Ifpack2
375
376#endif /* IFPACK2_EXPERIMENTALCRSRBILUK_DECL_HPP */
ILU(k) factorization of a given Tpetra::BlockCrsMatrix.
Definition Ifpack2_Experimental_RBILUK_decl.hpp:130
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition Ifpack2_Experimental_RBILUK_decl.hpp:150
const block_crs_matrix_type & getUBlock() const
Return the U factor of the ILU factorization.
Definition Ifpack2_Experimental_RBILUK_def.hpp:139
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
Teuchos::RCP< const block_crs_matrix_type > getBlockMatrix() const
Get the input matrix.
Definition Ifpack2_Experimental_RBILUK_def.hpp:182
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition Ifpack2_Experimental_RBILUK_decl.hpp:142
void setMatrix(const Teuchos::RCP< const block_crs_matrix_type > &A)
Change the matrix to be preconditioned.
Definition Ifpack2_Experimental_RBILUK_def.hpp:86
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:800
void compute()
Compute the (numeric) incomplete factorization.
Definition Ifpack2_Experimental_RBILUK_def.hpp:458
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
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition Ifpack2_Experimental_RBILUK_decl.hpp:136
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:81
const block_crs_matrix_type & getDBlock() const
Return the diagonal entries of the ILU factorization.
Definition Ifpack2_Experimental_RBILUK_def.hpp:125
void initialize()
Initialize by computing the symbolic incomplete factorization.
Definition Ifpack2_Experimental_RBILUK_def.hpp:187
std::string description() const
A one-line description of this object.
Definition Ifpack2_Experimental_RBILUK_def.hpp:952
const block_crs_matrix_type & getLBlock() const
Return the L factor of the ILU factorization.
Definition Ifpack2_Experimental_RBILUK_def.hpp:111
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
ILU(k) factorization of a given Tpetra::RowMatrix.
Definition Ifpack2_RILUK_decl.hpp:254
Ifpack2 features that are experimental. Use at your own risk.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:74