43 #ifndef IFPACK2_BLOCKTRIDICONTAINER_DECL_HPP
44 #define IFPACK2_BLOCKTRIDICONTAINER_DECL_HPP
49 #include "Ifpack2_config.h"
51 #include "Tpetra_MultiVector.hpp"
52 #include "Tpetra_Map.hpp"
53 #include "Tpetra_RowMatrix.hpp"
54 #include "Tpetra_BlockCrsMatrix_decl.hpp"
55 #include <type_traits>
111 namespace BlockTriDiContainerDetails {
116 struct ImplSimdTag {};
117 struct ImplSacadoTag {};
119 template<
typename T>
struct ImplTag {
typedef ImplNotAvailTag type; };
120 template<>
struct ImplTag<float> {
typedef ImplSimdTag type; };
121 template<>
struct ImplTag<double> {
typedef ImplSimdTag type; };
122 template<>
struct ImplTag<std::complex<float> > {
typedef ImplSimdTag type; };
123 template<>
struct ImplTag<std::complex<double> > {
typedef ImplSimdTag type; };
132 template <
typename MatrixType,
141 template <
typename MatrixType>
152 typedef MatrixType matrix_type;
155 typedef typename Container<MatrixType>::scalar_type scalar_type;
157 typedef typename Kokkos::ArithTraits<scalar_type>::magnitudeType magnitude_type;
159 typedef typename Container<MatrixType>::local_ordinal_type local_ordinal_type;
161 typedef typename Container<MatrixType>::global_ordinal_type global_ordinal_type;
163 typedef typename Container<MatrixType>::node_type node_type;
165 typedef typename Container<MatrixType>::mv_type mv_type;
166 typedef typename Container<MatrixType>::map_type map_type;
167 typedef typename Container<MatrixType>::vector_type vector_type;
169 typedef typename Container<MatrixType>::import_type import_type;
171 typedef typename Container<MatrixType>::HostView host_view_type;
172 typedef host_view_type HostView;
176 typedef Tpetra::Experimental::BlockCrsMatrix
177 <scalar_type,local_ordinal_type,global_ordinal_type,node_type> block_crs_matrix_type;
185 typedef typename Container<MatrixType>::row_matrix_type row_matrix_type;
187 static_assert (std::is_same<MatrixType, row_matrix_type>::value,
188 "Ifpack2::BlockTriDiContainer: MatrixType must be a Tpetra::RowMatrix specialization.");
213 scalar_type DampingFactor);
231 bool overlapCommAndComp =
false,
bool useSequentialMethod =
false);
236 struct ComputeParameters {
243 magnitude_type addRadiallyToDiagonal = Kokkos::ArithTraits<magnitude_type>::zero();
247 struct ApplyParameters {
250 bool zeroStartingSolution =
false;
252 scalar_type dampingFactor = Kokkos::ArithTraits<scalar_type>::one();
255 int maxNumSweeps = 1;
265 magnitude_type tolerance = Kokkos::ArithTraits<magnitude_type>::zero();
273 int checkToleranceEvery = 1;
281 bool isInitialized()
const override;
284 bool isComputed()
const override;
289 void clearBlocks()
override;
296 void initialize ()
override;
299 void compute ()
override;
302 void applyInverseJacobi (
const mv_type& X, mv_type& Y,
303 bool zeroStartingSolution =
false,
304 int numSweeps = 1)
const override;
307 ComputeParameters createDefaultComputeParameters ()
const;
320 void compute (
const ComputeParameters& input);
323 ApplyParameters createDefaultApplyParameters ()
const;
331 int applyInverseJacobi (
const mv_type& X, mv_type& Y,
332 const ApplyParameters& input)
const;
347 apply (host_view_type& X,
358 weightedApply (host_view_type& X,
374 std::ostream& print (std::ostream& os)
const override;
381 std::string description ()
const override;
392 static std::string getName();
411 const bool overlapCommAndComp,
412 const bool useSeqMethod);
414 void clearInternal();
424 template <
typename MatrixType>
428 typedef typename Container<MatrixType>::scalar_type scalar_type;
429 typedef typename Kokkos::ArithTraits<scalar_type>::magnitudeType magnitude_type;
430 typedef typename Container<MatrixType>::local_ordinal_type local_ordinal_type;
431 typedef typename Container<MatrixType>::global_ordinal_type global_ordinal_type;
433 typedef typename Container<MatrixType>::mv_type mv_type;
435 typedef typename Container<MatrixType>::import_type import_type;
437 typedef typename Container<MatrixType>::HostView host_view_type;
438 typedef typename Container<MatrixType>::row_matrix_type row_matrix_type;
440 static_assert (std::is_same<MatrixType, row_matrix_type>::value,
441 "Ifpack2::BlockTriDiContainer: MatrixType must be a Tpetra::RowMatrix specialization.");
448 scalar_type DampingFactor)
456 void clearBlocks()
override {}
461 bool zeroStartingSolution =
false,
462 int numSweeps = 1)
const override {}
483 std::ostream&
print (std::ostream& os)
const override {
484 return os <<
"Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
487 std::string description ()
const override {
488 return "Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
495 out <<
"Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
498 static std::string getName() {
499 return "Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
506 #endif // IFPACK2_BLOCKTRIDICONTAINER_DECL_HPP
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:115
Ifpack2::Container class declaration.
void compute() override
Extract the local diagonal block and prepare the solver.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:459
Store and solve local block tridiagonal linear problems.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:134
void weightedApply(host_view_type &X, host_view_type &Y, host_view_type &W, int blockIndex, int stride, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const override
Compute Y := alpha * diag(D) * M^{-1} (diag(D) * X) + beta*Y.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:474
Ifpack2::Partitioner:
Definition: Ifpack2_Partitioner.hpp:179
void initialize() override
Do all set-up operations that only require matrix structure.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:458
#define TEUCHOS_TEST_FOR_EXCEPT_MSG(throw_exception_test, msg)
forward declaration
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:126
std::ostream & print(std::ostream &os) const override
Print basic information about the container to os.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:483
void setParameters(const Teuchos::ParameterList &List) override
Set parameters.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:455
static const EVerbosityLevel verbLevel_default
void apply(host_view_type &X, host_view_type &Y, int blockIndex, int stride, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const override
Compute Y := alpha * M^{-1} X + beta*Y.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:465
Interface for creating and solving a local linear problem.
Definition: Ifpack2_Container.hpp:114
void applyInverseJacobi(const mv_type &X, mv_type &Y, bool zeroStartingSolution=false, int numSweeps=1) const override
Compute Y := (1 - a) Y + a D^{-1} (X - R*Y).
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:460
bool isInitialized() const override
Return true if the container has been successfully initialized.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:453
bool isComputed() const override
Return true if the container has been successfully computed.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:454