10 #ifndef IFPACK2_RELAXATION_DECL_HPP
11 #define IFPACK2_RELAXATION_DECL_HPP
15 #include "Ifpack2_Parameters.hpp"
16 #include "Tpetra_Vector.hpp"
18 #include "Tpetra_CrsMatrix.hpp"
19 #include "Tpetra_BlockCrsMatrix.hpp"
20 #include <type_traits>
21 #include <KokkosKernels_Handle.hpp>
22 #include "Ifpack2_Details_GaussSeidel.hpp"
23 #include "Ifpack2_Details_InverseDiagonalKernel.hpp"
25 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 template <
class TpetraOperatorType>
30 class ScaledDampedResidual;
40 #endif // DOXYGEN_SHOULD_SKIP_THIS
205 template <
class MatrixType>
207 typename MatrixType::scalar_type,
208 typename MatrixType::local_ordinal_type,
209 typename MatrixType::global_ordinal_type,
210 typename MatrixType::node_type>,
212 Tpetra::RowMatrix<typename MatrixType::scalar_type,
213 typename MatrixType::local_ordinal_type,
214 typename MatrixType::global_ordinal_type,
215 typename MatrixType::node_type> > {
250 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.");
375 bool supportsZeroStartingSolution() {
return true; }
388 return isInitialized_;
448 apply(
const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
449 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
569 typedef typename Kokkos::ArithTraits<scalar_type>::val_type impl_scalar_type;
586 block_crs_matrix_type;
589 block_multivector_type;
591 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
592 typedef Tpetra::Import<local_ordinal_type, global_ordinal_type, node_type> import_type;
594 typedef typename crs_matrix_type::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
595 typedef typename crs_matrix_type::nonconst_values_host_view_type nonconst_values_host_view_type;
603 typedef typename crs_matrix_type::local_matrix_device_type local_matrix_device_type;
604 typedef typename local_matrix_device_type::StaticCrsGraphType::row_map_type lno_row_view_t;
605 typedef typename local_matrix_device_type::StaticCrsGraphType::entries_type lno_nonzero_view_t;
606 typedef typename local_matrix_device_type::values_type scalar_nonzero_view_t;
607 typedef typename local_matrix_device_type::StaticCrsGraphType::device_type TemporaryWorkSpace;
608 typedef typename local_matrix_device_type::StaticCrsGraphType::device_type PersistentWorkSpace;
609 typedef typename local_matrix_device_type::StaticCrsGraphType::execution_space MyExecSpace;
610 typedef typename KokkosKernels::Experimental::KokkosKernelsHandle<
typename lno_row_view_t::const_value_type,
local_ordinal_type,
typename scalar_nonzero_view_t::value_type,
611 MyExecSpace, TemporaryWorkSpace, PersistentWorkSpace>
612 mt_kernel_handle_type;
619 using SerialGaussSeidel = Ifpack2::Details::GaussSeidel<scalar_type, local_ordinal_type, global_ordinal_type, node_type>;
643 void ApplyInverseRichardson(
644 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
645 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y)
const;
648 void ApplyInverseJacobi(
649 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
650 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y)
const;
653 void ApplyInverseJacobi_BlockCrsMatrix(
654 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
655 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y)
const;
658 void ApplyInverseMTGS_CrsMatrix(
659 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& B,
660 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
661 Tpetra::ESweepDirection direction)
const;
664 void ApplyInverseSerialGS(
665 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
666 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
667 Tpetra::ESweepDirection direction)
const;
670 void ApplyInverseSerialGS_CrsMatrix(
const crs_matrix_type& A,
671 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& B,
672 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
673 Tpetra::ESweepDirection direction)
const;
676 void ApplyInverseSerialGS_RowMatrix(
677 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
678 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
679 Tpetra::ESweepDirection direction)
const;
682 void ApplyInverseSerialGS_BlockCrsMatrix(
683 const block_crs_matrix_type& A,
684 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
685 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
686 Tpetra::ESweepDirection direction);
689 void ApplyInverseMTSGS_CrsMatrix(
690 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
691 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y)
const;
694 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& B,
695 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
696 const Tpetra::ESweepDirection direction)
const;
698 void computeBlockCrs();
701 void updateCachedMultiVector(
const Teuchos::RCP<
const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> >& map,
size_t numVecs)
const;
727 typedef Kokkos::View<
typename block_crs_matrix_type::impl_scalar_type***,
728 typename block_crs_matrix_type::device_type>
730 typedef Kokkos::View<
typename block_crs_matrix_type::impl_scalar_type***,
731 typename block_crs_matrix_type::device_type,
732 Kokkos::MemoryUnmanaged>
733 unmanaged_block_diag_type;
749 block_diag_type blockDiag_;
756 Details::RelaxationType PrecType_ = Ifpack2::Details::JACOBI;
762 bool ZeroStartingSolution_ =
true;
764 bool DoBackwardGS_ =
false;
766 bool DoL1Method_ =
false;
772 bool fixTinyDiagEntries_ =
false;
774 bool checkDiagEntries_ =
false;
776 int clusterSize_ = 1;
778 int longRowThreshold_ = 0;
780 KokkosGraph::ColoringAlgorithm mtColoringAlgorithm_ = KokkosGraph::COLORING_DEFAULT;
783 int NumOuterSweeps_ = 1;
785 int NumInnerSweeps_ = 1;
787 bool InnerSpTrsv_ =
false;
791 bool CompactForm_ =
false;
794 bool is_matrix_structurally_symmetric_ =
false;
797 bool ifpack2_dump_matrix_ =
false;
800 bool isInitialized_ =
false;
802 bool IsComputed_ =
false;
804 int NumInitialize_ = 0;
808 bool TimerForApply_ =
true;
810 mutable int NumApply_ = 0;
812 double InitializeTime_ = 0.0;
814 double ComputeTime_ = 0.0;
816 mutable double ApplyTime_ = 0.0;
818 double ComputeFlops_ = 0.0;
820 mutable double ApplyFlops_ = 0.0;
827 size_t globalNumSmallDiagEntries_ = 0;
829 size_t globalNumZeroDiagEntries_ = 0;
831 size_t globalNumNegDiagEntries_ = 0;
843 Kokkos::View<size_t*, typename node_type::device_type> diagOffsets_;
850 bool savedDiagOffsets_ =
false;
852 bool hasBlockCrsMatrix_ =
false;
862 #endif // IFPACK2_RELAXATION_DECL_HPP
bool hasTransposeApply() const
Whether apply() and applyMat() let you apply the transpose or conjugate transpose.
Definition: Ifpack2_Relaxation_def.hpp:484
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:60
Tpetra::Operator< scalar_type, local_ordinal_type, global_ordinal_type, node_type > op_type
Tpetra::Operator specialization used by this class.
Definition: Ifpack2_Relaxation_decl.hpp:248
double getComputeFlops() const
Total number of floating-point operations over all calls to compute().
Definition: Ifpack2_Relaxation_def.hpp:519
double getApplyFlops() const
Total number of floating-point operations over all calls to apply().
Definition: Ifpack2_Relaxation_def.hpp:524
void setZeroStartingSolution(bool zeroStartingSolution)
Set this preconditioner's parameters.
Definition: Ifpack2_Relaxation_decl.hpp:377
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object's attributes to the given output stream.
Definition: Ifpack2_Relaxation_def.hpp:2186
Relaxation(const Teuchos::RCP< const row_matrix_type > &A)
Constructor.
Definition: Ifpack2_Relaxation_def.hpp:182
void compute()
Compute the preconditioner ("numeric setup");.
Definition: Ifpack2_Relaxation_def.hpp:960
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
Definition: Ifpack2_Relaxation_def.hpp:529
MatrixType::node_type::device_type device_type
The Kokkos device type used by the input MatrixType.
Definition: Ifpack2_Relaxation_decl.hpp:233
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the matrix and vectors are distributed.
Definition: Ifpack2_Relaxation_def.hpp:442
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Change the matrix to be preconditioned.
Definition: Ifpack2_Relaxation_def.hpp:162
int getNumApply() const
Total number of calls to apply().
Definition: Ifpack2_Relaxation_def.hpp:499
double getComputeTime() const
Total time in seconds spent in all calls to compute().
Definition: Ifpack2_Relaxation_def.hpp:509
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_Relaxation_decl.hpp:230
Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getDomainMap() const
Returns the Tpetra::Map object associated with the domain of this operator.
Definition: Ifpack2_Relaxation_def.hpp:461
void setParameters(const Teuchos::ParameterList ¶ms)
Set the relaxation / preconditioner parameters.
Definition: Ifpack2_Relaxation_def.hpp:434
std::string description() const
A simple one-line description of this object.
Definition: Ifpack2_Relaxation_def.hpp:2085
int getNumInitialize() const
Total number of calls to initialize().
Definition: Ifpack2_Relaxation_def.hpp:489
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
bool isComputed() const
Return true if compute() has been called.
Definition: Ifpack2_Relaxation_decl.hpp:395
Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getRangeMap() const
Returns the Tpetra::Map object associated with the range of this operator.
Definition: Ifpack2_Relaxation_def.hpp:474
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_Relaxation_decl.hpp:227
double getInitializeTime() const
Total time in seconds spent in all calls to initialize().
Definition: Ifpack2_Relaxation_def.hpp:504
Declaration of interface for preconditioners that can change their matrix after construction.
static const EVerbosityLevel verbLevel_default
void applyMat(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) const
Apply the input matrix to X, returning the result in Y.
Definition: Ifpack2_Relaxation_def.hpp:653
Teuchos::RCP< const row_matrix_type > getMatrix() const
The matrix to be preconditioned.
Definition: Ifpack2_Relaxation_def.hpp:453
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_Relaxation_decl.hpp:224
virtual ~Relaxation()=default
Destructor.
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_Relaxation_decl.hpp:221
static scalar_type zero()
int getNumCompute() const
Total number of calls to compute().
Definition: Ifpack2_Relaxation_def.hpp:494
bool isInitialized() const
Returns true if the preconditioner has been successfully initialized.
Definition: Ifpack2_Relaxation_decl.hpp:387
Relaxation preconditioners for Tpetra::RowMatrix and Tpetra::CrsMatrix sparse matrices.
Definition: Ifpack2_Relaxation_decl.hpp:206
double getApplyTime() const
Total time in seconds spent in all calls to apply().
Definition: Ifpack2_Relaxation_def.hpp:514
void initialize()
Initialize the preconditioner ("symbolic setup").
Definition: Ifpack2_Relaxation_def.hpp:674
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:241
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 preconditioner to X, returning the result in Y.
Definition: Ifpack2_Relaxation_def.hpp:541
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return a list of all the parameters that this class accepts.
Definition: Ifpack2_Relaxation_def.hpp:191
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_Relaxation_decl.hpp:236