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 "Ifpack2_BlockHelper_ETI.hpp"
79template <
typename MatrixType,
80 typename ImplTagType =
typename BlockTriDiContainerDetails::ImplTag<typename MatrixType::scalar_type>::type>
88template <
typename MatrixType>
99 typedef MatrixType matrix_type;
102 typedef typename MatrixType::scalar_type scalar_type;
104 typedef typename KokkosKernels::ArithTraits<scalar_type>::magnitudeType magnitude_type;
106 typedef typename Container<MatrixType>::local_ordinal_type local_ordinal_type;
108 typedef typename Container<MatrixType>::global_ordinal_type global_ordinal_type;
110 typedef typename Container<MatrixType>::node_type node_type;
112 typedef typename Container<MatrixType>::mv_type mv_type;
113 typedef typename Container<MatrixType>::map_type map_type;
114 typedef typename Container<MatrixType>::vector_type vector_type;
115 typedef typename Container<MatrixType>::import_type import_type;
118 typedef typename Container<MatrixType>::ConstHostView const_host_view_type;
119 typedef host_view_type HostView;
120 typedef const_host_view_type ConstHostView;
124 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> crs_matrix_type;
125 typedef Tpetra::BlockCrsMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> block_crs_matrix_type;
127 const Teuchos::Array<Teuchos::Array<local_ordinal_type> > partitions_;
135 typedef typename Container<MatrixType>::row_matrix_type row_matrix_type;
137 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
138 "Ifpack2::BlockTriDiContainer: MatrixType must be a Tpetra::RowMatrix specialization.");
165 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
166 const Teuchos::RCP<const import_type>& importer,
189 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
190 const int n_subparts_per_part = 1,
191 bool overlapCommAndComp =
false,
192 bool useSequentialMethod =
false,
193 const int block_size = -1,
194 const bool explicitConversion =
false);
199 struct ComputeParameters {
206 magnitude_type addRadiallyToDiagonal = KokkosKernels::ArithTraits<magnitude_type>::zero();
228 magnitude_type
tolerance = KokkosKernels::ArithTraits<magnitude_type>::zero();
244 void setParameters(
const Teuchos::ParameterList& List)
override;
246 void clearBlocks()
override;
260 scalar_type dampingFactor,
261 bool zeroStartingSolution =
false,
262 int numSweeps = 1)
const override;
280 void compute(
const ComputeParameters& input);
306 apply(const_host_view_type X,
309 Teuchos::ETransp mode = Teuchos::NO_TRANS,
310 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
311 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const override;
318 const_host_view_type W,
320 Teuchos::ETransp mode = Teuchos::NO_TRANS,
321 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
322 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const override;
331 std::ostream&
print(std::ostream& os)
const override;
342 describe(Teuchos::FancyOStream& out,
343 const Teuchos::EVerbosityLevel verbLevel =
344 Teuchos::Describable::verbLevel_default)
const override;
356 Teuchos::RCP<BlockTriDiContainerDetails::ImplObject<MatrixType> > impl_;
357 int n_subparts_per_part_;
358 int block_size_ = -1;
361 void initInternal(
const Teuchos::RCP<const row_matrix_type>& matrix,
362 const Teuchos::RCP<const import_type>& importer,
363 const bool overlapCommAndComp,
364 const bool useSeqMethod,
365 const int block_size = -1,
366 const bool explicitConversion =
false);
368 void clearInternal();
371 bool shouldUseFusedBlockJacobi(
372 const Teuchos::RCP<const row_matrix_type>& matrix,
373 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
384template <
typename MatrixType>
385class BlockTriDiContainer<MatrixType, BlockTriDiContainerDetails::ImplNotAvailTag>
388 typedef typename MatrixType::scalar_type scalar_type;
389 typedef typename KokkosKernels::ArithTraits<scalar_type>::magnitudeType magnitude_type;
390 typedef typename Container<MatrixType>::local_ordinal_type local_ordinal_type;
391 typedef typename Container<MatrixType>::global_ordinal_type global_ordinal_type;
393 typedef typename Container<MatrixType>::mv_type mv_type;
394 typedef typename Container<MatrixType>::import_type import_type;
397 typedef typename Container<MatrixType>::ConstHostView const_host_view_type;
398 typedef typename Container<MatrixType>::row_matrix_type row_matrix_type;
400 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
401 "Ifpack2::BlockTriDiContainer: MatrixType must be a Tpetra::RowMatrix specialization.");
404 BlockTriDiContainer(
const Teuchos::RCP<const row_matrix_type>& matrix,
405 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
406 const Teuchos::RCP<const import_type>& ,
409 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"Error: BlockTriDiContainer is not available for this scalar_type");
413 void clearBlocks()
override {}
418 scalar_type dampingFactor,
419 bool zeroStartingSolution =
false,
420 int numSweeps = 1)
const override {}
426 Teuchos::ETransp mode = Teuchos::NO_TRANS,
427 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
428 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const override {}
433 const_host_view_type W,
435 Teuchos::ETransp mode = Teuchos::NO_TRANS,
436 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
437 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const override {}
439 std::ostream&
print(std::ostream& os)
const override {
440 return os <<
"Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
443 std::string description()
const override {
444 return "Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
448 describe(Teuchos::FancyOStream& out,
449 const Teuchos::EVerbosityLevel =
450 Teuchos::Describable::verbLevel_default)
const override {
451 out <<
"Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
454 static std::string getName() {
455 return "Ifpack2::BlockTriDiContainer::ImplNotAvailTag";
void setParameters(const Teuchos::ParameterList &List) override
Set parameters, if any.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:412
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:431
void compute() override
Extract the local diagonal blocks and prepare the solver.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:416
void initialize() override
Do all set-up operations that only require matrix structure.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:415
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:423
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:417
std::ostream & print(std::ostream &os) const override
Print basic information about the container to os.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:439
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:454
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:400
ApplyParameters createDefaultApplyParameters() const
Create an ApplyParameters struct with default values.
Definition Ifpack2_BlockTriDiContainer_def.hpp:352
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:149
ComputeParameters createDefaultComputeParameters() const
Create a ComputeParameters struct with default values.
Definition Ifpack2_BlockTriDiContainer_def.hpp:329
std::string description() const override
A one-line description of this object.
Definition Ifpack2_BlockTriDiContainer_def.hpp:435
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:289
void initialize() override
Do all set-up operations that only require matrix structure.
Definition Ifpack2_BlockTriDiContainer_def.hpp:218
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:411
void setParameters(const Teuchos::ParameterList &List) override
Set all necessary parameters.
Definition Ifpack2_BlockTriDiContainer_def.hpp:210
static std::string getName()
Get the name of this container type for Details::constructContainer().
Definition Ifpack2_BlockTriDiContainer_def.hpp:469
void compute() override
Extract the local tridiagonal block and prepare the solver.
Definition Ifpack2_BlockTriDiContainer_def.hpp:262
std::ostream & print(std::ostream &os) const override
Print information about this object to the given output stream.
Definition Ifpack2_BlockTriDiContainer_def.hpp:426
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:406
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:419
Store and solve local block tridiagonal linear problems.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:81
Container(const Teuchos::RCP< const row_matrix_type > &matrix, const Teuchos::Array< Teuchos::Array< LO > > &partitions, bool pointIndexed)
Constructor.
Definition Ifpack2_Container_def.hpp:22
typename mv_type::dual_view_type::t_host HostView
Definition Ifpack2_Container_decl.hpp:105
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40
Input arguments to applyInverseJacobi.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:210
bool zeroStartingSolution
Definition Ifpack2_BlockTriDiContainer_decl.hpp:213
scalar_type dampingFactor
Damping factor. Defaults to 1.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:215
int checkToleranceEvery
Definition Ifpack2_BlockTriDiContainer_decl.hpp:236
magnitude_type tolerance
Definition Ifpack2_BlockTriDiContainer_decl.hpp:228
int maxNumSweeps
Definition Ifpack2_BlockTriDiContainer_decl.hpp:218