// @HEADER // ***************************************************************************** // Xpetra: A linear algebra interface package // // Copyright 2012 NTESS and the Xpetra contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef XPETRA_TPETRAMAP_DEF_HPP #define XPETRA_TPETRAMAP_DEF_HPP #include "Xpetra_TpetraMap_decl.hpp" namespace Xpetra { //! @name Constructor/Destructor Methods //@{ template TpetraMap:: TpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP > &comm, LocalGlobal lg) : map_(Teuchos::rcp(new Tpetra::Map(numGlobalElements, indexBase, comm, toTpetra(lg)))) {} //! Constructor with a user-defined contiguous distribution. template TpetraMap:: TpetraMap(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP > &comm) : map_(Teuchos::rcp(new Tpetra::Map(numGlobalElements, numLocalElements, indexBase, comm))) {} //! Constructor with user-defined arbitrary (possibly noncontiguous) distribution. template TpetraMap:: TpetraMap(global_size_t numGlobalElements, const Teuchos::ArrayView &elementList, GlobalOrdinal indexBase, const Teuchos::RCP > &comm) : map_(Teuchos::rcp(new Tpetra::Map(numGlobalElements, elementList, indexBase, comm))) {} #ifdef HAVE_XPETRA_TPETRA //! Constructor with user-defined arbitrary (possibly noncontiguous) distribution passed as a Kokkos::View. template TpetraMap:: TpetraMap(global_size_t numGlobalElements, const Kokkos::View &indexList, GlobalOrdinal indexBase, const Teuchos::RCP > &comm) : map_(Teuchos::rcp(new Tpetra::Map(numGlobalElements, indexList, indexBase, comm))) {} #endif //! Destructor. template TpetraMap::~TpetraMap() {} //@} template global_size_t TpetraMap::getGlobalNumElements() const { XPETRA_MONITOR("TpetraMap::getGlobalNumElements"); return map_->getGlobalNumElements(); } template size_t TpetraMap::getLocalNumElements() const { XPETRA_MONITOR("TpetraMap::getLocalNumElements"); return map_->getLocalNumElements(); } template GlobalOrdinal TpetraMap::getIndexBase() const { XPETRA_MONITOR("TpetraMap::getIndexBase"); return map_->getIndexBase(); } template LocalOrdinal TpetraMap::getMinLocalIndex() const { XPETRA_MONITOR("TpetraMap::getMinLocalIndex"); return map_->getMinLocalIndex(); } template LocalOrdinal TpetraMap::getMaxLocalIndex() const { XPETRA_MONITOR("TpetraMap::getMaxLocalIndex"); return map_->getMaxLocalIndex(); } template GlobalOrdinal TpetraMap::getMinGlobalIndex() const { XPETRA_MONITOR("TpetraMap::getMinGlobalIndex"); return map_->getMinGlobalIndex(); } template GlobalOrdinal TpetraMap::getMaxGlobalIndex() const { XPETRA_MONITOR("TpetraMap::getMaxGlobalIndex"); return map_->getMaxGlobalIndex(); } template GlobalOrdinal TpetraMap::getMinAllGlobalIndex() const { XPETRA_MONITOR("TpetraMap::getMinAllGlobalIndex"); return map_->getMinAllGlobalIndex(); } template GlobalOrdinal TpetraMap::getMaxAllGlobalIndex() const { XPETRA_MONITOR("TpetraMap::getMaxAllGlobalIndex"); return map_->getMaxAllGlobalIndex(); } template LocalOrdinal TpetraMap::getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("TpetraMap::getLocalElement"); return map_->getLocalElement(globalIndex); } template GlobalOrdinal TpetraMap::getGlobalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("TpetraMap::getGlobalElement"); return map_->getGlobalElement(localIndex); } template LookupStatus TpetraMap::getRemoteIndexList(const Teuchos::ArrayView &GIDList, const Teuchos::ArrayView &nodeIDList, const Teuchos::ArrayView &LIDList) const { XPETRA_MONITOR("TpetraMap::getRemoteIndexList"); return toXpetra(map_->getRemoteIndexList(GIDList, nodeIDList, LIDList)); } template LookupStatus TpetraMap::getRemoteIndexList(const Teuchos::ArrayView &GIDList, const Teuchos::ArrayView &nodeIDList) const { XPETRA_MONITOR("TpetraMap::getRemoteIndexList"); return toXpetra(map_->getRemoteIndexList(GIDList, nodeIDList)); } template Teuchos::ArrayView TpetraMap::getLocalElementList() const { XPETRA_MONITOR("TpetraMap::getLocalElementList"); return map_->getLocalElementList(); } template typename Map::global_indices_array_device_type TpetraMap::getMyGlobalIndicesDevice() const { XPETRA_MONITOR("TpetraMap::getMyGlobalIndicesDevice"); return map_->getMyGlobalIndicesDevice(); } template bool TpetraMap::isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("TpetraMap::isNodeLocalElement"); return map_->isNodeLocalElement(localIndex); } template bool TpetraMap::isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("TpetraMap::isNodeGlobalElement"); return map_->isNodeGlobalElement(globalIndex); } template bool TpetraMap::isContiguous() const { XPETRA_MONITOR("TpetraMap::isContiguous"); return map_->isContiguous(); } template bool TpetraMap::isDistributed() const { XPETRA_MONITOR("TpetraMap::isDistributed"); return map_->isDistributed(); } template bool TpetraMap::isCompatible(const Map &map) const { XPETRA_MONITOR("TpetraMap::isCompatible"); return map_->isCompatible(toTpetra(map)); } template bool TpetraMap::isSameAs(const Map &map) const { XPETRA_MONITOR("TpetraMap::isSameAs"); return map_->isSameAs(toTpetra(map)); } template Teuchos::RCP > TpetraMap::getComm() const { XPETRA_MONITOR("TpetraMap::getComm"); return map_->getComm(); } template std::string TpetraMap::description() const { XPETRA_MONITOR("TpetraMap::description"); return map_->description(); } template void TpetraMap::describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const { XPETRA_MONITOR("TpetraMap::describe"); map_->describe(out, verbLevel); } template RCP > TpetraMap::removeEmptyProcesses() const { return toXpetra(map_->removeEmptyProcesses()); } template RCP > TpetraMap::replaceCommWithSubset(const Teuchos::RCP > &newComm) const { return toXpetra(map_->replaceCommWithSubset(newComm)); } template TpetraMap::TpetraMap(const Teuchos::RCP > &map) : map_(map) {} template UnderlyingLib TpetraMap::lib() const { return UseTpetra; } template RCP > TpetraMap::getTpetra_Map() const { return map_; } #ifdef HAVE_XPETRA_TPETRA template typename Map::local_map_type TpetraMap::getLocalMap() const { return map_->getLocalMap(); } #endif #ifdef HAVE_XPETRA_EPETRA #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) // specialization for Tpetra Map on EpetraNode and GO=int template <> class TpetraMap : public virtual Map { public: typedef int GlobalOrdinal; typedef int LocalOrdinal; typedef EpetraNode Node; //! @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) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraMap).name(), typeid(TpetraMap).name(), "int", typeid(EpetraNode).name()); } //! Constructor with a user-defined contiguous distribution. TpetraMap(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP > &comm) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraMap).name(), typeid(TpetraMap).name(), "int", typeid(EpetraNode).name()); } //! Constructor with user-defined arbitrary (possibly noncontiguous) distribution. TpetraMap(global_size_t numGlobalElements, const Teuchos::ArrayView &elementList, GlobalOrdinal indexBase, const Teuchos::RCP > &comm) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraMap).name(), typeid(TpetraMap).name(), "int", typeid(EpetraNode).name()); } //! Destructor. ~TpetraMap() {} //@} //! @name Attributes //@{ //! The number of elements in this Map. global_size_t getGlobalNumElements() const { return 0; } //! The number of elements belonging to the calling node. size_t getLocalNumElements() const { return 0; } //! The index base for this Map. GlobalOrdinal getIndexBase() const { return 0; } //! The minimum local index. LocalOrdinal getMinLocalIndex() const { return 0; } //! The maximum local index on the calling process. LocalOrdinal getMaxLocalIndex() const { return 0; } //! The minimum global index owned by the calling process. GlobalOrdinal getMinGlobalIndex() const { return 0; } //! The maximum global index owned by the calling process. GlobalOrdinal getMaxGlobalIndex() const { return 0; } //! The minimum global index over all processes in the communicator. GlobalOrdinal getMinAllGlobalIndex() const { return 0; } //! The maximum global index over all processes in the communicator. GlobalOrdinal getMaxAllGlobalIndex() const { return 0; } //! The local index corresponding to the given global index. LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { return 0; } //! The global index corresponding to the given local index. GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const { return 0; } //! 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 Xpetra::IDNotPresent; } //! Return the process IDs for the given global IDs. LookupStatus getRemoteIndexList(const Teuchos::ArrayView &GIDList, const Teuchos::ArrayView &nodeIDList) const { return Xpetra::IDNotPresent; } //! Return a view of the global indices owned by this node. Teuchos::ArrayView getLocalElementList() const { return Teuchos::ArrayView(); } //@} //! @name Boolean tests //@{ //! True if the local index is valid for this Map on this node, else false. bool isNodeLocalElement(LocalOrdinal localIndex) const { return false; } //! True if the global index is found in this Map on this node, else false. bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { return false; } //! True if this Map is distributed contiguously, else false. bool isContiguous() const { return false; } //! Whether this Map is globally distributed or locally replicated. bool isDistributed() const { return false; } //! True if and only if map is compatible with this Map. bool isCompatible(const Map &map) const { return false; } //! True if and only if map is identical to this Map. bool isSameAs(const Map &map) const { return false; } //@} //! @name //@{ //! Get this Map's Comm object. Teuchos::RCP > getComm() const { return Teuchos::null; } //@} //! @name //@{ //! Return a simple one-line description of this object. std::string description() const { return std::string(""); } //! 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 { return Teuchos::null; } RCP > replaceCommWithSubset(const Teuchos::RCP > &newComm) const { return Teuchos::null; } //@} //! @name Xpetra specific //@{ //! TpetraMap constructor to wrap a Tpetra::Map object TpetraMap(const Teuchos::RCP > &map) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraMap).name(), typeid(TpetraMap).name(), "int", typeid(EpetraNode).name()); } //! Get the library used by this object (Tpetra or Epetra?) UnderlyingLib lib() const { return UseTpetra; } //! Get the underlying Tpetra map RCP > getTpetra_Map() const { return Teuchos::null; } #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 { return local_map_type(); } #endif //@} }; // TpetraMap class (specialization for GO=int and NO=EpetraNode) #endif #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \ (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG)))) // specialization for Tpetra Map on EpetraNode and GO=int template <> class TpetraMap : public virtual Map { public: typedef long long GlobalOrdinal; typedef int LocalOrdinal; typedef EpetraNode Node; //! @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) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraMap).name(), typeid(TpetraMap).name(), "long long", typeid(EpetraNode).name()); } //! Constructor with a user-defined contiguous distribution. TpetraMap(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP > &comm) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraMap).name(), typeid(TpetraMap).name(), "long long", typeid(EpetraNode).name()); } //! Constructor with user-defined arbitrary (possibly noncontiguous) distribution. TpetraMap(global_size_t numGlobalElements, const Teuchos::ArrayView &elementList, GlobalOrdinal indexBase, const Teuchos::RCP > &comm) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraMap).name(), typeid(TpetraMap).name(), "long long", typeid(EpetraNode).name()); } //! Destructor. ~TpetraMap() {} //@} //! @name Attributes //@{ //! The number of elements in this Map. global_size_t getGlobalNumElements() const { return 0; } //! The number of elements belonging to the calling node. size_t getLocalNumElements() const { return 0; } //! The index base for this Map. GlobalOrdinal getIndexBase() const { return 0; } //! The minimum local index. LocalOrdinal getMinLocalIndex() const { return 0; } //! The maximum local index on the calling process. LocalOrdinal getMaxLocalIndex() const { return 0; } //! The minimum global index owned by the calling process. GlobalOrdinal getMinGlobalIndex() const { return 0; } //! The maximum global index owned by the calling process. GlobalOrdinal getMaxGlobalIndex() const { return 0; } //! The minimum global index over all processes in the communicator. GlobalOrdinal getMinAllGlobalIndex() const { return 0; } //! The maximum global index over all processes in the communicator. GlobalOrdinal getMaxAllGlobalIndex() const { return 0; } //! The local index corresponding to the given global index. LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { return 0; } //! The global index corresponding to the given local index. GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const { return 0; } //! 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 Xpetra::IDNotPresent; } //! Return the process IDs for the given global IDs. LookupStatus getRemoteIndexList(const Teuchos::ArrayView &GIDList, const Teuchos::ArrayView &nodeIDList) const { return Xpetra::IDNotPresent; } //! Return a view of the global indices owned by this node. Teuchos::ArrayView getLocalElementList() const { return Teuchos::ArrayView(); } //@} //! @name Boolean tests //@{ //! True if the local index is valid for this Map on this node, else false. bool isNodeLocalElement(LocalOrdinal localIndex) const { return false; } //! True if the global index is found in this Map on this node, else false. bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { return false; } //! True if this Map is distributed contiguously, else false. bool isContiguous() const { return false; } //! Whether this Map is globally distributed or locally replicated. bool isDistributed() const { return false; } //! True if and only if map is compatible with this Map. bool isCompatible(const Map &map) const { return false; } //! True if and only if map is identical to this Map. bool isSameAs(const Map &map) const { return false; } //@} //! @name //@{ //! Get this Map's Comm object. Teuchos::RCP > getComm() const { return Teuchos::null; } //@} //! @name //@{ //! Return a simple one-line description of this object. std::string description() const { return std::string(""); } //! 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 { return Teuchos::null; } RCP > replaceCommWithSubset(const Teuchos::RCP > &newComm) const { return Teuchos::null; } //@} //! @name Xpetra specific //@{ //! TpetraMap constructor to wrap a Tpetra::Map object TpetraMap(const Teuchos::RCP > &map) { XPETRA_TPETRA_ETI_EXCEPTION(typeid(TpetraMap).name(), typeid(TpetraMap).name(), "long long", typeid(EpetraNode).name()); } //! Get the library used by this object (Tpetra or Epetra?) UnderlyingLib lib() const { return UseTpetra; } //! Get the underlying Tpetra map RCP > getTpetra_Map() const { return Teuchos::null; } #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 { // We will never be here, this is a stub class return local_map_type(); } #endif //@} }; // TpetraMap class (specialization for GO=int and NO=EpetraNode) #endif #endif // HAVE_XPETRA_EPETRA } // namespace Xpetra // TODO: remove? //! Returns true if \c map is identical to this map. Implemented in TpetraMap::isSameAs(). template bool operator==(const Xpetra::TpetraMap &map1, const Xpetra::TpetraMap &map2) { XPETRA_MONITOR("TpetraMap==TpetraMap"); return map1.isSameAs(map2); } //! Returns true if \c map is not identical to this map. Implemented in TpetraMap::isSameAs(). template bool operator!=(const Xpetra::TpetraMap &map1, const Xpetra::TpetraMap &map2) { XPETRA_MONITOR("TpetraMap!=TpetraMap"); return !map1.isSameAs(map2); } #endif // XPETRA_TPETRAMAP_DEF_HPP