43 #ifndef IFPACK2_BLOCKTRIDICONTAINER_DEF_HPP 
   44 #define IFPACK2_BLOCKTRIDICONTAINER_DEF_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_Gemv_Serial_Impl.hpp> 
   60 #include <KokkosBatched_Trsm_Decl.hpp> 
   61 #include <KokkosBatched_Trsm_Serial_Impl.hpp> 
   62 #include <KokkosBatched_Trsv_Decl.hpp> 
   63 #include <KokkosBatched_Trsv_Serial_Impl.hpp> 
   64 #include <KokkosBatched_LU_Decl.hpp> 
   65 #include <KokkosBatched_LU_Serial_Impl.hpp> 
   68 #include "Ifpack2_BlockTriDiContainer_impl.hpp" 
   79   template <
typename MatrixType>
 
   81   BlockTriDiContainer<MatrixType, BlockTriDiContainerDetails::ImplSimdTag>
 
   85                   const bool overlapCommAndComp,
 
   86                   const bool useSeqMethod) 
 
   89     impl_ = 
Teuchos::rcp(
new BlockTriDiContainerDetails::ImplObject<MatrixType>());
 
   91     using impl_type = BlockTriDiContainerDetails::ImplType<MatrixType>;
 
   92     using block_crs_matrix_type = 
typename impl_type::tpetra_block_crs_matrix_type;
 
   94     impl_->A = Teuchos::rcp_dynamic_cast<
const block_crs_matrix_type>(matrix);
 
   96       (impl_->A.is_null(), 
"BlockTriDiContainer currently supports Tpetra::BlockCrsMatrix only.");
 
   98     impl_->tpetra_importer = Teuchos::null;
 
   99     impl_->async_importer  = Teuchos::null;
 
  103         impl_->tpetra_importer = BlockTriDiContainerDetails::createBlockCrsTpetraImporter<MatrixType>(impl_->A);
 
  105         impl_->async_importer = BlockTriDiContainerDetails::createBlockCrsAsyncImporter<MatrixType>(impl_->A);
 
  107       impl_->tpetra_importer = importer; 
 
  115     impl_->overlap_communication_and_computation = overlapCommAndComp;
 
  117     impl_->Z = 
typename impl_type::tpetra_multivector_type();
 
  118     impl_->W = 
typename impl_type::impl_scalar_type_1d_view();
 
  120     impl_->part_interface  = BlockTriDiContainerDetails::createPartInterface<MatrixType>(impl_->A, partitions);
 
  121     impl_->block_tridiags  = BlockTriDiContainerDetails::createBlockTridiags<MatrixType>(impl_->part_interface);
 
  122     impl_->norm_manager    = BlockTriDiContainerDetails::NormManager<MatrixType>(impl_->A->getComm());
 
  125   template <
typename MatrixType>
 
  127   BlockTriDiContainer<MatrixType, BlockTriDiContainerDetails::ImplSimdTag>
 
  130     using impl_type = BlockTriDiContainerDetails::ImplType<MatrixType>;
 
  131     using part_interface_type = BlockTriDiContainerDetails::PartInterface<MatrixType>;
 
  132     using block_tridiags_type = BlockTriDiContainerDetails::BlockTridiags<MatrixType>;
 
  133     using amd_type = BlockTriDiContainerDetails::AmD<MatrixType>;
 
  134     using norm_manager_type = BlockTriDiContainerDetails::NormManager<MatrixType>;
 
  136     impl_->A = Teuchos::null;
 
  137     impl_->tpetra_importer = Teuchos::null;
 
  138     impl_->async_importer  = Teuchos::null;
 
  140     impl_->Z = 
typename impl_type::tpetra_multivector_type();
 
  141     impl_->W = 
typename impl_type::impl_scalar_type_1d_view();
 
  143     impl_->part_interface  = part_interface_type();
 
  144     impl_->block_tridiags  = block_tridiags_type();
 
  145     impl_->a_minus_d       = amd_type();
 
  146     impl_->work            = 
typename impl_type::vector_type_1d_view();
 
  147     impl_->norm_manager    = norm_manager_type();
 
  149     impl_ = Teuchos::null;
 
  152   template <
typename MatrixType>
 
  158     : 
Container<MatrixType>(matrix, partitions, pointIndexed)
 
  160     const bool useSeqMethod = 
false;
 
  161     const bool overlapCommAndComp = 
false;
 
  162     initInternal(matrix, partitions, importer, overlapCommAndComp, useSeqMethod);
 
  165   template <
typename MatrixType>
 
  169                        const bool overlapCommAndComp, 
const bool useSeqMethod)
 
  170     : 
Container<MatrixType>(matrix, partitions, false)
 
  172     initInternal(matrix, partitions, Teuchos::null, overlapCommAndComp, useSeqMethod);
 
  175   template <
typename MatrixType>
 
  181   template <
typename MatrixType>
 
  189   template <
typename MatrixType>
 
  194     this->IsInitialized_ = 
true;
 
  197     this->IsComputed_ = 
false;
 
  200       BlockTriDiContainerDetails::performSymbolicPhase<MatrixType>
 
  202          impl_->part_interface, impl_->block_tridiags, 
 
  204          impl_->overlap_communication_and_computation);    
 
  208   template <
typename MatrixType>
 
  213     this->IsComputed_ = 
false;
 
  214     if (!this->isInitialized())
 
  217       BlockTriDiContainerDetails::performNumericPhase<MatrixType>
 
  219          impl_->part_interface, impl_->block_tridiags, 
 
  220          Kokkos::ArithTraits<magnitude_type>::zero());
 
  222     this->IsComputed_ = 
true;
 
  225   template <
typename MatrixType>
 
  231     this->IsInitialized_ = 
false;
 
  232     this->IsComputed_ = 
false;
 
  236   template <
typename MatrixType>
 
  238   BlockTriDiContainer<MatrixType, BlockTriDiContainerDetails::ImplSimdTag>
 
  239   ::applyInverseJacobi (
const mv_type& X, mv_type& Y, scalar_type dampingFactor,
 
  240                         bool zeroStartingSolution, 
int numSweeps)
 const 
  242     const magnitude_type tol = Kokkos::ArithTraits<magnitude_type>::zero();
 
  243     const int check_tol_every = 1;
 
  245     BlockTriDiContainerDetails::applyInverseJacobi<MatrixType>
 
  247        impl_->tpetra_importer, 
 
  248        impl_->async_importer, 
 
  249        impl_->overlap_communication_and_computation,
 
  250        X, Y, impl_->Z, impl_->W,
 
  251        impl_->part_interface, impl_->block_tridiags, impl_->a_minus_d,
 
  255        zeroStartingSolution,
 
  261   template <
typename MatrixType>
 
  262   typename BlockTriDiContainer<MatrixType, BlockTriDiContainerDetails::ImplSimdTag>::ComputeParameters
 
  266     return ComputeParameters();
 
  269   template <
typename MatrixType>
 
  274     this->IsComputed_ = 
false;
 
  275     if (!this->isInitialized())
 
  278       BlockTriDiContainerDetails::performNumericPhase<MatrixType>
 
  280          impl_->part_interface, impl_->block_tridiags, 
 
  281          in.addRadiallyToDiagonal);
 
  283     this->IsComputed_ = 
true;
 
  286   template <
typename MatrixType>
 
  296   template <
typename MatrixType>
 
  300                         const ApplyParameters& in)
 const 
  304       r_val = BlockTriDiContainerDetails::applyInverseJacobi<MatrixType>
 
  306          impl_->tpetra_importer, 
 
  307          impl_->async_importer,
 
  308          impl_->overlap_communication_and_computation,
 
  309          X, Y, impl_->Z, impl_->W,
 
  310          impl_->part_interface, impl_->block_tridiags, impl_->a_minus_d,
 
  314          in.zeroStartingSolution,
 
  317          in.checkToleranceEvery);
 
  322   template <
typename MatrixType>
 
  326     return impl_->norm_manager.getNorms0();
 
  329   template <
typename MatrixType>
 
  333     return impl_->norm_manager.getNormsFinal();
 
  336   template <
typename MatrixType>
 
  340            scalar_type , scalar_type )
 const 
  343                                 << 
"because you want to use this container's performance-portable Jacobi iteration. In " 
  344                                 << 
"that case, set \"relaxation: type\" to \"MT Split Jacobi\" rather than \"Jacobi\".");
 
  347   template <
typename MatrixType>
 
  356   template <
typename MatrixType>
 
  367   template <
typename MatrixType>
 
  372     std::ostringstream oss;
 
  374     if (this->isInitialized()) {
 
  375       if (this->isComputed()) {
 
  376         oss << 
"{status = initialized, computed";
 
  379         oss << 
"{status = initialized, not computed";
 
  383       oss << 
"{status = not initialized, not computed";
 
  390   template <
typename MatrixType>
 
  398     os << 
"================================================================================" << endl
 
  399        << 
"Ifpack2::BlockTriDiContainer" << endl
 
  400        << 
"Number of blocks        = " << this->numBlocks_ << endl
 
  401        << 
"isInitialized()         = " << this->IsInitialized_ << endl
 
  402        << 
"isComputed()            = " << this->IsComputed_ << endl
 
  403        << 
"================================================================================" << endl
 
  407   template <
typename MatrixType>
 
  410   ::getName() { 
return "Ifpack2::BlockTriDiContainer::ImplSimdTag"; }
 
  412 #define IFPACK2_BLOCKTRIDICONTAINER_INSTANT(S,LO,GO,N)                  \ 
  413   template class Ifpack2::BlockTriDiContainer< Tpetra::RowMatrix<S, LO, GO, N> >; 
Ifpack2::BlockTriDiContainer class declaration. 
 
Store and solve local block tridiagonal linear problems. 
Definition: Ifpack2_BlockTriDiContainer_decl.hpp:134
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
 
#define TEUCHOS_TEST_FOR_EXCEPT_MSG(throw_exception_test, msg)
 
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:154
 
virtual std::string description() const 
 
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
 
Interface for creating and solving a set of local linear problems. 
Definition: Ifpack2_Container_decl.hpp:112
 
ComputeParameters createDefaultComputeParameters() const 
Create a ComputeParameters struct with default values. 
Definition: Ifpack2_BlockTriDiContainer_def.hpp:264
 
#define TEUCHOS_ASSERT(assertion_test)