10 #ifndef IFPACK2_BLOCKTRIDICONTAINER_DECL_HPP
11 #define IFPACK2_BLOCKTRIDICONTAINER_DECL_HPP
16 #include "Ifpack2_config.h"
17 #include "Ifpack2_Container.hpp"
18 #include "Tpetra_MultiVector.hpp"
19 #include "Tpetra_Map.hpp"
20 #include "Tpetra_RowMatrix.hpp"
21 #include "Tpetra_BlockCrsMatrix_decl.hpp"
22 #include <type_traits>
78 namespace BlockTriDiContainerDetails {
83 struct ImplSimdTag {};
84 struct ImplSacadoTag {};
87 struct ImplTag {
typedef ImplNotAvailTag type; };
89 struct ImplTag<float> {
typedef ImplSimdTag type; };
91 struct ImplTag<double> {
typedef ImplSimdTag type; };
93 struct ImplTag<std::complex<float> > {
typedef ImplSimdTag type; };
95 struct ImplTag<std::complex<double> > {
typedef ImplSimdTag type; };
98 template <
typename MatrixType>
105 template <
typename MatrixType,
114 template <
typename MatrixType>
125 typedef MatrixType matrix_type;
128 typedef typename MatrixType::scalar_type scalar_type;
130 typedef typename Kokkos::ArithTraits<scalar_type>::magnitudeType magnitude_type;
132 typedef typename Container<MatrixType>::local_ordinal_type local_ordinal_type;
134 typedef typename Container<MatrixType>::global_ordinal_type global_ordinal_type;
136 typedef typename Container<MatrixType>::node_type node_type;
138 typedef typename Container<MatrixType>::mv_type mv_type;
139 typedef typename Container<MatrixType>::map_type map_type;
140 typedef typename Container<MatrixType>::vector_type vector_type;
141 typedef typename Container<MatrixType>::import_type import_type;
144 typedef typename Container<MatrixType>::ConstHostView const_host_view_type;
145 typedef host_view_type HostView;
146 typedef const_host_view_type ConstHostView;
150 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> crs_matrix_type;
151 typedef Tpetra::BlockCrsMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> block_crs_matrix_type;
161 typedef typename Container<MatrixType>::row_matrix_type row_matrix_type;
163 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
164 "Ifpack2::BlockTriDiContainer: MatrixType must be a Tpetra::RowMatrix specialization.");
206 const int n_subparts_per_part = 1,
207 bool overlapCommAndComp =
false,
208 bool useSequentialMethod =
false,
209 const int block_size = -1,
210 const bool explicitConversion =
false);
215 struct ComputeParameters {
222 magnitude_type addRadiallyToDiagonal = Kokkos::ArithTraits<magnitude_type>::zero();
226 struct ApplyParameters {
229 bool zeroStartingSolution =
false;
231 scalar_type dampingFactor = Kokkos::ArithTraits<scalar_type>::one();
234 int maxNumSweeps = 1;
244 magnitude_type tolerance = Kokkos::ArithTraits<magnitude_type>::zero();
252 int checkToleranceEvery = 1;
262 void clearBlocks()
override;
269 void initialize()
override;
272 void compute()
override;
275 void applyInverseJacobi(
const mv_type& X, mv_type& Y,
276 scalar_type dampingFactor,
277 bool zeroStartingSolution =
false,
278 int numSweeps = 1)
const override;
281 ComputeParameters createDefaultComputeParameters()
const;
294 void compute(
const ComputeParameters& input);
297 ApplyParameters createDefaultApplyParameters()
const;
305 int applyInverseJacobi(
const mv_type& X, mv_type& Y,
306 const ApplyParameters& input)
const;
311 const magnitude_type getNorms0()
const;
315 const magnitude_type getNormsFinal()
const;
320 apply(const_host_view_type X,
330 weightedApply(const_host_view_type X,
332 const_host_view_type W,
345 std::ostream& print(std::ostream& os)
const override;
352 std::string description()
const override;
363 static std::string getName();
371 int n_subparts_per_part_;
372 int block_size_ = -1;
377 const bool overlapCommAndComp,
378 const bool useSeqMethod,
379 const int block_size = -1,
380 const bool explicitConversion =
false);
382 void clearInternal();
385 bool shouldUseFusedBlockJacobi(
398 template <
typename MatrixType>
402 typedef typename MatrixType::scalar_type scalar_type;
403 typedef typename Kokkos::ArithTraits<scalar_type>::magnitudeType magnitude_type;
404 typedef typename Container<MatrixType>::local_ordinal_type local_ordinal_type;
405 typedef typename Container<MatrixType>::global_ordinal_type global_ordinal_type;
407 typedef typename Container<MatrixType>::mv_type mv_type;
408 typedef typename Container<MatrixType>::import_type import_type;
411 typedef typename Container<MatrixType>::ConstHostView const_host_view_type;
412 typedef typename Container<MatrixType>::row_matrix_type row_matrix_type;
414 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
415 "Ifpack2::BlockTriDiContainer: MatrixType must be a Tpetra::RowMatrix specialization.");
427 void clearBlocks()
override {}
431 void applyInverseJacobi(
const mv_type& X, mv_type& Y,
432 scalar_type dampingFactor,
433 bool zeroStartingSolution =
false,
434 int numSweeps = 1)
const override {}
437 apply(const_host_view_type X,
445 weightedApply(const_host_view_type X,
447 const_host_view_type W,
453 std::ostream&
print(std::ostream& os)
const override {
454 return os <<
"Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
457 std::string description()
const override {
458 return "Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
465 out <<
"Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
468 static std::string getName() {
469 return "Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
475 #endif // IFPACK2_BLOCKTRIDICONTAINER_DECL_HPP
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:82
void compute() override
Extract the local diagonal blocks and prepare the solver.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:430
Store and solve local block tridiagonal linear problems.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:107
void initialize() override
Do all set-up operations that only require matrix structure.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:429
#define TEUCHOS_TEST_FOR_EXCEPT_MSG(throw_exception_test, msg)
forward declaration
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:99
typename mv_type::dual_view_type::t_host HostView
Definition: Ifpack2_Container_decl.hpp:105
std::ostream & print(std::ostream &os) const override
Print basic information about the container to os.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:453
void setParameters(const Teuchos::ParameterList &List) override
Set parameters, if any.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:426
static const EVerbosityLevel verbLevel_default
Interface for creating and solving a set of local linear problems.
Definition: Ifpack2_Container_decl.hpp:79