42 #ifndef TPETRA_DETAILS_LOCALMAP_HPP 43 #define TPETRA_DETAILS_LOCALMAP_HPP 49 #include "Tpetra_Details_FixedHashTable.hpp" 69 template<
class LocalOrdinal,
class GlobalOrdinal,
class DeviceType>
72 typedef LocalOrdinal local_ordinal_type;
73 typedef GlobalOrdinal global_ordinal_type;
74 typedef DeviceType device_type;
78 myMinGid_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
79 myMaxGid_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
80 firstContiguousGid_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
81 lastContiguousGid_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
82 numLocalElements_ (0),
85 LocalMap (const ::Tpetra::Details::FixedHashTable<GlobalOrdinal, LocalOrdinal, DeviceType>& glMap,
86 const ::Kokkos::View<const GlobalOrdinal*, ::Kokkos::LayoutLeft, DeviceType>& lgMap,
87 const GlobalOrdinal indexBase,
88 const GlobalOrdinal myMinGid,
89 const GlobalOrdinal myMaxGid,
90 const GlobalOrdinal firstContiguousGid,
91 const GlobalOrdinal lastContiguousGid,
92 const LocalOrdinal numLocalElements,
93 const bool contiguous) :
96 indexBase_ (indexBase),
99 firstContiguousGid_ (firstContiguousGid),
100 lastContiguousGid_ (lastContiguousGid),
101 numLocalElements_ (numLocalElements),
102 contiguous_ (contiguous)
107 return numLocalElements_;
129 KOKKOS_INLINE_FUNCTION LocalOrdinal
132 if (numLocalElements_ == 0) {
133 return ::Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
135 return static_cast<LocalOrdinal
> (numLocalElements_ - 1);
150 KOKKOS_INLINE_FUNCTION LocalOrdinal
154 if (globalIndex < myMinGid_ || globalIndex > myMaxGid_) {
155 return ::Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
157 return static_cast<LocalOrdinal
> (globalIndex - myMinGid_);
159 else if (globalIndex >= firstContiguousGid_ &&
160 globalIndex <= lastContiguousGid_) {
161 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGid_);
166 return glMap_.
get (globalIndex);
171 KOKKOS_INLINE_FUNCTION GlobalOrdinal
175 return ::Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
181 return lgMap_(localIndex);
202 ::Kokkos::View<const GlobalOrdinal*, ::Kokkos::LayoutLeft, DeviceType> lgMap_;
203 GlobalOrdinal indexBase_;
204 GlobalOrdinal myMinGid_;
205 GlobalOrdinal myMaxGid_;
206 GlobalOrdinal firstContiguousGid_;
207 GlobalOrdinal lastContiguousGid_;
208 LocalOrdinal numLocalElements_;
215 #endif // TPETRA_DETAILS_LOCALMAP_HPP KOKKOS_INLINE_FUNCTION LocalOrdinal getMinLocalIndex() const
The minimum local index.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getIndexBase() const
The (global) index base.
"Local" part of Map suitable for Kokkos kernels.
Implementation details of Tpetra.
KOKKOS_INLINE_FUNCTION LocalOrdinal getMaxLocalIndex() const
The maximum local index.
KOKKOS_INLINE_FUNCTION ValueType get(const KeyType &key) const
Get the value corresponding to the given key.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getMinGlobalIndex() const
The minimum global index on the calling process.
KOKKOS_INLINE_FUNCTION bool isContiguous() const
Whether the Map is (locally) contiguous.
KOKKOS_INLINE_FUNCTION LocalOrdinal getLocalElement(const GlobalOrdinal globalIndex) const
Get the local index corresponding to the given global index.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getGlobalElement(const LocalOrdinal localIndex) const
Get the global index corresponding to the given local index.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getMaxGlobalIndex() const
The maximum global index on the calling process.
KOKKOS_INLINE_FUNCTION LocalOrdinal getNodeNumElements() const
The number of indices that live on the calling process.