diff --git a/packages/xpetra/src/CMakeLists.txt b/packages/xpetra/src/CMakeLists.txt index d9216812c253c003b87dc3b2d16d1f7a5df71925..a0b81badc88bc8dffe70c93d957d95563b589cb0 100644 --- a/packages/xpetra/src/CMakeLists.txt +++ b/packages/xpetra/src/CMakeLists.txt @@ -101,6 +101,7 @@ IF (${PACKAGE_NAME}_ENABLE_Epetra) ENDIF() # Create the .hpp file in BUILD/packages/xpetra/src +TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${CMAKE_CURRENT_SOURCE_DIR}/CrsGraph NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${CMAKE_CURRENT_SOURCE_DIR}/CrsMatrix NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${CMAKE_CURRENT_SOURCE_DIR}/MultiVector NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${CMAKE_CURRENT_SOURCE_DIR}/Vector NOSIERRABJAM) diff --git a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp new file mode 100644 index 0000000000000000000000000000000000000000..bc116b3319a100456190582ef4f5d36ccf794dd1 --- /dev/null +++ b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp @@ -0,0 +1,388 @@ +// @HEADER +// +// *********************************************************************** +// +// Xpetra: A linear algebra interface package +// Copyright 2012 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact +// Jonathan Hu (jhu@sandia.gov) +// Andrey Prokopenko (aprokop@sandia.gov) +// Ray Tuminaro (rstumin@sandia.gov) +// +// *********************************************************************** +// +// @HEADER +#ifndef XPETRA_TPETRACRSGRAPH_DECL_HPP +#define XPETRA_TPETRACRSGRAPH_DECL_HPP + +/* this file is automatically generated - do not edit (see script/tpetra.py) */ + +#include "Xpetra_TpetraConfigDefs.hpp" +#include "Xpetra_Exceptions.hpp" + +#include "Tpetra_CrsGraph.hpp" + +#include "Xpetra_CrsGraph.hpp" +#include "Xpetra_Utils.hpp" +#include "Xpetra_TpetraMap.hpp" +#include "Xpetra_TpetraImport.hpp" +#include "Xpetra_TpetraExport.hpp" + +namespace Xpetra { + + + template ::local_ordinal_type, + class GlobalOrdinal = typename CrsGraph::global_ordinal_type, + class Node = typename CrsGraph::node_type> + class TpetraCrsGraph + : public CrsGraph + { + + // The following typedef is used by the XPETRA_DYNAMIC_CAST() macro. + typedef TpetraCrsGraph TpetraCrsGraphClass; + typedef Map map_type; + +#ifdef HAVE_XPETRA_KOKKOS_REFACTOR + typedef typename Xpetra::CrsGraph::local_graph_type local_graph_type; +#endif + + public: + + //! @name Constructor/Destructor Methods + //@{ + + //! Constructor specifying fixed number of entries for each row. + TpetraCrsGraph(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null); + + //! Constructor specifying (possibly different) number of entries in each row. + TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null); + + //! Constructor specifying column Map and fixed number of entries for each row. + TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null); + + //! Constructor specifying column Map and number of entries in each row. + TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null); + +#ifdef HAVE_XPETRA_KOKKOS_REFACTOR + /// \brief Constructor specifying column Map and arrays containing the graph in sorted, local ids. + /// + /// + /// \param rowMap [in] Distribution of rows of the graph. + /// + /// \param colMap [in] Distribution of columns of the graph. + /// + /// \param rowPointers [in] The beginning of each row in the graph, + /// as in a CSR "rowptr" array. The length of this vector should be + /// equal to the number of rows in the graph, plus one. This last + /// entry should store the nunber of nonzeros in the graph. + /// + /// \param columnIndices [in] The local indices of the columns, + /// as in a CSR "colind" array. The length of this vector + /// should be equal to the number of unknowns in the graph. + /// + /// \param params [in/out] Optional list of parameters. If not + /// null, any missing parameters will be filled in with their + /// default values. + TpetraCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, + const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, + const typename local_graph_type::row_map_type& rowPointers, + const typename local_graph_type::entries_type::non_const_type& columnIndices, + const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null); + + /// \brief Constructor specifying column, domain and range maps, and a + /// local (sorted) graph, which the resulting CrsGraph views. + /// + /// Unlike most other CrsGraph constructors, successful completion + /// of this constructor will result in a fill-complete graph. + /// + /// \param rowMap [in] Distribution of rows of the graph. + /// + /// \param colMap [in] Distribution of columns of the graph. + /// + /// \param domainMap [in] The graph's domain Map. MUST be one to + /// one! + /// + /// \param rangeMap [in] The graph's range Map. MUST be one to + /// one! May be, but need not be, the same as the domain Map. + /// + /// \param lclGraph [in] A locally indexed Kokkos::StaticCrsGraph + /// whose local row indices come from the specified row Map, and + /// whose local column indices come from the specified column + /// Map. + /// + /// \param params [in/out] Optional list of parameters. If not + /// null, any missing parameters will be filled in with their + /// default values. + TpetraCrsGraph(const local_graph_type& lclGraph, + const Teuchos::RCP& rowMap, + const Teuchos::RCP& colMap, + const Teuchos::RCP& domainMap = Teuchos::null, + const Teuchos::RCP& rangeMap = Teuchos::null, + const Teuchos::RCP& params = Teuchos::null); + + /// \brief Constructor specifying column Map and a local (sorted) + /// graph, which the resulting CrsGraph views. + /// + /// Unlike most other CrsGraph constructors, successful completion + /// of this constructor will result in a fill-complete graph. + /// + /// \param rowMap [in] Distribution of rows of the graph. + /// + /// \param colMap [in] Distribution of columns of the graph. + /// + /// \param lclGraph [in] A locally indexed Kokkos::StaticCrsGraph + /// whose local row indices come from the specified row Map, and + /// whose local column indices come from the specified column + /// Map. + /// + /// \param params [in/out] Optional list of parameters. If not + /// null, any missing parameters will be filled in with their + /// default values. + TpetraCrsGraph(const Teuchos::RCP& rowMap, + const Teuchos::RCP& colMap, + const local_graph_type& lclGraph, + const Teuchos::RCP& params); + +#endif + + //! Destructor. + virtual ~TpetraCrsGraph(); + + //! @name Insertion/Removal Methods + //@{ + + //! Insert global indices into the graph. + void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices); + + //! Insert local indices into the graph. + void insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices); + + //! Remove all graph indices from the specified local row. + void removeLocalIndices(LocalOrdinal localRow); + + //@} + + //! @name Transformational Methods + //@{ + + //! Signal that data entry is complete, specifying domain and range maps. + void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null); + + //! Signal that data entry is complete. + void fillComplete(const RCP< ParameterList > ¶ms=null); + + //@} + + //! @name Methods implementing RowGraph. + //@{ + + //! Returns the communicator. + RCP< const Comm< int > > getComm() const; + + //! Returns the Map that describes the row distribution in this graph. + RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const; + + //! Returns the Map that describes the column distribution in this graph. + RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const; + + //! Returns the Map associated with the domain of this graph. + RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const; + + //! Returns the Map associated with the domain of this graph. + RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const; + + //! Returns the importer associated with this graph. + RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter() const; + + //! Returns the exporter associated with this graph. + RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > getExporter() const; + + //! Returns the number of global rows in the graph. + global_size_t getGlobalNumRows() const; + + //! Returns the number of global columns in the graph. + global_size_t getGlobalNumCols() const; + + //! Returns the number of graph rows owned on the calling node. + size_t getNodeNumRows() const; + + //! Returns the number of columns connected to the locally owned rows of this graph. + size_t getNodeNumCols() const; + + //! Returns the index base for global indices for this graph. + GlobalOrdinal getIndexBase() const; + + //! Returns the global number of entries in the graph. + global_size_t getGlobalNumEntries() const; + + //! Returns the local number of entries in the graph. + size_t getNodeNumEntries() const; + + //! Returns the current number of entries on this node in the specified global row. + size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) 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 allocated entries for this node in the specified global row . + size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const; + + //! Returns the current number of allocated entries on this node in the specified local row. + size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const; + + //! Maximum number of entries in all rows over all processes. + size_t getGlobalMaxNumRowEntries() const; + + //! Maximum number of entries in all rows owned by the calling process. + size_t getNodeMaxNumRowEntries() const; + + //! Whether the graph has a column Map. + bool hasColMap() const; + + //! Whether column indices are stored using local indices on the calling process. + bool isLocallyIndexed() const; + + //! Whether column indices are stored using global indices on the calling process. + bool isGloballyIndexed() const; + + //! Whether fillComplete() has been called and the graph is in compute mode. + bool isFillComplete() const; + + //! Returns true if storage has been optimized. + bool isStorageOptimized() const; + + //! Return a const, nonpersisting view of global indices in the given row. + void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const; + + //! Return a const, nonpersisting view of local indices in the given row. + void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const; + +#ifdef HAVE_XPETRA_KOKKOS_REFACTOR + /// \brief Access the local KokkosSparse::StaticCrsGraph data + local_graph_type getLocalGraph () const; +#endif + + + //! Force the computation of global constants if we don't have them + void computeGlobalConstants(); + + //@} + + //! @name Overridden from Teuchos::Describable + //@{ + + //! Return 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 Advanced methods, at increased risk of deprecation. + //@{ + + //! Get an ArrayRCP of the row-offsets. + ArrayRCP< const size_t > getNodeRowPtrs() const; + + //@} + + //! Implements DistObject interface + //{@ + + //! Access function for the Tpetra::Map this DistObject was constructed with. + Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const; + + //! Import. + void doImport(const DistObject &source, + const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM); + + //! Export. + void doExport(const DistObject &dest, + const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM); + + //! Import (using an Exporter). + void doImport(const DistObject &source, + const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM); + + //! Export (using an Importer). + void doExport(const DistObject &dest, + const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM); + + // @} + + //! @name Xpetra specific + //@{ + + //! TpetraCrsGraph constructor to wrap a Tpetra::CrsGraph object + TpetraCrsGraph(const Teuchos::RCP > &graph); + + //! Get the underlying Tpetra graph + RCP< const Tpetra::CrsGraph > getTpetra_CrsGraph() const; + + //@} + + private: + RCP< Tpetra::CrsGraph > graph_; + }; // TpetraCrsGraph class + + + // TODO: move that elsewhere + template + RCP > + toXpetra (RCP > graph) + { //TODO: return TpetraCrsGraph instead of CrsGraph + // typedef TpetraCrsGraph TpetraCrsGraphClass; + // XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tGraph, "toTpetra"); + if (graph.is_null ()) { + return Teuchos::null; + } + RCP > tGraph = + Teuchos::rcp_const_cast > (graph); + return rcp (new Xpetra::TpetraCrsGraph (tGraph)); + } + + template + RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > + toTpetra (const RCP > &graph) + { + typedef TpetraCrsGraph TpetraCrsGraphClass; + XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tpetraCrsGraph, "toTpetra"); + return tpetraCrsGraph->getTpetra_CrsGraph (); + } + +} // Xpetra namespace + +#endif // XPETRA_TPETRACRSGRAPH_DECL_HPP + diff --git a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph.hpp b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp similarity index 62% rename from packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph.hpp rename to packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp index fab4831939d3bb621c39fda9322f9624141b0655..ae809b3aef3d83ad88dd1e7dfad833e77293f4c2 100644 --- a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph.hpp +++ b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp @@ -43,396 +43,286 @@ // *********************************************************************** // // @HEADER -#ifndef XPETRA_TPETRACRSGRAPH_HPP -#define XPETRA_TPETRACRSGRAPH_HPP - -/* this file is automatically generated - do not edit (see script/tpetra.py) */ - +#ifndef XPETRA_TPETRACRSGRAPH_DEF_HPP +#define XPETRA_TPETRACRSGRAPH_DEF_HPP #include "Xpetra_TpetraConfigDefs.hpp" #include "Xpetra_Exceptions.hpp" #include "Tpetra_CrsGraph.hpp" #include "Xpetra_CrsGraph.hpp" +#include "Xpetra_TpetraCrsGraph_decl.hpp" #include "Xpetra_Utils.hpp" #include "Xpetra_TpetraMap.hpp" #include "Xpetra_TpetraImport.hpp" #include "Xpetra_TpetraExport.hpp" -namespace Xpetra { - - // TODO: move that elsewhere - template - RCP > - toXpetra (RCP > graph); - - template - RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > - toTpetra (const RCP >& graph); - - template ::local_ordinal_type, - class GlobalOrdinal = typename CrsGraph::global_ordinal_type, - class Node = typename CrsGraph::node_type> - class TpetraCrsGraph - : public CrsGraph - { - - // The following typedef is used by the XPETRA_DYNAMIC_CAST() macro. - typedef TpetraCrsGraph TpetraCrsGraphClass; - typedef Map map_type; +namespace Xpetra { #ifdef HAVE_XPETRA_KOKKOS_REFACTOR - typedef typename Xpetra::CrsGraph::local_graph_type local_graph_type; #endif - public: +template +TpetraCrsGraph::TpetraCrsGraph(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype, const RCP< ParameterList > ¶ms) +: graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } - //! @name Constructor/Destructor Methods - //@{ - - //! Constructor specifying fixed number of entries for each row. - TpetraCrsGraph(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } +template +TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype, const RCP< ParameterList > ¶ms) +: graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } - //! Constructor specifying (possibly different) number of entries in each row. - TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } +template +TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype, const RCP< ParameterList > ¶ms) +: graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } - //! Constructor specifying column Map and fixed number of entries for each row. - TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } - - //! Constructor specifying column Map and number of entries in each row. - TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } +template +TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype, const RCP< ParameterList > ¶ms) +: graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } #ifdef HAVE_XPETRA_KOKKOS_REFACTOR - /// \brief Constructor specifying column Map and arrays containing the graph in sorted, local ids. - /// - /// - /// \param rowMap [in] Distribution of rows of the graph. - /// - /// \param colMap [in] Distribution of columns of the graph. - /// - /// \param rowPointers [in] The beginning of each row in the graph, - /// as in a CSR "rowptr" array. The length of this vector should be - /// equal to the number of rows in the graph, plus one. This last - /// entry should store the nunber of nonzeros in the graph. - /// - /// \param columnIndices [in] The local indices of the columns, - /// as in a CSR "colind" array. The length of this vector - /// should be equal to the number of unknowns in the graph. - /// - /// \param params [in/out] Optional list of parameters. If not - /// null, any missing parameters will be filled in with their - /// default values. - TpetraCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, - const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, - const typename local_graph_type::row_map_type& rowPointers, - const typename local_graph_type::entries_type::non_const_type& columnIndices, - const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), rowPointers, columnIndices, plist))) { } - - /// \brief Constructor specifying column Map and a local (sorted) - /// graph, which the resulting CrsGraph views. - /// - /// Unlike most other CrsGraph constructors, successful completion - /// of this constructor will result in a fill-complete graph. - /// - /// \param rowMap [in] Distribution of rows of the graph. - /// - /// \param colMap [in] Distribution of columns of the graph. - /// - /// \param lclGraph [in] A locally indexed Kokkos::StaticCrsGraph - /// whose local row indices come from the specified row Map, and - /// whose local column indices come from the specified column - /// Map. - /// - /// \param params [in/out] Optional list of parameters. If not - /// null, any missing parameters will be filled in with their - /// default values. - TpetraCrsGraph(const Teuchos::RCP& rowMap, - const Teuchos::RCP& colMap, - const local_graph_type& lclGraph, - const Teuchos::RCP& params) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), lclGraph, params))) { } - - /// \brief Constructor specifying column, domain and range maps, and a - /// local (sorted) graph, which the resulting CrsGraph views. - /// - /// Unlike most other CrsGraph constructors, successful completion - /// of this constructor will result in a fill-complete graph. - /// - /// \param rowMap [in] Distribution of rows of the graph. - /// - /// \param colMap [in] Distribution of columns of the graph. - /// - /// \param domainMap [in] The graph's domain Map. MUST be one to - /// one! - /// - /// \param rangeMap [in] The graph's range Map. MUST be one to - /// one! May be, but need not be, the same as the domain Map. - /// - /// \param lclGraph [in] A locally indexed Kokkos::StaticCrsGraph - /// whose local row indices come from the specified row Map, and - /// whose local column indices come from the specified column - /// Map. - /// - /// \param params [in/out] Optional list of parameters. If not - /// null, any missing parameters will be filled in with their - /// default values. - TpetraCrsGraph(const local_graph_type& lclGraph, - const Teuchos::RCP& rowMap, - const Teuchos::RCP& colMap, - const Teuchos::RCP& domainMap = Teuchos::null, - const Teuchos::RCP& rangeMap = Teuchos::null, - const Teuchos::RCP& params = Teuchos::null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph(lclGraph, toTpetra(rowMap), toTpetra(colMap), toTpetra(domainMap), toTpetra(rangeMap), params))) { } +template +TpetraCrsGraph:: +TpetraCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, + const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, + const typename local_graph_type::row_map_type& rowPointers, + const typename local_graph_type::entries_type::non_const_type& columnIndices, + const Teuchos::RCP< Teuchos::ParameterList > &plist) + : graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), rowPointers, columnIndices, plist))) { } + + +template +TpetraCrsGraph:: +TpetraCrsGraph(const Teuchos::RCP& rowMap, + const Teuchos::RCP& colMap, + const local_graph_type& lclGraph, + const Teuchos::RCP& params) + : graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), lclGraph, params))) { } + +template +TpetraCrsGraph:: +TpetraCrsGraph(const local_graph_type& lclGraph, + const Teuchos::RCP& rowMap, + const Teuchos::RCP& colMap, + const Teuchos::RCP& domainMap, + const Teuchos::RCP& rangeMap, + const Teuchos::RCP& params) + : graph_(Teuchos::rcp(new Tpetra::CrsGraph(lclGraph, toTpetra(rowMap), toTpetra(colMap), toTpetra(domainMap), toTpetra(rangeMap), params))) { } #endif - //! Destructor. - virtual ~TpetraCrsGraph() { } - - //@} - - //! @name Insertion/Removal Methods - //@{ - - //! Insert global indices into the graph. - void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices) { XPETRA_MONITOR("TpetraCrsGraph::insertGlobalIndices"); graph_->insertGlobalIndices(globalRow, indices); } - - //! Insert local indices into the graph. - void insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices) { XPETRA_MONITOR("TpetraCrsGraph::insertLocalIndices"); graph_->insertLocalIndices(localRow, indices); } +template + TpetraCrsGraph::~TpetraCrsGraph() { } - //! Remove all graph indices from the specified local row. - void removeLocalIndices(LocalOrdinal localRow) { XPETRA_MONITOR("TpetraCrsGraph::removeLocalIndices"); graph_->removeLocalIndices(localRow); } +template +void TpetraCrsGraph::insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices) +{ XPETRA_MONITOR("TpetraCrsGraph::insertGlobalIndices"); graph_->insertGlobalIndices(globalRow, indices); } - //@} +template +void TpetraCrsGraph::insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices) +{ XPETRA_MONITOR("TpetraCrsGraph::insertLocalIndices"); graph_->insertLocalIndices(localRow, indices); } - //! @name Transformational Methods - //@{ +template +void TpetraCrsGraph::removeLocalIndices(LocalOrdinal localRow) +{ XPETRA_MONITOR("TpetraCrsGraph::removeLocalIndices"); graph_->removeLocalIndices(localRow); } - //! Signal that data entry is complete, specifying domain and range maps. - void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null) { XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(toTpetra(domainMap), toTpetra(rangeMap), params); } +template +void TpetraCrsGraph::fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms) +{ XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(toTpetra(domainMap), toTpetra(rangeMap), params); } - //! Signal that data entry is complete. - void fillComplete(const RCP< ParameterList > ¶ms=null) { XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(params); } +template +void TpetraCrsGraph::fillComplete(const RCP< ParameterList > ¶ms) +{ XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(params); } - //@} +template +RCP< const Comm< int > > TpetraCrsGraph::getComm() const +{ XPETRA_MONITOR("TpetraCrsGraph::getComm"); return graph_->getComm(); } - //! @name Methods implementing RowGraph. - //@{ +template +RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getRowMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getRowMap"); return toXpetra(graph_->getRowMap()); } - //! Returns the communicator. - RCP< const Comm< int > > getComm() const { XPETRA_MONITOR("TpetraCrsGraph::getComm"); return graph_->getComm(); } +template +RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getColMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getColMap"); return toXpetra(graph_->getColMap()); } - //! Returns the Map that describes the row distribution in this graph. - RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const { XPETRA_MONITOR("TpetraCrsGraph::getRowMap"); return toXpetra(graph_->getRowMap()); } +template +RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getDomainMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getDomainMap"); return toXpetra(graph_->getDomainMap()); } - //! Returns the Map that describes the column distribution in this graph. - RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const { XPETRA_MONITOR("TpetraCrsGraph::getColMap"); return toXpetra(graph_->getColMap()); } +template +RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getRangeMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getRangeMap"); return toXpetra(graph_->getRangeMap()); } - //! Returns the Map associated with the domain of this graph. - RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const { XPETRA_MONITOR("TpetraCrsGraph::getDomainMap"); return toXpetra(graph_->getDomainMap()); } +template +RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getImporter() const +{ XPETRA_MONITOR("TpetraCrsGraph::getImporter"); return toXpetra(graph_->getImporter()); } - //! Returns the Map associated with the domain of this graph. - RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const { XPETRA_MONITOR("TpetraCrsGraph::getRangeMap"); return toXpetra(graph_->getRangeMap()); } +template +RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getExporter() const +{ XPETRA_MONITOR("TpetraCrsGraph::getExporter"); return toXpetra(graph_->getExporter()); } - //! Returns the importer associated with this graph. - RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter() const { XPETRA_MONITOR("TpetraCrsGraph::getImporter"); return toXpetra(graph_->getImporter()); } +template +global_size_t TpetraCrsGraph::getGlobalNumRows() const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumRows"); return graph_->getGlobalNumRows(); } - //! Returns the exporter associated with this graph. - RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > getExporter() const { XPETRA_MONITOR("TpetraCrsGraph::getExporter"); return toXpetra(graph_->getExporter()); } +template +global_size_t TpetraCrsGraph::getGlobalNumCols() const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumCols"); return graph_->getGlobalNumCols(); } - //! Returns the number of global rows in the graph. - global_size_t getGlobalNumRows() const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumRows"); return graph_->getGlobalNumRows(); } +template +size_t TpetraCrsGraph::getNodeNumRows() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeNumRows"); return graph_->getNodeNumRows(); } - //! Returns the number of global columns in the graph. - global_size_t getGlobalNumCols() const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumCols"); return graph_->getGlobalNumCols(); } +template +size_t TpetraCrsGraph::getNodeNumCols() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeNumCols"); return graph_->getNodeNumCols(); } - //! Returns the number of graph rows owned on the calling node. - size_t getNodeNumRows() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeNumRows"); return graph_->getNodeNumRows(); } +template +GlobalOrdinal TpetraCrsGraph::getIndexBase() const +{ XPETRA_MONITOR("TpetraCrsGraph::getIndexBase"); return graph_->getIndexBase(); } - //! Returns the number of columns connected to the locally owned rows of this graph. - size_t getNodeNumCols() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeNumCols"); return graph_->getNodeNumCols(); } +template +global_size_t TpetraCrsGraph::getGlobalNumEntries() const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumEntries"); return graph_->getGlobalNumEntries(); } - //! Returns the index base for global indices for this graph. - GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("TpetraCrsGraph::getIndexBase"); return graph_->getIndexBase(); } +template +size_t TpetraCrsGraph::getNodeNumEntries() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeNumEntries"); return graph_->getNodeNumEntries(); } - //! Returns the global number of entries in the graph. - global_size_t getGlobalNumEntries() const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumEntries"); return graph_->getGlobalNumEntries(); } +template +size_t TpetraCrsGraph::getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const +{ XPETRA_MONITOR("TpetraCrsGraph::getNumEntriesInGlobalRow"); return graph_->getNumEntriesInGlobalRow(globalRow); } - //! Returns the local number of entries in the graph. - size_t getNodeNumEntries() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeNumEntries"); return graph_->getNodeNumEntries(); } +template +size_t TpetraCrsGraph::getNumEntriesInLocalRow(LocalOrdinal localRow) const +{ XPETRA_MONITOR("TpetraCrsGraph::getNumEntriesInLocalRow"); return graph_->getNumEntriesInLocalRow(localRow); } - //! Returns the current number of entries on this node in the specified global row. - size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const { XPETRA_MONITOR("TpetraCrsGraph::getNumEntriesInGlobalRow"); return graph_->getNumEntriesInGlobalRow(globalRow); } +template +size_t TpetraCrsGraph::getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const +{ XPETRA_MONITOR("TpetraCrsGraph::getNumAllocatedEntriesInGlobalRow"); return graph_->getNumAllocatedEntriesInGlobalRow(globalRow); } - //! Returns the current number of entries on this node in the specified local row. - size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const { XPETRA_MONITOR("TpetraCrsGraph::getNumEntriesInLocalRow"); return graph_->getNumEntriesInLocalRow(localRow); } +template +size_t TpetraCrsGraph::getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const +{ XPETRA_MONITOR("TpetraCrsGraph::getNumAllocatedEntriesInLocalRow"); return graph_->getNumAllocatedEntriesInLocalRow(localRow); } - //! Returns the current number of allocated entries for this node in the specified global row . - size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const { XPETRA_MONITOR("TpetraCrsGraph::getNumAllocatedEntriesInGlobalRow"); return graph_->getNumAllocatedEntriesInGlobalRow(globalRow); } +template +size_t TpetraCrsGraph::getGlobalMaxNumRowEntries() const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalMaxNumRowEntries"); return graph_->getGlobalMaxNumRowEntries(); } - //! Returns the current number of allocated entries on this node in the specified local row. - size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const { XPETRA_MONITOR("TpetraCrsGraph::getNumAllocatedEntriesInLocalRow"); return graph_->getNumAllocatedEntriesInLocalRow(localRow); } +template +size_t TpetraCrsGraph::getNodeMaxNumRowEntries() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeMaxNumRowEntries"); return graph_->getNodeMaxNumRowEntries(); } - //! Maximum number of entries in all rows over all processes. - size_t getGlobalMaxNumRowEntries() const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalMaxNumRowEntries"); return graph_->getGlobalMaxNumRowEntries(); } +template +bool TpetraCrsGraph::hasColMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::hasColMap"); return graph_->hasColMap(); } - //! Maximum number of entries in all rows owned by the calling process. - size_t getNodeMaxNumRowEntries() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeMaxNumRowEntries"); return graph_->getNodeMaxNumRowEntries(); } +template +bool TpetraCrsGraph::isLocallyIndexed() const +{ XPETRA_MONITOR("TpetraCrsGraph::isLocallyIndexed"); return graph_->isLocallyIndexed(); } - //! Whether the graph has a column Map. - bool hasColMap() const { XPETRA_MONITOR("TpetraCrsGraph::hasColMap"); return graph_->hasColMap(); } +template +bool TpetraCrsGraph::isGloballyIndexed() const +{ XPETRA_MONITOR("TpetraCrsGraph::isGloballyIndexed"); return graph_->isGloballyIndexed(); } - //! Whether column indices are stored using local indices on the calling process. - bool isLocallyIndexed() const { XPETRA_MONITOR("TpetraCrsGraph::isLocallyIndexed"); return graph_->isLocallyIndexed(); } +template +bool TpetraCrsGraph::isFillComplete() const +{ XPETRA_MONITOR("TpetraCrsGraph::isFillComplete"); return graph_->isFillComplete(); } - //! Whether column indices are stored using global indices on the calling process. - bool isGloballyIndexed() const { XPETRA_MONITOR("TpetraCrsGraph::isGloballyIndexed"); return graph_->isGloballyIndexed(); } +template +bool TpetraCrsGraph::isStorageOptimized() const +{ XPETRA_MONITOR("TpetraCrsGraph::isStorageOptimized"); return graph_->isStorageOptimized(); } - //! Whether fillComplete() has been called and the graph is in compute mode. - bool isFillComplete() const { XPETRA_MONITOR("TpetraCrsGraph::isFillComplete"); return graph_->isFillComplete(); } - - //! Returns true if storage has been optimized. - bool isStorageOptimized() const { XPETRA_MONITOR("TpetraCrsGraph::isStorageOptimized"); return graph_->isStorageOptimized(); } +template +void TpetraCrsGraph::getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalRowView"); graph_->getGlobalRowView(GlobalRow, Indices); } - //! Return a const, nonpersisting view of global indices in the given row. - void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalRowView"); graph_->getGlobalRowView(GlobalRow, Indices); } - - //! Return a const, nonpersisting view of local indices in the given row. - void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const { XPETRA_MONITOR("TpetraCrsGraph::getLocalRowView"); graph_->getLocalRowView(LocalRow, indices); } +template +void TpetraCrsGraph::getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const +{ XPETRA_MONITOR("TpetraCrsGraph::getLocalRowView"); graph_->getLocalRowView(LocalRow, indices); } #ifdef HAVE_XPETRA_KOKKOS_REFACTOR - /// \brief Access the local KokkosSparse::StaticCrsGraph data - local_graph_type getLocalGraph () const { - return getTpetra_CrsGraph()->getLocalGraph(); - } +template +typename Xpetra::CrsGraph::local_graph_type TpetraCrsGraph::getLocalGraph () const { + return getTpetra_CrsGraph()->getLocalGraph(); +} #endif - - //! Force the computation of global constants if we don't have them - void computeGlobalConstants() { +template +void TpetraCrsGraph::computeGlobalConstants() { // mfh 07 May 2018: See GitHub Issue #2565. constexpr bool computeLocalTriangularConstants = true; graph_->computeGlobalConstants(computeLocalTriangularConstants); } - //@} - - //! @name Overridden from Teuchos::Describable - //@{ - - //! Return a simple one-line description of this object. - std::string description() const { XPETRA_MONITOR("TpetraCrsGraph::description"); return graph_->description(); } - - //! 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 { XPETRA_MONITOR("TpetraCrsGraph::describe"); graph_->describe(out, verbLevel); } - - //@} - - //! @name Advanced methods, at increased risk of deprecation. - //@{ - - //! Get an ArrayRCP of the row-offsets. - ArrayRCP< const size_t > getNodeRowPtrs() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeRowPtrs"); return graph_->getNodeRowPtrs(); } - - //@} - - //! Implements DistObject interface - //{@ - - //! Access function for the Tpetra::Map this DistObject was constructed with. - Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const { XPETRA_MONITOR("TpetraCrsGraph::getMap"); return rcp( new TpetraMap< LocalOrdinal, GlobalOrdinal, Node >(graph_->getMap()) ); } - - //! Import. - void doImport(const DistObject &source, - const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM) { - XPETRA_MONITOR("TpetraCrsGraph::doImport"); - - XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() - RCP< const Tpetra::CrsGraph > v = tSource.getTpetra_CrsGraph(); - //graph_->doImport(toTpetraCrsGraph(source), *tImporter.getTpetra_Import(), toTpetra(CM)); - - graph_->doImport(*v, toTpetra(importer), toTpetra(CM)); - } - - //! Export. - void doExport(const DistObject &dest, - const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM) { - XPETRA_MONITOR("TpetraCrsGraph::doExport"); - - XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() - RCP< const Tpetra::CrsGraph > v = tDest.getTpetra_CrsGraph(); - graph_->doExport(*v, toTpetra(importer), toTpetra(CM)); - - } - - //! Import (using an Exporter). - void doImport(const DistObject &source, - const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) { - XPETRA_MONITOR("TpetraCrsGraph::doImport"); - - XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() - RCP< const Tpetra::CrsGraph > v = tSource.getTpetra_CrsGraph(); - - graph_->doImport(*v, toTpetra(exporter), toTpetra(CM)); - - } - - //! Export (using an Importer). - void doExport(const DistObject &dest, - const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) { - XPETRA_MONITOR("TpetraCrsGraph::doExport"); - - XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() - RCP< const Tpetra::CrsGraph > v = tDest.getTpetra_CrsGraph(); - +template +std::string TpetraCrsGraph::description() const +{ XPETRA_MONITOR("TpetraCrsGraph::description"); return graph_->description(); } + +template +void TpetraCrsGraph::describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const +{ XPETRA_MONITOR("TpetraCrsGraph::describe"); graph_->describe(out, verbLevel); } + +template +ArrayRCP< const size_t > TpetraCrsGraph::getNodeRowPtrs() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeRowPtrs"); return graph_->getNodeRowPtrs(); } + +template +Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getMap"); return rcp( new TpetraMap< LocalOrdinal, GlobalOrdinal, Node >(graph_->getMap()) ); } + +template +void TpetraCrsGraph::doImport(const DistObject &source, + const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM){ + XPETRA_MONITOR("TpetraCrsGraph::doImport"); + + XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() + RCP< const Tpetra::CrsGraph > v = tSource.getTpetra_CrsGraph(); + //graph_->doImport(toTpetraCrsGraph(source), *tImporter.getTpetra_Import(), toTpetra(CM)); + + graph_->doImport(*v, toTpetra(importer), toTpetra(CM)); +} + +template +void TpetraCrsGraph::doExport(const DistObject &dest, + const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM) { + XPETRA_MONITOR("TpetraCrsGraph::doExport"); + + XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() + RCP< const Tpetra::CrsGraph > v = tDest.getTpetra_CrsGraph(); + graph_->doExport(*v, toTpetra(importer), toTpetra(CM)); + +} + +template +void TpetraCrsGraph::doImport(const DistObject &source, + const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM){ + XPETRA_MONITOR("TpetraCrsGraph::doImport"); + + XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() + RCP< const Tpetra::CrsGraph > v = tSource.getTpetra_CrsGraph(); + + graph_->doImport(*v, toTpetra(exporter), toTpetra(CM)); + +} + +template +void TpetraCrsGraph::doExport(const DistObject &dest, + const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) { + XPETRA_MONITOR("TpetraCrsGraph::doExport"); + + XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() + RCP< const Tpetra::CrsGraph > v = tDest.getTpetra_CrsGraph(); + graph_->doExport(*v, toTpetra(exporter), toTpetra(CM)); + +} - } - - // @} +template +TpetraCrsGraph::TpetraCrsGraph(const Teuchos::RCP > &graph) : graph_(graph) +{ } - //! @name Xpetra specific - //@{ - - //! TpetraCrsGraph constructor to wrap a Tpetra::CrsGraph object - TpetraCrsGraph(const Teuchos::RCP > &graph) : graph_(graph) { } - - //! Get the underlying Tpetra graph - RCP< const Tpetra::CrsGraph > getTpetra_CrsGraph() const { return graph_; } - - //@} - - private: - RCP< Tpetra::CrsGraph > graph_; - }; // TpetraCrsGraph class - - // TODO: move that elsewhere - template - RCP > - toXpetra (RCP > graph) - { //TODO: return TpetraCrsGraph instead of CrsGraph - // typedef TpetraCrsGraph TpetraCrsGraphClass; - // XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tGraph, "toTpetra"); - if (graph.is_null ()) { - return Teuchos::null; - } - RCP > tGraph = - Teuchos::rcp_const_cast > (graph); - return rcp (new Xpetra::TpetraCrsGraph (tGraph)); - } - - template - RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > - toTpetra (const RCP > &graph) - { - typedef TpetraCrsGraph TpetraCrsGraphClass; - XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tpetraCrsGraph, "toTpetra"); - return tpetraCrsGraph->getTpetra_CrsGraph (); - } +template +RCP< const Tpetra::CrsGraph > TpetraCrsGraph::getTpetra_CrsGraph() const +{ return graph_; } #ifdef HAVE_XPETRA_EPETRA @@ -1085,7 +975,7 @@ namespace Xpetra { #endif // HAVE_XPETRA_EPETRA + } // Xpetra namespace +#endif //XPETRA_TPETRACRSGRAPH_DEF_HPP -#define XPETRA_TPETRACRSGRAPH_SHORT -#endif // XPETRA_TPETRACRSGRAPH_HPP diff --git a/packages/xpetra/src/Utils/ClassList/LO-GO-NO.classList b/packages/xpetra/src/Utils/ClassList/LO-GO-NO.classList index 2a8c27011fc49622297b79fb9a3f505304d58b1e..29860c0b690a0769b43ab9c13ed86fd4d7356a39 100644 --- a/packages/xpetra/src/Utils/ClassList/LO-GO-NO.classList +++ b/packages/xpetra/src/Utils/ClassList/LO-GO-NO.classList @@ -13,7 +13,7 @@ #StridedMapFactory #StridedTpetraMap ##TpetraBlockMap -#TpetraCrsGraph +TpetraCrsGraph #TpetraExport TpetraImport #TpetraMap diff --git a/packages/xpetra/src/Utils/ExplicitInstantiation/ETI_LO_GO_NO_classes.cmake b/packages/xpetra/src/Utils/ExplicitInstantiation/ETI_LO_GO_NO_classes.cmake index 9dc0db22fd01af258f86bc5c79687f80e1ba286c..f9267ac1e410e18a030b3061e5af71b342cbb6ca 100644 --- a/packages/xpetra/src/Utils/ExplicitInstantiation/ETI_LO_GO_NO_classes.cmake +++ b/packages/xpetra/src/Utils/ExplicitInstantiation/ETI_LO_GO_NO_classes.cmake @@ -1,2 +1,3 @@ # This file is automatically generated by xpetra/src/Utils/ExplicitInstantiation/genClassLists.sh +APPEND_SET(XPETRA_LO_GO_NO_ETI_CLASSES Xpetra::TpetraCrsGraph ) APPEND_SET(XPETRA_LO_GO_NO_ETI_CLASSES Xpetra::TpetraImport )