46 #ifndef XPETRA_TPETRAMAP_HPP 47 #define XPETRA_TPETRAMAP_HPP 53 #include <Tpetra_Map.hpp> 63 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
toTpetra(
const RCP<
const Map< LocalOrdinal, GlobalOrdinal, Node > > &);
69 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
toXpetra(
const RCP<
const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &);
73 template <
class LocalOrdinal,
class GlobalOrdinal = LocalOrdinal,
class Node = Kokkos::DefaultNode::DefaultNodeType>
75 :
public virtual Map<LocalOrdinal,GlobalOrdinal,Node> {
84 :
map_(Teuchos::rcp(new Tpetra::
Map< LocalOrdinal, GlobalOrdinal, Node >(numGlobalElements, indexBase, comm,
toTpetra(lg), node))) { }
87 TpetraMap(
global_size_t numGlobalElements,
size_t numLocalElements, GlobalOrdinal indexBase,
const Teuchos::RCP<
const Teuchos::Comm< int > > &comm,
const Teuchos::RCP< Node > &node=Kokkos::Details::getNode<Node>())
88 :
map_(Teuchos::rcp(new Tpetra::
Map< LocalOrdinal, GlobalOrdinal, Node >(numGlobalElements, numLocalElements, indexBase, comm, node))) { }
91 TpetraMap(
global_size_t numGlobalElements,
const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase,
const Teuchos::RCP<
const Teuchos::Comm< int > > &comm,
const Teuchos::RCP< Node > &node=Kokkos::Details::getNode<Node>())
92 :
map_(Teuchos::rcp(new Tpetra::
Map< LocalOrdinal, GlobalOrdinal, Node >(numGlobalElements, elementList, indexBase, comm, node))) { }
136 LookupStatus getRemoteIndexList(
const Teuchos::ArrayView< const GlobalOrdinal > &GIDList,
const Teuchos::ArrayView< int > &nodeIDList,
const Teuchos::ArrayView< LocalOrdinal > &LIDList)
const {
XPETRA_MONITOR(
"TpetraMap::getRemoteIndexList");
return toXpetra(
map_->getRemoteIndexList(GIDList, nodeIDList, LIDList)); }
187 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const {
XPETRA_MONITOR(
"TpetraMap::describe");
map_->describe(out, verbLevel); }
192 RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
replaceCommWithSubset (
const Teuchos::RCP<
const Teuchos::Comm<int> >& newComm)
const {
202 TpetraMap(
const Teuchos::RCP<
const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node > > &map)
209 const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &
getTpetra_Map()
const {
return map_; }
215 RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
map_;
220 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
227 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
230 if (map != Teuchos::null) {
232 return tpetraMap->getTpetra_Map();
234 return Teuchos::null;
239 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
241 TEUCHOS_TEST_FOR_EXCEPTION(map.is_null(), std::invalid_argument,
"map must be nonzero");
244 return tpetraMap->getTpetra_Map();
247 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
248 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
toXpetra(
const RCP<
const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map) {
249 if (map != Teuchos::null)
251 return Teuchos::null;
256 namespace useTpetra {
259 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
260 Teuchos::RCP< const TpetraMap<LocalOrdinal,GlobalOrdinal,Node> >
261 createLocalMapWithNode(
size_t numElements,
const Teuchos::RCP<
const Teuchos::Comm< int > > &comm,
const Teuchos::RCP< Node > &node) {
268 template <
class LocalOrdinal,
class GlobalOrdinal>
269 Teuchos::RCP< const TpetraMap<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
277 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
278 Teuchos::RCP< const TpetraMap<LocalOrdinal,GlobalOrdinal,Node> >
280 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm,
const Teuchos::RCP< Node > &node) {
290 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
297 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
303 #define XPETRA_TPETRAMAP_SHORT 304 #endif // XPETRA_TPETRAMAP_HPP Teuchos::RCP< const TpetraMap< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node)
Non-member function to create a locally replicated Map with a specified node.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
TpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=Kokkos::Details::getNode< Node >())
Constructor with Tpetra-defined contiguous uniform distribution.
bool operator!=(const Xpetra::TpetraMap< LocalOrdinal, GlobalOrdinal, Node > &map1, const Xpetra::TpetraMap< LocalOrdinal, GlobalOrdinal, Node > &map2)
Returns true if map is not identical to this map. Implemented in TpetraMap::isSameAs().
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this node.
const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & toTpetraNonZero(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
RCP< const CrsGraph< int, int > > toXpetra(const Epetra_CrsGraph &g)
std::string description() const
Return a simple one-line description of this object.
TpetraMap(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=Kokkos::Details::getNode< Node >())
Constructor with a user-defined contiguous distribution.
Teuchos::RCP< const TpetraMap< LocalOrdinal, GlobalOrdinal, Node > > createContigMapWithNode(global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node)
Non-member function to create a (potentially) non-uniform, contiguous Map with a user-specified node...
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
bool isNodeLocalElement(LocalOrdinal localIndex) const
True if the local index is valid for this Map on this node, else false.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print this object with the given verbosity level to the given FancyOStream.
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
Return the process IDs and corresponding local IDs for the given global IDs.
Teuchos::RCP< const TpetraMap< LocalOrdinal, GlobalOrdinal, Kokkos::DefaultNode::DefaultNodeType > > createContigMap(global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member function to create a (potentially) non-uniform, contiguous Map with the default node...
const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getTpetra_Map() const
Get the underlying Tpetra map.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
const Teuchos::RCP< Node > getNode() const
Get this Map's Node object.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
TpetraMap(const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
TpetraMap constructor to wrap a Tpetra::Map object.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
TpetraMap(global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=Kokkos::Details::getNode< Node >())
Constructor with user-defined arbitrary (possibly noncontiguous) distribution.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const
Return the process IDs for the given global IDs.
const Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
size_t global_size_t
Global size_t object.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
GlobalOrdinal getIndexBase() const
The index base for this Map.
bool operator==(const Xpetra::TpetraMap< LocalOrdinal, GlobalOrdinal, Node > &map1, const Xpetra::TpetraMap< LocalOrdinal, GlobalOrdinal, Node > &map2)
Returns true if map is identical to this map. Implemented in TpetraMap::isSameAs().
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
size_t getNodeNumElements() const
The number of elements belonging to the calling node.
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > map_
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
True if the global index is found in this Map on this node, else false.
#define XPETRA_MONITOR(funcName)
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > > &graph)
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.