46 #ifndef IFPACK2_CRSRILUK_DECL_HPP 47 #define IFPACK2_CRSRILUK_DECL_HPP 51 #include "Tpetra_CrsMatrix_decl.hpp" 54 #include "Ifpack2_LocalSparseTriangularSolver_decl.hpp" 56 #include <type_traits> 59 #ifdef IFPACK2_ILUK_EXPERIMENTAL 60 #include <Kokkos_Core.hpp> 61 #include <shylubasker_decl.hpp> 62 # ifdef IFPACK2_HTS_EXPERIMENTAL 63 # include <ShyLUHTS_config.h> 64 # include <shylu_hts_decl.hpp> 253 template<
class MatrixType>
256 typename MatrixType::local_ordinal_type,
257 typename MatrixType::global_ordinal_type,
258 typename MatrixType::node_type>,
260 typename MatrixType::local_ordinal_type,
261 typename MatrixType::global_ordinal_type,
262 typename MatrixType::node_type> >
278 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType
magnitude_type;
281 typedef Tpetra::RowMatrix<scalar_type,
287 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
"Ifpack2::RILUK: The template parameter MatrixType must be a Tpetra::RowMatrix specialization. Please don't use Tpetra::CrsMatrix (a subclass of Tpetra::RowMatrix) here anymore.");
290 typedef Tpetra::CrsMatrix<scalar_type,
295 template <
class NewMatrixType>
friend class RILUK;
300 RILUK (
const Teuchos::RCP<const row_matrix_type>& A_in);
309 RILUK (
const Teuchos::RCP<const crs_matrix_type>& A_in);
322 template <
typename NewMatrixType>
323 Teuchos::RCP< RILUK< NewMatrixType > >
324 clone (
const Teuchos::RCP<const NewMatrixType>& A_newnode)
const;
336 void setParameters (
const Teuchos::ParameterList& params);
353 return isInitialized_;
362 return numInitialize_;
375 return initializeTime_;
412 setMatrix (
const Teuchos::RCP<const row_matrix_type>& A);
419 std::string description ()
const;
426 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> >
427 getDomainMap ()
const;
430 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> >
431 getRangeMap ()
const;
463 apply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
464 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
465 Teuchos::ETransp mode = Teuchos::NO_TRANS,
466 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one (),
467 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero ())
const;
493 multiply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
494 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
495 const Teuchos::ETransp mode = Teuchos::NO_TRANS)
const;
499 Teuchos::RCP<const row_matrix_type> getMatrix ()
const;
517 TEUCHOS_TEST_FOR_EXCEPTION(
518 true, std::logic_error,
"Ifpack2::RILUK::SetOverlapMode: " 519 "RILUK no longer implements overlap on its own. " 520 "Use RILUK with AdditiveSchwarz if you want overlap.");
525 return getL ().getGlobalNumEntries () + getU ().getGlobalNumEntries ();
529 Teuchos::RCP<Ifpack2::IlukGraph<Tpetra::CrsGraph<local_ordinal_type,global_ordinal_type,node_type> > >
getGraph ()
const {
534 const crs_matrix_type& getL ()
const;
537 const Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>&
541 const crs_matrix_type& getU ()
const;
544 Teuchos::RCP<const crs_matrix_type> getCrsMatrix ()
const;
547 typedef Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> MV;
548 typedef Teuchos::ScalarTraits<scalar_type> STS;
549 typedef Teuchos::ScalarTraits<magnitude_type> STM;
551 void allocateSolvers ();
552 void allocate_L_and_U ();
553 static void checkOrderingConsistency (
const row_matrix_type& A);
554 void initAllValues (
const row_matrix_type& A);
561 static Teuchos::RCP<const row_matrix_type>
562 makeLocalFilter (
const Teuchos::RCP<const row_matrix_type>& A);
565 typedef Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> vec_type;
568 Teuchos::RCP<const row_matrix_type>
A_;
580 Teuchos::RCP<crs_matrix_type>
L_;
582 Teuchos::RCP<LocalSparseTriangularSolver<row_matrix_type> >
L_solver_;
584 Teuchos::RCP<crs_matrix_type>
U_;
586 Teuchos::RCP<LocalSparseTriangularSolver<row_matrix_type> >
U_solver_;
588 Teuchos::RCP<vec_type>
D_;
591 #ifdef IFPACK2_ILUK_EXPERIMENTAL 592 typedef typename node_type::device_type kokkos_device;
593 typedef typename kokkos_device::execution_space kokkos_exe;
595 static_assert( std::is_same< kokkos_exe,
596 Kokkos::OpenMP>::value,
597 "Kokkos node type not supported by exepertimentalthread basker RILUK decl");
600 Teuchos::RCP<const crs_matrix_type> A_local_crs_;
603 void initLocalCrs ();
605 Teuchos::RCP< BaskerNS::Basker<local_ordinal_type, scalar_type, Kokkos::OpenMP> >
607 local_ordinal_type basker_threads;
608 scalar_type basker_user_fill;
611 # ifdef IFPACK2_HTS_EXPERIMENTAL 614 typedef ::Experimental::HTS<local_ordinal_type, local_ordinal_type, scalar_type> HTST;
615 struct HTSData :
public HTST::Deallocator {
616 local_ordinal_type n;
617 local_ordinal_type* jc, * ir;
621 virtual void free_CrsMatrix_data();
623 bool operator< (
const Entry& o)
const {
return j < o.j; }
624 local_ordinal_type j; scalar_type v;
629 typename HTST::Impl* Limpl, * Uimpl;
633 Teuchos::RCP<HTSManager> hts_mgr_;
642 bool isExperimental_;
646 mutable int numApply_;
648 double initializeTime_;
650 mutable double applyTime_;
652 magnitude_type RelaxValue_;
653 magnitude_type Athresh_;
654 magnitude_type Rthresh_;
665 template<
class MatrixType,
class NodeType>
666 struct setLocalSolveParams{
667 static Teuchos::RCP<Teuchos::ParameterList>
668 setParams (
const Teuchos::RCP<Teuchos::ParameterList>& param) {
674 template <
class MatrixType>
675 template <
typename NewMatrixType>
676 Teuchos::RCP<RILUK<NewMatrixType> >
678 clone (
const Teuchos::RCP<const NewMatrixType>& A_newnode)
const 680 using Teuchos::ParameterList;
684 typedef typename NewMatrixType::scalar_type new_scalar_type;
685 typedef typename NewMatrixType::local_ordinal_type new_local_ordinal_type;
686 typedef typename NewMatrixType::global_ordinal_type new_global_ordinal_type;
687 typedef typename NewMatrixType::node_type new_node_type;
688 typedef Tpetra::RowMatrix<new_scalar_type, new_local_ordinal_type,
689 new_global_ordinal_type, new_node_type> new_row_matrix_type;
692 RCP<new_riluk_type> new_riluk = rcp (
new new_riluk_type (A_newnode));
694 RCP<ParameterList> plClone = Teuchos::parameterList ();
695 plClone = detail::setLocalSolveParams<NewMatrixType, new_node_type>::setParams (plClone);
697 RCP<new_node_type> new_node = A_newnode->getNode ();
698 new_riluk->L_ = L_->clone (new_node, plClone);
699 new_riluk->U_ = U_->clone (new_node, plClone);
700 new_riluk->D_ = D_->clone (new_node);
702 new_riluk->LevelOfFill_ = LevelOfFill_;
704 new_riluk->isAllocated_ = isAllocated_;
705 new_riluk->isInitialized_ = isInitialized_;
706 new_riluk->isComputed_ = isComputed_;
708 new_riluk->numInitialize_ = numInitialize_;
709 new_riluk->numCompute_ = numCompute_;
710 new_riluk->numApply_ = numApply_;
712 new_riluk->RelaxValue_ = RelaxValue_;
713 new_riluk->Athresh_ = Athresh_;
714 new_riluk->Rthresh_ = Rthresh_;
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:93
Declaration and definition of IlukGraph.
Ifpack2::ScalingType enumerable type.
double getComputeTime() const
Total time in seconds taken by all successful compute() calls for this object.
Definition: Ifpack2_RILUK_decl.hpp:378
int getNumApply() const
Number of successful apply() calls for this object.
Definition: Ifpack2_RILUK_decl.hpp:369
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_RILUK_decl.hpp:272
Teuchos::RCP< crs_matrix_type > L_
The L (lower triangular) factor of ILU(k).
Definition: Ifpack2_RILUK_decl.hpp:580
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
Tpetra::RowMatrix specialization used by this class.
Definition: Ifpack2_RILUK_decl.hpp:284
ILU(k) factorization of a given Tpetra::RowMatrix.
Definition: Ifpack2_RILUK_decl.hpp:254
Tpetra::CombineMode getOverlapMode()
Get overlap mode type.
Definition: Ifpack2_RILUK_decl.hpp:516
bool isComputed() const
Whether compute() has been called on this object.
Definition: Ifpack2_RILUK_decl.hpp:356
double getApplyTime() const
Total time in seconds taken by all successful apply() calls for this object.
Definition: Ifpack2_RILUK_decl.hpp:382
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_RILUK_decl.hpp:287
magnitude_type getAbsoluteThreshold() const
Get absolute threshold value.
Definition: Ifpack2_RILUK_decl.hpp:507
Teuchos::RCP< Ifpack2::IlukGraph< Tpetra::CrsGraph< local_ordinal_type, global_ordinal_type, node_type > > > getGraph() const
Return the Ifpack2::IlukGraph associated with this factored matrix.
Definition: Ifpack2_RILUK_decl.hpp:529
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_RILUK_decl.hpp:275
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_RILUK_decl.hpp:269
Teuchos::RCP< LocalSparseTriangularSolver< row_matrix_type > > U_solver_
Sparse triangular solver for U.
Definition: Ifpack2_RILUK_decl.hpp:586
int getNumCompute() const
Number of successful compute() calls for this object.
Definition: Ifpack2_RILUK_decl.hpp:365
magnitude_type getRelaxValue() const
Get RILU(k) relaxation parameter.
Definition: Ifpack2_RILUK_decl.hpp:504
Teuchos::RCP< Ifpack2::IlukGraph< Tpetra::CrsGraph< local_ordinal_type, global_ordinal_type, node_type > > > Graph_
The ILU(k) graph.
Definition: Ifpack2_RILUK_decl.hpp:573
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:107
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_RILUK_decl.hpp:278
Construct a level filled graph for use in computing an ILU(k) incomplete factorization.
Definition: Ifpack2_IlukGraph.hpp:97
Declaration of interface for preconditioners that can change their matrix after construction.
Teuchos::RCP< LocalSparseTriangularSolver< row_matrix_type > > L_solver_
Sparse triangular solver for L.
Definition: Ifpack2_RILUK_decl.hpp:582
bool isInitialized() const
Whether initialize() has been called on this object.
Definition: Ifpack2_RILUK_decl.hpp:352
Teuchos::RCP< const row_matrix_type > A_
The (original) input matrix for which to compute ILU(k).
Definition: Ifpack2_RILUK_decl.hpp:568
Tpetra::global_size_t getGlobalNumEntries() const
Returns the number of nonzero entries in the global graph.
Definition: Ifpack2_RILUK_decl.hpp:524
Definition: Ifpack2_Container.hpp:761
Teuchos::RCP< vec_type > D_
The diagonal entries of the ILU(k) factorization.
Definition: Ifpack2_RILUK_decl.hpp:588
magnitude_type getRelativeThreshold() const
Get relative threshold value.
Definition: Ifpack2_RILUK_decl.hpp:510
int getNumInitialize() const
Number of successful initialize() calls for this object.
Definition: Ifpack2_RILUK_decl.hpp:361
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
int getLevelOfFill() const
Get level of fill (the "k" in ILU(k)).
Definition: Ifpack2_RILUK_decl.hpp:513
double getInitializeTime() const
Total time in seconds taken by all successful initialize() calls for this object. ...
Definition: Ifpack2_RILUK_decl.hpp:374
Teuchos::RCP< const row_matrix_type > A_local_
The matrix whos numbers are used to to compute ILU(k). The graph may be computed using a crs_matrix_t...
Definition: Ifpack2_RILUK_decl.hpp:577
Teuchos::RCP< crs_matrix_type > U_
The U (upper triangular) factor of ILU(k).
Definition: Ifpack2_RILUK_decl.hpp:584
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_RILUK_decl.hpp:266