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 {};
86 template<
typename T>
struct ImplTag {
typedef ImplNotAvailTag type; };
87 template<>
struct ImplTag<float> {
typedef ImplSimdTag type; };
88 template<>
struct ImplTag<double> {
typedef ImplSimdTag type; };
89 template<>
struct ImplTag<std::complex<float> > {
typedef ImplSimdTag type; };
90 template<>
struct ImplTag<std::complex<double> > {
typedef ImplSimdTag type; };
99 template <
typename MatrixType,
108 template <
typename MatrixType>
119 typedef MatrixType matrix_type;
122 typedef typename MatrixType::scalar_type scalar_type;
124 typedef typename Kokkos::ArithTraits<scalar_type>::magnitudeType magnitude_type;
126 typedef typename Container<MatrixType>::local_ordinal_type local_ordinal_type;
128 typedef typename Container<MatrixType>::global_ordinal_type global_ordinal_type;
130 typedef typename Container<MatrixType>::node_type node_type;
132 typedef typename Container<MatrixType>::mv_type mv_type;
133 typedef typename Container<MatrixType>::map_type map_type;
134 typedef typename Container<MatrixType>::vector_type vector_type;
135 typedef typename Container<MatrixType>::import_type import_type;
138 typedef typename Container<MatrixType>::ConstHostView const_host_view_type;
139 typedef host_view_type HostView;
140 typedef const_host_view_type ConstHostView;
144 typedef Tpetra::CrsMatrix
145 <scalar_type,local_ordinal_type,global_ordinal_type,node_type> crs_matrix_type;
146 typedef Tpetra::BlockCrsMatrix
147 <scalar_type,local_ordinal_type,global_ordinal_type,node_type> block_crs_matrix_type;
157 typedef typename Container<MatrixType>::row_matrix_type row_matrix_type;
159 static_assert (std::is_same<MatrixType, row_matrix_type>::value,
160 "Ifpack2::BlockTriDiContainer: MatrixType must be a Tpetra::RowMatrix specialization.");
202 const int n_subparts_per_part = 1,
203 bool overlapCommAndComp =
false,
204 bool useSequentialMethod =
false,
205 const int block_size = -1,
206 const bool explicitConversion =
false);
211 struct ComputeParameters {
218 magnitude_type addRadiallyToDiagonal = Kokkos::ArithTraits<magnitude_type>::zero();
222 struct ApplyParameters {
225 bool zeroStartingSolution =
false;
227 scalar_type dampingFactor = Kokkos::ArithTraits<scalar_type>::one();
230 int maxNumSweeps = 1;
240 magnitude_type tolerance = Kokkos::ArithTraits<magnitude_type>::zero();
248 int checkToleranceEvery = 1;
258 void clearBlocks()
override;
265 void initialize ()
override;
268 void compute ()
override;
271 void applyInverseJacobi (
const mv_type& X, mv_type& Y,
272 scalar_type dampingFactor,
273 bool zeroStartingSolution =
false,
274 int numSweeps = 1)
const override;
277 ComputeParameters createDefaultComputeParameters ()
const;
290 void compute (
const ComputeParameters& input);
293 ApplyParameters createDefaultApplyParameters ()
const;
301 int applyInverseJacobi (
const mv_type& X, mv_type& Y,
302 const ApplyParameters& input)
const;
307 const magnitude_type getNorms0 ()
const;
311 const magnitude_type getNormsFinal ()
const;
316 apply (const_host_view_type X,
326 weightedApply (const_host_view_type X,
328 const_host_view_type W,
341 std::ostream& print (std::ostream& os)
const override;
348 std::string description ()
const override;
359 static std::string getName();
367 int n_subparts_per_part_;
368 int block_size_ = -1;
373 const bool overlapCommAndComp,
374 const bool useSeqMethod,
375 const int block_size = -1,
376 const bool explicitConversion =
false);
378 void clearInternal();
388 template <
typename MatrixType>
392 typedef typename MatrixType::scalar_type scalar_type;
393 typedef typename Kokkos::ArithTraits<scalar_type>::magnitudeType magnitude_type;
394 typedef typename Container<MatrixType>::local_ordinal_type local_ordinal_type;
395 typedef typename Container<MatrixType>::global_ordinal_type global_ordinal_type;
397 typedef typename Container<MatrixType>::mv_type mv_type;
398 typedef typename Container<MatrixType>::import_type import_type;
401 typedef typename Container<MatrixType>::ConstHostView const_host_view_type;
402 typedef typename Container<MatrixType>::row_matrix_type row_matrix_type;
404 static_assert (std::is_same<MatrixType, row_matrix_type>::value,
405 "Ifpack2::BlockTriDiContainer: MatrixType must be a Tpetra::RowMatrix specialization.");
417 void clearBlocks()
override {}
421 void applyInverseJacobi (
const mv_type& X, mv_type& Y,
422 scalar_type dampingFactor,
423 bool zeroStartingSolution =
false,
424 int numSweeps = 1)
const override {}
427 apply (const_host_view_type X,
435 weightedApply (const_host_view_type X,
437 const_host_view_type W,
443 std::ostream&
print (std::ostream& os)
const override {
444 return os <<
"Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
447 std::string description ()
const override {
448 return "Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
455 out <<
"Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
458 static std::string getName() {
459 return "Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
466 #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:420
Store and solve local block tridiagonal linear problems.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:101
void initialize() override
Do all set-up operations that only require matrix structure.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:419
#define TEUCHOS_TEST_FOR_EXCEPT_MSG(throw_exception_test, msg)
forward declaration
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:93
typename mv_type::dual_view_type::t_host HostView
Definition: Ifpack2_Container_decl.hpp:106
std::ostream & print(std::ostream &os) const override
Print basic information about the container to os.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:443
void setParameters(const Teuchos::ParameterList &List) override
Set parameters, if any.
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:416
static const EVerbosityLevel verbLevel_default
Interface for creating and solving a set of local linear problems.
Definition: Ifpack2_Container_decl.hpp:79