43 #ifndef IFPACK2_RELAXATION_DECL_HPP 44 #define IFPACK2_RELAXATION_DECL_HPP 48 #include "Ifpack2_Parameters.hpp" 49 #include "Tpetra_Vector.hpp" 50 #include "Teuchos_ScalarTraits.hpp" 51 #include "Tpetra_CrsMatrix_decl.hpp" 52 #include "Tpetra_Experimental_BlockCrsMatrix_decl.hpp" 53 #include <type_traits> 55 #ifdef HAVE_IFPACK2_EXPERIMENTAL_KOKKOSKERNELS_FEATURES 56 #include <KokkosKernels_Handle.hpp> 225 template<
class MatrixType>
228 typename MatrixType::local_ordinal_type,
229 typename MatrixType::global_ordinal_type,
230 typename MatrixType::node_type>,
232 typename MatrixType::local_ordinal_type,
233 typename MatrixType::global_ordinal_type,
234 typename MatrixType::node_type> >
253 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType
magnitude_type;
256 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
259 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
"Ifpack2::Relaxation: Please use MatrixType = Tpetra::RowMatrix. This saves build times, library sizes, and executable sizes. Don't worry, this class still works with CrsMatrix and BlockCrsMatrix; those are both subclasses of RowMatrix.");
298 explicit Relaxation (
const Teuchos::RCP<const row_matrix_type>& A);
384 void setParameters (
const Teuchos::ParameterList& params);
387 Teuchos::RCP<const Teuchos::ParameterList>
402 return isInitialized_;
447 setMatrix (
const Teuchos::RCP<const row_matrix_type>& A);
469 apply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
470 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
471 Teuchos::ETransp mode = Teuchos::NO_TRANS,
472 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
473 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const;
476 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> >
477 getDomainMap ()
const;
480 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> >
481 getRangeMap ()
const;
484 bool hasTransposeApply ()
const;
499 applyMat (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
500 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
501 Teuchos::ETransp mode = Teuchos::NO_TRANS)
const;
508 Teuchos::RCP<const Teuchos::Comm<int> > getComm()
const;
511 Teuchos::RCP<const row_matrix_type> getMatrix ()
const;
514 double getComputeFlops()
const;
517 double getApplyFlops()
const;
520 int getNumInitialize()
const;
523 int getNumCompute()
const;
526 int getNumApply()
const;
529 double getInitializeTime()
const;
532 double getComputeTime()
const;
535 double getApplyTime()
const;
547 std::string description ()
const;
572 describe (Teuchos::FancyOStream &out,
573 const Teuchos::EVerbosityLevel verbLevel =
574 Teuchos::Describable::verbLevel_default)
const;
581 typedef Teuchos::ScalarTraits<scalar_type> STS;
582 typedef Teuchos::ScalarTraits<magnitude_type> STM;
588 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type,
589 global_ordinal_type, node_type> crs_matrix_type;
590 typedef Tpetra::Experimental::BlockCrsMatrix<scalar_type, local_ordinal_type,
591 global_ordinal_type, node_type> block_crs_matrix_type;
592 typedef Tpetra::Experimental::BlockMultiVector<scalar_type, local_ordinal_type,
593 global_ordinal_type, node_type> block_multivector_type;
595 #ifdef HAVE_IFPACK2_EXPERIMENTAL_KOKKOSKERNELS_FEATURES 596 typedef typename crs_matrix_type::local_matrix_type kokkos_csr_matrix;
597 typedef typename kokkos_csr_matrix::StaticCrsGraphType crs_graph_type;
598 typedef typename kokkos_csr_matrix::StaticCrsGraphType::row_map_type lno_row_view_t;
599 typedef typename kokkos_csr_matrix::StaticCrsGraphType::entries_type lno_nonzero_view_t;
600 typedef typename kokkos_csr_matrix::values_type scalar_nonzero_view_t;
601 typedef typename kokkos_csr_matrix::StaticCrsGraphType::device_type TemporaryWorkSpace;
602 typedef typename kokkos_csr_matrix::StaticCrsGraphType::device_type PersistentWorkSpace;
603 typedef typename kokkos_csr_matrix::StaticCrsGraphType::execution_space MyExecSpace;
604 typedef typename KokkosKernels::Experimental::KokkosKernelsHandle
605 <lno_row_view_t,lno_nonzero_view_t, scalar_nonzero_view_t,
606 MyExecSpace, TemporaryWorkSpace,PersistentWorkSpace > KernelHandle;
607 Teuchos::RCP<KernelHandle> kh;
627 void setParametersImpl (Teuchos::ParameterList& params);
630 void ApplyInverseJacobi(
631 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
632 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
635 void ApplyInverseJacobi_BlockCrsMatrix(
636 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
637 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
641 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
642 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
645 void ApplyInverseMTGS_CrsMatrix(
646 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
647 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
651 void ApplyInverseGS_RowMatrix(
652 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
653 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
657 ApplyInverseGS_CrsMatrix (
const crs_matrix_type& A,
658 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
659 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
663 ApplyInverseGS_BlockCrsMatrix (
const block_crs_matrix_type& A,
664 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
665 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y);
668 void ApplyInverseSGS(
669 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
670 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
673 void ApplyInverseMTSGS_CrsMatrix(
674 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
675 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
678 const crs_matrix_type* crsMat,
679 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
680 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& B,
681 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& D,
682 const scalar_type& dampingFactor,
683 const Tpetra::ESweepDirection direction,
685 const bool zeroInitialGuess)
const;
688 void ApplyInverseSGS_RowMatrix(
689 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
690 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
694 ApplyInverseSGS_CrsMatrix (
const crs_matrix_type& A,
695 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
696 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y)
const;
700 ApplyInverseSGS_BlockCrsMatrix (
const block_crs_matrix_type& A,
701 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
702 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y);
704 void computeBlockCrs ();
717 mutable Teuchos::RCP<const Teuchos::ParameterList> validParams_;
720 Teuchos::RCP<const row_matrix_type> A_;
722 Teuchos::RCP<Teuchos::Time> Time_;
724 Teuchos::RCP<const Tpetra::Import<local_ordinal_type,global_ordinal_type,node_type> > Importer_;
726 Teuchos::RCP<Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > Diagonal_;
729 typedef Kokkos::View<
typename block_crs_matrix_type::impl_scalar_type***,
730 typename block_crs_matrix_type::device_type> block_diag_type;
731 typedef Kokkos::View<
typename block_crs_matrix_type::impl_scalar_type***,
732 typename block_crs_matrix_type::device_type,
733 Kokkos::MemoryUnmanaged> unmanaged_block_diag_type;
749 block_diag_type blockDiag_;
751 Teuchos::RCP<block_multivector_type> yBlockColumnPointMap_;
756 Details::RelaxationType PrecType_;
758 scalar_type DampingFactor_;
762 bool ZeroStartingSolution_;
768 magnitude_type L1Eta_;
770 scalar_type MinDiagonalValue_;
772 bool fixTinyDiagEntries_;
774 bool checkDiagEntries_;
785 mutable int NumApply_;
787 double InitializeTime_;
791 mutable double ApplyTime_;
793 double ComputeFlops_;
795 mutable double ApplyFlops_;
798 magnitude_type globalMinMagDiagEntryMag_;
800 magnitude_type globalMaxMagDiagEntryMag_;
802 size_t globalNumSmallDiagEntries_;
804 size_t globalNumZeroDiagEntries_;
806 size_t globalNumNegDiagEntries_;
811 magnitude_type globalDiagNormDiff_;
818 Kokkos::View<size_t*, typename node_type::device_type> diagOffsets_;
825 bool savedDiagOffsets_;
827 bool hasBlockCrsMatrix_;
830 Teuchos::ArrayRCP<local_ordinal_type> localSmoothingIndices_;
837 #endif // IFPACK2_RELAXATION_DECL_HPP Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:93
bool isInitialized() const
Returns true if the preconditioner has been successfully initialized.
Definition: Ifpack2_Relaxation_decl.hpp:401
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_Relaxation_decl.hpp:250
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:107
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_Relaxation_decl.hpp:247
Declaration of interface for preconditioners that can change their matrix after construction.
bool isComputed() const
Return true if compute() has been called.
Definition: Ifpack2_Relaxation_decl.hpp:416
Definition: Ifpack2_Container.hpp:761
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_Relaxation_decl.hpp:244
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_Relaxation_decl.hpp:241
Relaxation preconditioners for Tpetra::RowMatrix and Tpetra::CrsMatrix sparse matrices.
Definition: Ifpack2_Relaxation_decl.hpp:226
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
void getValidParameters(Teuchos::ParameterList ¶ms)
Fills a list which contains all the parameters possibly used by Ifpack2.
Definition: Ifpack2_Parameters.cpp:50
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
Tpetra::RowMatrix specialization used by this class.
Definition: Ifpack2_Relaxation_decl.hpp:257
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_Relaxation_decl.hpp:253