// @HEADER // ***************************************************************************** // Xpetra: A linear algebra interface package // // Copyright 2012 NTESS and the Xpetra contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef XPETRA_TPETRABLOCKCRSMATRIX_DECL_HPP #define XPETRA_TPETRABLOCKCRSMATRIX_DECL_HPP /* this file is automatically generated - do not edit (see script/tpetra.py) */ #include "Xpetra_TpetraConfigDefs.hpp" #include "Tpetra_BlockCrsMatrix.hpp" #include "Tpetra_CrsMatrix.hpp" #include "Xpetra_CrsMatrix.hpp" #include "Xpetra_TpetraMap_decl.hpp" #include "Xpetra_TpetraMultiVector_decl.hpp" #include "Xpetra_TpetraVector_decl.hpp" #include "Xpetra_TpetraCrsGraph_decl.hpp" #include "Xpetra_Exceptions.hpp" namespace Xpetra { template class TpetraBlockCrsMatrix : public CrsMatrix //, public TpetraRowMatrix { // The following typedef are used by the XPETRA_DYNAMIC_CAST() macro. typedef TpetraBlockCrsMatrix TpetraBlockCrsMatrixClass; typedef TpetraVector TpetraVectorClass; typedef TpetraImport TpetraImportClass; typedef TpetraExport TpetraExportClass; public: //! @name Constructor/Destructor Methods //! Constructor specifying fixed number of entries for each row (not implemented) TpetraBlockCrsMatrix(const Teuchos::RCP > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP ¶ms = Teuchos::null); //! Constructor specifying (possibly different) number of entries in each row (not implemented) TpetraBlockCrsMatrix(const Teuchos::RCP > &rowMap, const ArrayRCP &NumEntriesPerRowToAlloc, const Teuchos::RCP ¶ms = Teuchos::null); //! Constructor specifying column Map and fixed number of entries for each row (not implemented) TpetraBlockCrsMatrix(const Teuchos::RCP > &rowMap, const Teuchos::RCP > &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP ¶ms = Teuchos::null); //! Constructor specifying column Map and number of entries in each row (not implemented) TpetraBlockCrsMatrix(const Teuchos::RCP > &rowMap, const Teuchos::RCP > &colMap, const ArrayRCP &NumEntriesPerRowToAlloc, const Teuchos::RCP ¶ms = Teuchos::null); //! Constructor specifying a previously constructed graph ( not implemented ) TpetraBlockCrsMatrix(const Teuchos::RCP > &graph, const Teuchos::RCP ¶ms = Teuchos::null); //! Constructor specifying a previously constructed graph & blocksize TpetraBlockCrsMatrix(const Teuchos::RCP > &graph, const LocalOrdinal blockSize); //! Constructor specifying a previously constructed graph, point maps & blocksize TpetraBlockCrsMatrix(const Teuchos::RCP > &graph, const Teuchos::RCP > &pointDomainMap, const Teuchos::RCP > &pointRangeMap, const LocalOrdinal blockSize); //! Constructor for a fused import ( not implemented ) TpetraBlockCrsMatrix(const Teuchos::RCP > &sourceMatrix, const Import &importer, const Teuchos::RCP > &domainMap = Teuchos::null, const Teuchos::RCP > &rangeMap = Teuchos::null, const Teuchos::RCP ¶ms = Teuchos::null); //! Constructor for a fused export ( not implemented ) TpetraBlockCrsMatrix(const Teuchos::RCP > &sourceMatrix, const Export &exporter, const Teuchos::RCP > &domainMap = Teuchos::null, const Teuchos::RCP > &rangeMap = Teuchos::null, const Teuchos::RCP ¶ms = Teuchos::null); //! Constructor for a fused import ( not implemented ) TpetraBlockCrsMatrix(const Teuchos::RCP > &sourceMatrix, const Import &RowImporter, const Teuchos::RCP > DomainImporter, const Teuchos::RCP > &domainMap, const Teuchos::RCP > &rangeMap, const Teuchos::RCP ¶ms); //! Constructor for a fused export ( not implemented ) TpetraBlockCrsMatrix(const Teuchos::RCP > &sourceMatrix, const Export &RowExporter, const Teuchos::RCP > DomainExporter, const Teuchos::RCP > &domainMap, const Teuchos::RCP > &rangeMap, const Teuchos::RCP ¶ms); //! Destructor. virtual ~TpetraBlockCrsMatrix(); //! @name Insertion/Removal Methods //! Insert matrix entries, using global IDs (not implemented) void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView &cols, const ArrayView &vals); //! Insert matrix entries, using local IDs (not implemented) void insertLocalValues(LocalOrdinal localRow, const ArrayView &cols, const ArrayView &vals); //! Replace matrix entries, using global IDs (not implemented) void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView &cols, const ArrayView &vals); //! Replace matrix entries, using local IDs. void replaceLocalValues(LocalOrdinal localRow, const ArrayView &cols, const ArrayView &vals); //! Set all matrix entries equal to scalarThis. void setAllToScalar(const Scalar &alpha); //! Scale the current values of a matrix, this = alpha*this (not implemented) void scale(const Scalar &alpha); //! Allocates and returns ArrayRCPs of the Crs arrays --- This is an Xpetra-only routine. //** \warning This is an expert-only routine and should not be called from user code. (not implemented) void allocateAllValues(size_t numNonZeros, ArrayRCP &rowptr, ArrayRCP &colind, ArrayRCP &values); //! Sets the 1D pointer arrays of the graph (not impelmented) void setAllValues(const ArrayRCP &rowptr, const ArrayRCP &colind, const ArrayRCP &values); //! Gets the 1D pointer arrays of the graph (not implemented) void getAllValues(ArrayRCP &rowptr, ArrayRCP &colind, ArrayRCP &values) const; //! Gets the 1D pointer arrays of the graph (not implemented) void getAllValues(ArrayRCP &values); //! @name Transformational Methods //! void resumeFill(const RCP ¶ms = null); //! Signal that data entry is complete, specifying domain and range maps. void fillComplete(const RCP > &domainMap, const RCP > &rangeMap, const RCP ¶ms = null); //! Signal that data entry is complete. void fillComplete(const RCP ¶ms = null); //! Replaces the current domainMap and importer with the user-specified objects. void replaceDomainMapAndImporter(const Teuchos::RCP > &newDomainMap, Teuchos::RCP > &newImporter); //! Expert static fill complete void expertStaticFillComplete(const RCP > &domainMap, const RCP > &rangeMap, const RCP > &importer = Teuchos::null, const RCP > &exporter = Teuchos::null, const RCP ¶ms = Teuchos::null); //! @name Methods implementing RowMatrix //! Returns the Map that describes the row distribution in this matrix. const RCP > getRowMap() const; //! Returns the Map that describes the column distribution in this matrix. const RCP > getColMap() const; //! Returns the CrsGraph associated with this matrix. RCP > getCrsGraph() const; //! Number of global elements in the row map of this matrix. global_size_t getGlobalNumRows() const; //! Number of global columns in the matrix. global_size_t getGlobalNumCols() const; //! Returns the number of matrix rows owned on the calling node. size_t getLocalNumRows() const; //! Returns the number of columns connected to the locally owned rows of this matrix. size_t getLocalNumCols() const; //! Returns the global number of entries in this matrix. global_size_t getGlobalNumEntries() const; //! Returns the local number of entries in this matrix. size_t getLocalNumEntries() const; //! Returns the current number of entries on this node in the specified local row. size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const; //! Returns the current number of entries in the (locally owned) global row. size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const; //! Returns the maximum number of entries across all rows/columns on all nodes. size_t getGlobalMaxNumRowEntries() const; //! Returns the maximum number of entries across all rows/columns on this node. size_t getLocalMaxNumRowEntries() const; //! If matrix indices are in the local range, this function returns true. Otherwise, this function returns false. bool isLocallyIndexed() const; //! If matrix indices are in the global range, this function returns true. Otherwise, this function returns false. bool isGloballyIndexed() const; //! Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called. bool isFillComplete() const; //! Returns true if the matrix is in edit mode. bool isFillActive() const; //! Returns the Frobenius norm of the matrix. typename ScalarTraits::magnitudeType getFrobeniusNorm() const; //! Returns true if getLocalRowView() and getGlobalRowView() are valid for this class. bool supportsRowViews() const; //! Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calling routine. void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView &Indices, const ArrayView &Values, size_t &NumEntries) const; //! Extract a const, non-persisting view of global indices in a specified row of the matrix. void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView &indices, ArrayView &values) const; //! Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage. void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView &indices, const ArrayView &values, size_t &numEntries) const; //! Extract a const, non-persisting view of local indices in a specified row of the matrix. void getLocalRowView(LocalOrdinal LocalRow, ArrayView &indices, ArrayView &values) const; //! Returns true if globalConstants have been computed; false otherwise virtual bool haveGlobalConstants() const; //! @name Methods implementing Operator //! Computes the sparse matrix-multivector multiplication. void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode = Teuchos::NO_TRANS, Scalar alpha = ScalarTraits::one(), Scalar beta = ScalarTraits::zero()) const; //! Computes the matrix-multivector multiplication for region layout matrices (currently no block implementation) void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta, bool sumInterfaceValues, const RCP > ®ionInterfaceImporter, const Teuchos::ArrayRCP ®ionInterfaceLIDs) const; //! Returns the Map associated with the domain of this operator. This will be null until fillComplete() is called. const RCP > getDomainMap() const; //! const RCP > getRangeMap() const; //! @name Overridden from Teuchos::Describable //! A simple one-line description of this object. std::string description() const; //! Print the object with some verbosity level to an FancyOStream object. void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const; //! @name Overridden from Teuchos::LabeledObject void setObjectLabel(const std::string &objectLabel); //! Get a copy of the diagonal entries owned by this node, with local row idices void getLocalDiagCopy(Vector &diag) const; //! Get a copy of the diagonal entries owned by this node, with local row indices. void getLocalDiagCopy(Vector &diag, const Teuchos::ArrayView &offsets) const; //! Get offsets of the diagonal entries in the matrix. void getLocalDiagOffsets(Teuchos::ArrayRCP &offsets) const; //! Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets. void getLocalDiagCopy(Vector &diag, const Kokkos::View &offsets) const; void replaceDiag(const Vector &diag); //! Left scale operator with given vector values void leftScale(const Vector &x); //! Right scale operator with given vector values void rightScale(const Vector &x); //! Implements DistObject interface //! Access function for the Tpetra::Map this DistObject was constructed with. Teuchos::RCP > getMap() const; //! Import. void doImport(const DistObject &source, const Import &importer, CombineMode CM); //! Export. void doExport(const DistObject &dest, const Import &importer, CombineMode CM); //! Import (using an Exporter). void doImport(const DistObject &source, const Export &exporter, CombineMode CM); //! Export (using an Importer). void doExport(const DistObject &dest, const Export &exporter, CombineMode CM); void removeEmptyProcessesInPlace(const Teuchos::RCP > &newMap); //! @name Xpetra specific //! Does this have an underlying matrix bool hasMatrix() const; //! TpetraBlockCrsMatrix constructor to wrap a Tpetra::BlockCrsMatrix object TpetraBlockCrsMatrix(const Teuchos::RCP > &mtx); //! Get the underlying Tpetra matrix RCP > getTpetra_BlockCrsMatrix() const; //! Get the underlying Tpetra matrix RCP > getTpetra_BlockCrsMatrixNonConst() const; #ifdef HAVE_XPETRA_TPETRA // using local_matrix_type = typename Xpetra::CrsMatrix::local_matrix_type; using local_matrix_type = typename CrsMatrix::local_matrix_type; local_matrix_type getLocalMatrixDevice() const; typename local_matrix_type::HostMirror getLocalMatrixHost() const; void setAllValues(const typename local_matrix_type::row_map_type &ptr, const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind, const typename local_matrix_type::values_type &val); #endif // HAVE_XPETRA_TPETRA //! Returns the block size of the storage mechanism LocalOrdinal GetStorageBlockSize() const { return mtx_->getBlockSize(); } //! Compute a residual R = B - (*this) * X void residual(const MultiVector &X, const MultiVector &B, MultiVector &R) const { using STS = Teuchos::ScalarTraits; R.update(STS::one(), B, STS::zero()); this->apply(X, R, Teuchos::NO_TRANS, -STS::one(), STS::one()); } private: RCP > mtx_; }; // TpetraBlockCrsMatrix class } // namespace Xpetra #define XPETRA_TPETRABLOCKCRSMATRIX_SHORT #endif // XPETRA_TPETRABLOCKCRSMATRIX_DECL_HPP