43#ifndef IFPACK2_BLOCKTRIDICONTAINER_DEF_HPP
44#define IFPACK2_BLOCKTRIDICONTAINER_DEF_HPP
46#include <Teuchos_Details_MpiTypeTraits.hpp>
48#include <Tpetra_Distributor.hpp>
49#include <Tpetra_BlockMultiVector.hpp>
51#include <Kokkos_ArithTraits.hpp>
52#include <KokkosBatched_Util.hpp>
53#include <KokkosBatched_Vector.hpp>
54#include <KokkosBatched_AddRadial_Decl.hpp>
55#include <KokkosBatched_AddRadial_Impl.hpp>
56#include <KokkosBatched_Gemm_Decl.hpp>
57#include <KokkosBatched_Gemm_Serial_Impl.hpp>
58#include <KokkosBatched_Gemv_Decl.hpp>
59#include <KokkosBatched_Trsm_Decl.hpp>
60#include <KokkosBatched_Trsm_Serial_Impl.hpp>
61#include <KokkosBatched_Trsv_Decl.hpp>
62#include <KokkosBatched_Trsv_Serial_Impl.hpp>
63#include <KokkosBatched_LU_Decl.hpp>
64#include <KokkosBatched_LU_Serial_Impl.hpp>
67#include "Ifpack2_BlockTriDiContainer_impl.hpp"
78 template <
typename MatrixType>
82 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
83 const Teuchos::RCP<const import_type>& importer,
84 const bool overlapCommAndComp,
85 const bool useSeqMethod)
93 impl_->A = Teuchos::rcp_dynamic_cast<const block_crs_matrix_type>(matrix);
94 TEUCHOS_TEST_FOR_EXCEPT_MSG
95 (impl_->A.is_null(),
"BlockTriDiContainer currently supports Tpetra::BlockCrsMatrix only.");
97 impl_->tpetra_importer = Teuchos::null;
98 impl_->async_importer = Teuchos::null;
102 if (importer.is_null())
105 impl_->tpetra_importer = importer;
120 impl_->overlap_communication_and_computation = overlapCommAndComp;
122 impl_->Z =
typename impl_type::tpetra_multivector_type();
123 impl_->W =
typename impl_type::impl_scalar_type_1d_view();
130 template <
typename MatrixType>
136 using part_interface_type = BlockTriDiContainerDetails::PartInterface<MatrixType>;
141 impl_->A = Teuchos::null;
142 impl_->tpetra_importer = Teuchos::null;
143 impl_->async_importer = Teuchos::null;
145 impl_->Z =
typename impl_type::tpetra_multivector_type();
146 impl_->W =
typename impl_type::impl_scalar_type_1d_view();
148 impl_->part_interface = part_interface_type();
149 impl_->block_tridiags = block_tridiags_type();
150 impl_->a_minus_d = amd_type();
151 impl_->work =
typename impl_type::vector_type_1d_view();
152 impl_->norm_manager = norm_manager_type();
154 impl_ = Teuchos::null;
157 template <
typename MatrixType>
160 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
161 const Teuchos::RCP<const import_type>& importer,
163 :
Container<MatrixType>(matrix, partitions, pointIndexed)
165 const bool useSeqMethod =
false;
166 const bool overlapCommAndComp =
false;
167 initInternal(matrix, partitions, importer, overlapCommAndComp, useSeqMethod);
170 template <
typename MatrixType>
173 const Teuchos::Array<Teuchos::Array<local_ordinal_type> >& partitions,
174 const bool overlapCommAndComp,
const bool useSeqMethod)
175 :
Container<MatrixType>(matrix, partitions, false)
177 initInternal(matrix, partitions, Teuchos::null, overlapCommAndComp, useSeqMethod);
180 template <
typename MatrixType>
186 template <
typename MatrixType>
194 template <
typename MatrixType>
203 TEUCHOS_ASSERT(!impl_->A.is_null());
207 impl_->part_interface, impl_->block_tridiags,
209 impl_->overlap_communication_and_computation);
213 template <
typename MatrixType>
224 impl_->part_interface, impl_->block_tridiags,
225 Kokkos::ArithTraits<magnitude_type>::zero());
230 template <
typename MatrixType>
236 this->IsInitialized_ =
false;
237 this->IsComputed_ =
false;
238 Container<MatrixType>::clearBlocks();
241 template <
typename MatrixType>
243 BlockTriDiContainer<MatrixType, BlockTriDiContainerDetails::ImplSimdTag>
244 ::applyInverseJacobi (
const mv_type& X, mv_type& Y, scalar_type dampingFactor,
245 bool zeroStartingSolution,
int numSweeps)
const
247 const magnitude_type tol = Kokkos::ArithTraits<magnitude_type>::zero();
248 const int check_tol_every = 1;
252 impl_->tpetra_importer,
253 impl_->async_importer,
254 impl_->overlap_communication_and_computation,
255 X, Y, impl_->Z, impl_->W,
256 impl_->part_interface, impl_->block_tridiags, impl_->a_minus_d,
260 zeroStartingSolution,
266 template <
typename MatrixType>
271 return ComputeParameters();
274 template <
typename MatrixType>
285 impl_->part_interface, impl_->block_tridiags,
286 in.addRadiallyToDiagonal);
291 template <
typename MatrixType>
297 in.
dampingFactor = Teuchos::ScalarTraits<scalar_type>::one();
301 template <
typename MatrixType>
311 impl_->tpetra_importer,
312 impl_->async_importer,
313 impl_->overlap_communication_and_computation,
314 X, Y, impl_->Z, impl_->W,
315 impl_->part_interface, impl_->block_tridiags, impl_->a_minus_d,
327 template <
typename MatrixType>
331 return impl_->norm_manager.getNorms0();
334 template <
typename MatrixType>
338 return impl_->norm_manager.getNormsFinal();
341 template <
typename MatrixType>
344 ::apply (ConstHostView , HostView ,
int , Teuchos::ETransp ,
345 scalar_type , scalar_type )
const
347 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"BlockTriDiContainer::apply is not implemented. You may have reached this message "
348 <<
"because you want to use this container's performance-portable Jacobi iteration. In "
349 <<
"that case, set \"relaxation: type\" to \"MT Split Jacobi\" rather than \"Jacobi\".");
352 template <
typename MatrixType>
356 Teuchos::ETransp , scalar_type , scalar_type )
const
358 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"BlockTriDiContainer::weightedApply is not implemented.");
361 template <
typename MatrixType>
366 Teuchos::FancyOStream fos(Teuchos::rcp(&os,
false));
367 fos.setOutputToRootOnly(0);
372 template <
typename MatrixType>
377 std::ostringstream oss;
378 oss << Teuchos::Describable::description();
381 oss <<
"{status = initialized, computed";
384 oss <<
"{status = initialized, not computed";
388 oss <<
"{status = not initialized, not computed";
395 template <
typename MatrixType>
398 describe (Teuchos::FancyOStream& os,
399 const Teuchos::EVerbosityLevel verbLevel)
const
402 if(verbLevel==Teuchos::VERB_NONE)
return;
403 os <<
"================================================================================" << endl
404 <<
"Ifpack2::BlockTriDiContainer" << endl
405 <<
"Number of blocks = " << this->
numBlocks_ << endl
408 <<
"================================================================================" << endl
412 template <
typename MatrixType>
415 ::getName() {
return "Ifpack2::BlockTriDiContainer::ImplSimdTag"; }
417#define IFPACK2_BLOCKTRIDICONTAINER_INSTANT(S,LO,GO,N) \
418 template class Ifpack2::BlockTriDiContainer< Tpetra::RowMatrix<S, LO, GO, N> >;
Ifpack2::BlockTriDiContainer class declaration.
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:398
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:159
void initialize() override
Do all set-up operations that only require matrix structure.
Definition Ifpack2_BlockTriDiContainer_def.hpp:197
Store and solve local block tridiagonal linear problems.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:134
int numBlocks_
The number of blocks (partitions) in the container.
Definition Ifpack2_Container_decl.hpp:292
bool isInitialized() const
Whether the container has been successfully initialized.
Definition Ifpack2_Container_def.hpp:165
Container(const Teuchos::RCP< const row_matrix_type > &matrix, const Teuchos::Array< Teuchos::Array< LO > > &partitions, bool pointIndexed)
Constructor.
Definition Ifpack2_Container_def.hpp:54
bool IsInitialized_
If true, the container has been successfully initialized.
Definition Ifpack2_Container_decl.hpp:320
bool isComputed() const
Whether the container has been successfully computed.
Definition Ifpack2_Container_def.hpp:170
bool IsComputed_
If true, the container has been successfully computed.
Definition Ifpack2_Container_decl.hpp:322
Teuchos::RCP< const typename ImplType< MatrixType >::tpetra_import_type > createBlockCrsTpetraImporter(const Teuchos::RCP< const typename ImplType< MatrixType >::tpetra_block_crs_matrix_type > &A)
Definition Ifpack2_BlockTriDiContainer_impl.hpp:447
BlockTridiags< MatrixType > createBlockTridiags(const PartInterface< MatrixType > &interf)
Definition Ifpack2_BlockTriDiContainer_impl.hpp:1365
Teuchos::RCP< AsyncableImport< MatrixType > > createBlockCrsAsyncImporter(const Teuchos::RCP< const typename ImplType< MatrixType >::tpetra_block_crs_matrix_type > &A)
Definition Ifpack2_BlockTriDiContainer_impl.hpp:1040
void performNumericPhase(const Teuchos::RCP< const typename ImplType< MatrixType >::tpetra_block_crs_matrix_type > &A, const PartInterface< MatrixType > &interf, BlockTridiags< MatrixType > &btdm, const typename ImplType< MatrixType >::magnitude_type tiny)
Definition Ifpack2_BlockTriDiContainer_impl.hpp:2303
PartInterface< MatrixType > createPartInterface(const Teuchos::RCP< const typename ImplType< MatrixType >::tpetra_block_crs_matrix_type > &A, const Teuchos::Array< Teuchos::Array< typename ImplType< MatrixType >::local_ordinal_type > > &partitions)
Definition Ifpack2_BlockTriDiContainer_impl.hpp:1154
int applyInverseJacobi(const Teuchos::RCP< const typename ImplType< MatrixType >::tpetra_block_crs_matrix_type > &A, const Teuchos::RCP< const typename ImplType< MatrixType >::tpetra_import_type > &tpetra_importer, const Teuchos::RCP< AsyncableImport< MatrixType > > &async_importer, const bool overlap_communication_and_computation, const typename ImplType< MatrixType >::tpetra_multivector_type &X, typename ImplType< MatrixType >::tpetra_multivector_type &Y, typename ImplType< MatrixType >::tpetra_multivector_type &Z, typename ImplType< MatrixType >::impl_scalar_type_1d_view &W, const PartInterface< MatrixType > &interf, const BlockTridiags< MatrixType > &btdm, const AmD< MatrixType > &amd, typename ImplType< MatrixType >::vector_type_1d_view &work, NormManager< MatrixType > &norm_manager, const typename ImplType< MatrixType >::impl_scalar_type &damping_factor, bool is_y_zero, const int max_num_sweeps, const typename ImplType< MatrixType >::magnitude_type tol, const int check_tol_every)
Definition Ifpack2_BlockTriDiContainer_impl.hpp:3975
void performSymbolicPhase(const Teuchos::RCP< const typename ImplType< MatrixType >::tpetra_block_crs_matrix_type > &A, const PartInterface< MatrixType > &interf, BlockTridiags< MatrixType > &btdm, AmD< MatrixType > &amd, const bool overlap_communication_and_computation)
Definition Ifpack2_BlockTriDiContainer_impl.hpp:1564
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:74
Definition Ifpack2_BlockTriDiContainer_impl.hpp:1534
Definition Ifpack2_BlockTriDiContainer_impl.hpp:1321
forward declaration
Definition Ifpack2_BlockTriDiContainer_impl.hpp:4154
Definition Ifpack2_BlockTriDiContainer_impl.hpp:354
Definition Ifpack2_BlockTriDiContainer_impl.hpp:3848
Input arguments to applyInverseJacobi.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:247
bool zeroStartingSolution
Definition Ifpack2_BlockTriDiContainer_decl.hpp:250
scalar_type dampingFactor
Damping factor. Defaults to 1.
Definition Ifpack2_BlockTriDiContainer_decl.hpp:252
int checkToleranceEvery
Definition Ifpack2_BlockTriDiContainer_decl.hpp:273
magnitude_type tolerance
Definition Ifpack2_BlockTriDiContainer_decl.hpp:265
int maxNumSweeps
Definition Ifpack2_BlockTriDiContainer_decl.hpp:255