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"
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; };
93 template<
typename MatrixType>
struct ImplObject;
99 template <
typename MatrixType,
100 typename ImplTagType =
typename BlockTriDiContainerDetails::ImplTag<typename MatrixType::scalar_type>::type>
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;
149 const Teuchos::Array<Teuchos::Array<local_ordinal_type> > partitions_;
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.");
182 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
183 const Teuchos::RCP<const import_type>& importer,
201 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
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();
240 magnitude_type
tolerance = Kokkos::ArithTraits<magnitude_type>::zero();
256 void setParameters(
const Teuchos::ParameterList& List)
override;
258 void clearBlocks()
override;
272 scalar_type dampingFactor,
273 bool zeroStartingSolution =
false,
274 int numSweeps = 1)
const override;
290 void compute (
const ComputeParameters& input);
316 apply (const_host_view_type X,
319 Teuchos::ETransp mode = Teuchos::NO_TRANS,
320 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
321 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const override;
328 const_host_view_type W,
330 Teuchos::ETransp mode = Teuchos::NO_TRANS,
331 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
332 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const override;
341 std::ostream&
print (std::ostream& os)
const override;
352 describe (Teuchos::FancyOStream &out,
353 const Teuchos::EVerbosityLevel verbLevel =
354 Teuchos::Describable::verbLevel_default)
const override;
366 Teuchos::RCP<BlockTriDiContainerDetails::ImplObject<MatrixType> > impl_;
367 int n_subparts_per_part_;
368 int block_size_ = -1;
371 void initInternal (
const Teuchos::RCP<const row_matrix_type>& matrix,
372 const Teuchos::RCP<const import_type> &importer,
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.");
408 BlockTriDiContainer (
const Teuchos::RCP<const row_matrix_type>& matrix,
409 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
410 const Teuchos::RCP<const import_type>& importer,
413 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Error: BlockTriDiContainer is not available for this scalar_type");
417 void clearBlocks()
override {}
422 scalar_type dampingFactor,
423 bool zeroStartingSolution =
false,
424 int numSweeps = 1)
const override {}
430 Teuchos::ETransp mode = Teuchos::NO_TRANS,
431 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
432 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const override {}
437 const_host_view_type W,
439 Teuchos::ETransp mode = Teuchos::NO_TRANS,
440 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
441 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const override {}
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";
452 describe (Teuchos::FancyOStream &out,
453 const Teuchos::EVerbosityLevel verbLevel =
454 Teuchos::Describable::verbLevel_default)
const override {
455 out <<
"Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
458 static std::string getName() {
459 return "Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
void setParameters(const Teuchos::ParameterList &List) override
Set parameters, if any.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:416
void weightedApply(const_host_view_type X, host_view_type Y, const_host_view_type W, int blockIndex, 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:435
void compute() override
Extract the local diagonal blocks and prepare the solver.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:420
void initialize() override
Do all set-up operations that only require matrix structure.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:419
void apply(const_host_view_type X, host_view_type Y, int blockIndex, 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:427
void applyInverseJacobi(const mv_type &X, mv_type &Y, scalar_type dampingFactor, bool zeroStartingSolution=false, int numSweeps=1) const override
Compute Y := (1 - a) Y + a D^{-1} (X - R*Y).
Definition Ifpack2_BlockTriDiContainer_decl.hpp:421
std::ostream & print(std::ostream &os) const override
Print basic information about the container to os.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:443
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Print the object with some verbosity level to the given FancyOStream.
Definition Ifpack2_BlockTriDiContainer_def.hpp:461
const magnitude_type getNorms0() const
If a norm-based method was used, return a L2 norm of all rhs at the first iteration; otherwise return...
Definition Ifpack2_BlockTriDiContainer_def.hpp:393
ApplyParameters createDefaultApplyParameters() const
Create an ApplyParameters struct with default values.
Definition Ifpack2_BlockTriDiContainer_def.hpp:354
BlockTriDiContainer(const Teuchos::RCP< const row_matrix_type > &matrix, const Teuchos::Array< Teuchos::Array< local_ordinal_type > > &partitions, const Teuchos::RCP< const import_type > &importer, bool pointIndexed)
Constructor.
Definition Ifpack2_BlockTriDiContainer_def.hpp:162
ComputeParameters createDefaultComputeParameters() const
Create a ComputeParameters struct with default values.
Definition Ifpack2_BlockTriDiContainer_def.hpp:326
std::string description() const override
A one-line description of this object.
Definition Ifpack2_BlockTriDiContainer_def.hpp:438
void applyInverseJacobi(const mv_type &X, mv_type &Y, scalar_type dampingFactor, bool zeroStartingSolution=false, int numSweeps=1) const override
Compute Y := (1 - a) Y + a D^{-1} (X - R*Y).
Definition Ifpack2_BlockTriDiContainer_def.hpp:298
void initialize() override
Do all set-up operations that only require matrix structure.
Definition Ifpack2_BlockTriDiContainer_def.hpp:215
void apply(const_host_view_type X, host_view_type Y, int blockIndex, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const override
Definition Ifpack2_BlockTriDiContainer_def.hpp:407
void setParameters(const Teuchos::ParameterList &List) override
Set all necessary parameters.
Definition Ifpack2_BlockTriDiContainer_def.hpp:204
static std::string getName()
Get the name of this container type for Details::constructContainer().
Definition Ifpack2_BlockTriDiContainer_def.hpp:478
void compute() override
Extract the local tridiagonal block and prepare the solver.
Definition Ifpack2_BlockTriDiContainer_def.hpp:265
std::ostream & print(std::ostream &os) const override
Print information about this object to the given output stream.
Definition Ifpack2_BlockTriDiContainer_def.hpp:427
const magnitude_type getNormsFinal() const
If a norm-based method was used, return a L2 norm of all rhs; otherwise return zero.
Definition Ifpack2_BlockTriDiContainer_def.hpp:400
void weightedApply(const_host_view_type X, host_view_type Y, const_host_view_type W, int blockIndex, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const override
Definition Ifpack2_BlockTriDiContainer_def.hpp:418
Store and solve local block tridiagonal linear problems.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:101
Container(const Teuchos::RCP< const row_matrix_type > &matrix, const Teuchos::Array< Teuchos::Array< LO > > &partitions, bool pointIndexed)
Constructor.
Definition Ifpack2_Container_def.hpp:21
typename mv_type::dual_view_type::t_host HostView
Definition Ifpack2_Container_decl.hpp:106
Definition Ifpack2_BlockTriDiContainer_decl.hpp:78
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41
Definition Ifpack2_BlockTriDiContainer_decl.hpp:82
forward declaration
Definition Ifpack2_BlockTriDiContainer_impl.hpp:5069
Input arguments to applyInverseJacobi.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:222
bool zeroStartingSolution
Definition Ifpack2_BlockTriDiContainer_decl.hpp:225
scalar_type dampingFactor
Damping factor. Defaults to 1.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:227
int checkToleranceEvery
Definition Ifpack2_BlockTriDiContainer_decl.hpp:248
magnitude_type tolerance
Definition Ifpack2_BlockTriDiContainer_decl.hpp:240
int maxNumSweeps
Definition Ifpack2_BlockTriDiContainer_decl.hpp:230