// @HEADER // ***************************************************************************** // MueLu: A package for multigrid based preconditioning // // Copyright 2012 NTESS and the MueLu contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef XPETRA_TPETRABLOCKEDMATRIX_HPP #define XPETRA_TPETRABLOCKEDMATRIX_HPP #include #include #include #include #include #include namespace Xpetra { template ::scalar_type, class LocalOrdinal = typename Tpetra::Operator::local_ordinal_type, class GlobalOrdinal = typename Tpetra::Operator::global_ordinal_type, class Node = typename Tpetra::Operator::node_type> class TpetraBlockedMatrix { public: using matrix_type = Xpetra::Matrix; using blocked_map_type = TpetraBlockedMap; using tpetra_blocked_matrix_type = Tpetra::BlockedMatrix; TpetraBlockedMatrix(const Teuchos::RCP& pointA, const Teuchos::RCP& blockA, const Teuchos::RCP& blockMap, const Teuchos::RCP& ghosted_blockMap = Teuchos::null) { using TpCrs = TpetraCrsMatrix; using CrsWrap = CrsMatrixWrap; RCP tp_ghosted_blockMap; if (!ghosted_blockMap.is_null()) tp_ghosted_blockMap = ghosted_blockMap->getTpetra_BlockedMap(); blockMatrix_ = Teuchos::rcp(new tpetra_blocked_matrix_type(Teuchos::rcp_dynamic_cast(Teuchos::rcp_dynamic_cast(pointA)->getCrsMatrix(), true)->getTpetra_CrsMatrixNonConst(), Teuchos::rcp_dynamic_cast(Teuchos::rcp_dynamic_cast(blockA)->getCrsMatrix(), true)->getTpetra_CrsMatrixNonConst(), blockMap->getTpetra_BlockedMap(), tp_ghosted_blockMap)); } void apply(const Xpetra::MultiVector& X, Xpetra::MultiVector& Y, Teuchos::ETransp mode = Teuchos::NO_TRANS, Scalar alpha = Teuchos::ScalarTraits::one(), Scalar beta = Teuchos::ScalarTraits::zero()) const { blockMatrix_->apply(Xpetra::toTpetra(X), Xpetra::toTpetra(Y), mode, alpha, beta); } void localApply(const Xpetra::MultiVector& X, Xpetra::MultiVector& Y, Teuchos::ETransp mode = Teuchos::NO_TRANS, Scalar alpha = Teuchos::ScalarTraits::one(), Scalar beta = Teuchos::ScalarTraits::zero()) const { blockMatrix_->localApply(Xpetra::toTpetra(X), Xpetra::toTpetra(Y), mode, alpha, beta); } Teuchos::RCP getTpetra_BlockedMatrix() const { return blockMatrix_; } private: Teuchos::RCP blockMatrix_; }; } // namespace Xpetra #endif // XPETRA_TPETRABLOCKEDMATRIX_HPP