// @HEADER // ***************************************************************************** // Tpetra: Templated Linear Algebra Services Package // // Copyright 2008 NTESS and the Tpetra contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef TPETRA_MMHELPERS_DECL_HPP #define TPETRA_MMHELPERS_DECL_HPP #include #include #include #include #include /// \file TpetraExt_MMHelpers_decl.hpp /// \brief Declaration of Tpetra::MMMultiMultiply and nonmember constructors. /// /// \warning This is an implementation detail of Tpetra. Please don't /// rely on anything in this file. namespace Tpetra { /// \class CrsMatrixStruct /// \brief Struct that holds views of the contents of a CrsMatrix. /// /// These contents may be a mixture of local and remote rows of the /// actual matrix. template class CrsMatrixStruct { public: typedef Map map_type; typedef CrsMatrix crs_matrix_type; CrsMatrixStruct (); virtual ~CrsMatrixStruct (); void deleteContents (); /** \brief Original row map of matrix */ Teuchos::RCP origRowMap; /** \brief Desired row map for "imported" version of the matrix */ Teuchos::RCP rowMap; /** \brief Col map for the original version of the matrix */ Teuchos::RCP colMap; /** \brief Domain map for original matrix */ Teuchos::RCP domainMap; /** \brief Colmap garnered as a result of the import */ Teuchos::RCP importColMap; /** \brief The imported matrix */ Teuchos::RCP > importMatrix; /** \brief The original matrix */ Teuchos::RCP > origMatrix; }; /// \class BlockCrsMatrixStruct /// \brief Struct that holds views of the contents of a BlockCrsMatrix. /// /// These contents may be a mixture of local and remote rows of the /// actual matrix. template class BlockCrsMatrixStruct { public: typedef Map map_type; typedef BlockCrsMatrix block_crs_matrix_type; BlockCrsMatrixStruct (const LocalOrdinal blocksize_); virtual ~BlockCrsMatrixStruct (); void deleteContents (); /** \brief Original row map of matrix */ Teuchos::RCP origRowMap; /** \brief Desired row map for "imported" version of the matrix */ Teuchos::RCP rowMap; /** \brief Col map for the original version of the matrix */ Teuchos::RCP colMap; /** \brief Domain map for original matrix */ Teuchos::RCP domainMap; /** \brief Colmap garnered as a result of the import */ Teuchos::RCP importColMap; /** \brief The imported matrix */ Teuchos::RCP > importMatrix; /** \brief The original matrix */ Teuchos::RCP > origMatrix; /** \brief The blocksize of all matrices */ const LocalOrdinal blocksize; }; template int dumpCrsMatrixStruct (const CrsMatrixStruct& M); template class CrsWrapper { public: typedef Map map_type; virtual ~CrsWrapper () {} virtual Teuchos::RCP getRowMap () const = 0; virtual bool isFillComplete () = 0; virtual void insertGlobalValues (GlobalOrdinal globalRow, const Teuchos::ArrayView &indices, const Teuchos::ArrayView &values) = 0; virtual void sumIntoGlobalValues (GlobalOrdinal globalRow, const Teuchos::ArrayView &indices, const Teuchos::ArrayView &values) = 0; }; template class CrsWrapper_CrsMatrix : public CrsWrapper { public: typedef Map map_type; typedef CrsMatrix crs_matrix_type; CrsWrapper_CrsMatrix (crs_matrix_type& crsmatrix); virtual ~CrsWrapper_CrsMatrix (); Teuchos::RCP getRowMap () const; bool isFillComplete (); void insertGlobalValues (GlobalOrdinal globalRow, const Teuchos::ArrayView &indices, const Teuchos::ArrayView &values); void sumIntoGlobalValues (GlobalOrdinal globalRow, const Teuchos::ArrayView &indices, const Teuchos::ArrayView &values); private: crs_matrix_type& crsmat_; }; template class CrsWrapper_GraphBuilder : public CrsWrapper { public: typedef Map map_type; CrsWrapper_GraphBuilder (const Teuchos::RCP& map); virtual ~CrsWrapper_GraphBuilder (); Teuchos::RCP getRowMap () const { return rowmap_; } bool isFillComplete (); void insertGlobalValues (GlobalOrdinal globalRow, const Teuchos::ArrayView &indices, const Teuchos::ArrayView &values); void sumIntoGlobalValues (GlobalOrdinal globalRow, const Teuchos::ArrayView &indices, const Teuchos::ArrayView &values); std::map*>& get_graph (); size_t get_max_row_length () { return max_row_length_; } private: std::map*> graph_; const Teuchos::RCP& rowmap_; global_size_t max_row_length_; }; template void insert_matrix_locations (CrsWrapper_GraphBuilder& graphbuilder, CrsMatrix& C); } // namespace Tpetra #endif // TPETRA_MMHELPERS_DECL_HPP