// @HEADER // ***************************************************************************** // Xpetra: A linear algebra interface package // // Copyright 2012 NTESS and the Xpetra contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef XPETRA_TPETRAMAP_DECL_HPP #define XPETRA_TPETRAMAP_DECL_HPP /* this file is automatically generated - do not edit (see script/tpetra.py) */ #include "Xpetra_TpetraConfigDefs.hpp" #include #include "Xpetra_Map_decl.hpp" #include "Xpetra_Utils.hpp" #include "Xpetra_Exceptions.hpp" namespace Xpetra { template const RCP > toXpetraNonConst(const RCP > &map); template class TpetraMap : public virtual Map { public: typedef typename Map::global_indices_array_device_type global_indices_array_device_type; //! @name Constructors and destructor //@{ //! Constructor with Tpetra-defined contiguous uniform distribution. TpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP > &comm, LocalGlobal lg = GloballyDistributed); //! Constructor with a user-defined contiguous distribution. TpetraMap(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP > &comm); //! Constructor with user-defined arbitrary (possibly noncontiguous) distribution. TpetraMap(global_size_t numGlobalElements, const Teuchos::ArrayView &elementList, GlobalOrdinal indexBase, const Teuchos::RCP > &comm); #ifdef HAVE_XPETRA_TPETRA //! Constructor with user-defined arbitrary (possibly noncontiguous) distribution passed as a Kokkos::View. TpetraMap(global_size_t numGlobalElements, const Kokkos::View &indexList, GlobalOrdinal indexBase, const Teuchos::RCP > &comm); #endif //! Destructor ~TpetraMap(); //! @name Attributes //@{ //! The number of elements in this Map. global_size_t getGlobalNumElements() const; //! The number of elements belonging to the calling node. size_t getLocalNumElements() const; //! The index base for this Map. GlobalOrdinal getIndexBase() const; //! The minimum local index. LocalOrdinal getMinLocalIndex() const; //! The maximum local index on the calling process. LocalOrdinal getMaxLocalIndex() const; //! The minimum global index owned by the calling process. GlobalOrdinal getMinGlobalIndex() const; //! The maximum global index owned by the calling process. GlobalOrdinal getMaxGlobalIndex() const; //! The minimum global index over all processes in the communicator. GlobalOrdinal getMinAllGlobalIndex() const; //! The maximum global index over all processes in the communicator. GlobalOrdinal getMaxAllGlobalIndex() const; //! The local index corresponding to the given global index. LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const; //! The global index corresponding to the given local index. GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const; //! Return the process IDs and corresponding local IDs for the given global IDs. LookupStatus getRemoteIndexList(const Teuchos::ArrayView &GIDList, const Teuchos::ArrayView &nodeIDList, const Teuchos::ArrayView &LIDList) const; //! Return the process IDs for the given global IDs. LookupStatus getRemoteIndexList(const Teuchos::ArrayView &GIDList, const Teuchos::ArrayView &nodeIDList) const; //! Return a view of the global indices owned by this node. Teuchos::ArrayView getLocalElementList() const; //! Return a view of the global indices owned by this process. global_indices_array_device_type getMyGlobalIndicesDevice() const; //@} //! @name Boolean tests //@{ //! True if the local index is valid for this Map on this node, else false. bool isNodeLocalElement(LocalOrdinal localIndex) const; //! True if the global index is found in this Map on this node, else false. bool isNodeGlobalElement(GlobalOrdinal globalIndex) const; //! True if this Map is distributed contiguously, else false. bool isContiguous() const; //! Whether this Map is globally distributed or locally replicated. bool isDistributed() const; //! True if and only if map is compatible with this Map. bool isCompatible(const Map &map) const; //! True if and only if map is identical to this Map. bool isSameAs(const Map &map) const; //@} //! @name //@{ //! Get this Map's Comm object. Teuchos::RCP > getComm() const; //@} //! @name //@{ //! Return a simple one-line description of this object. std::string description() const; //! Print this object with the given verbosity level to the given FancyOStream. void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const; RCP > removeEmptyProcesses() const; RCP > replaceCommWithSubset(const Teuchos::RCP > &newComm) const; //@} //! @name Xpetra specific //@{ //! TpetraMap constructor to wrap a Tpetra::Map object TpetraMap(const Teuchos::RCP > &map); //! Get the library used by this object (Tpetra or Epetra?) UnderlyingLib lib() const; //! Get the underlying Tpetra map RCP > getTpetra_Map() const; #ifdef HAVE_XPETRA_TPETRA using local_map_type = typename Map::local_map_type; /// \brief Get the local Map for Kokkos kernels. local_map_type getLocalMap() const; #endif //@} protected: RCP > map_; }; // TpetraMap class template const Tpetra::Map &toTpetra(const Map &map) { // TODO: throw exception const TpetraMap &tpetraMap = dynamic_cast &>(*map.getMap()); return *tpetraMap.getTpetra_Map(); } template const RCP > toTpetra(const RCP > &map) { typedef TpetraMap TpetraMapClass; if (map != Teuchos::null) { XPETRA_RCP_DYNAMIC_CAST(const TpetraMapClass, map->getMap(), tpetraMap, "toTpetra"); return tpetraMap->getTpetra_Map(); } return Teuchos::null; } // In some cases (for instance, in MueLu adapter to Tpetra operator), we need to return a reference. This is only possible if // we assume that the map argument is nonzero template const RCP > toTpetraNonZero(const RCP > &map) { TEUCHOS_TEST_FOR_EXCEPTION(map.is_null(), std::invalid_argument, "map must be nonzero"); typedef TpetraMap TpetraMapClass; XPETRA_RCP_DYNAMIC_CAST(const TpetraMapClass, map->getMap(), tpetraMap, "toTpetra"); return tpetraMap->getTpetra_Map(); } template const RCP > toXpetra(const RCP > &map) { if (!map.is_null()) return rcp(new TpetraMap(map)); return Teuchos::null; } template const RCP > toXpetraNonConst(const RCP > &map) { if (!map.is_null()) return rcp(new TpetraMap(map)); return Teuchos::null; } namespace useTpetra { //! Non-member function to create a locally replicated Map with a specified node. template Teuchos::RCP > createLocalMapWithNode(size_t numElements, const Teuchos::RCP > &comm) { XPETRA_MONITOR("useTpetra::createLocalMapWithNode"); return rcp(new TpetraMap(Tpetra::createLocalMapWithNode(numElements, comm))); } //! Non-member function to create a (potentially) non-uniform, contiguous Map with the default node. template Teuchos::RCP::node_type> > createContigMap(global_size_t numElements, size_t localNumElements, const Teuchos::RCP > &comm) { XPETRA_MONITOR("useTpetra::createContigMap"); return rcp(new TpetraMap::node_type>(Tpetra::createContigMap::node_type>(numElements, localNumElements, comm))); } //! Non-member function to create a (potentially) non-uniform, contiguous Map with a user-specified node. template Teuchos::RCP > createContigMapWithNode(global_size_t numElements, size_t localNumElements, const Teuchos::RCP > &comm) { XPETRA_MONITOR("useTpetra::createContigMap"); return rcp(new TpetraMap(Tpetra::createContigMapWithNode(numElements, localNumElements, comm))); } } // namespace useTpetra #define XPETRA_TPETRAMAP_SHORT } // namespace Xpetra #endif // XPETRA_TPETRAMAP_DECL_HPP