Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_TpetraMap_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Xpetra: A linear algebra interface package
4 //
5 // Copyright 2012 NTESS and the Xpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef XPETRA_TPETRAMAP_DECL_HPP
11 #define XPETRA_TPETRAMAP_DECL_HPP
12 
13 /* this file is automatically generated - do not edit (see script/tpetra.py) */
14 
16 
17 #include <Tpetra_Map.hpp>
18 
19 #include "Xpetra_Map_decl.hpp"
20 #include "Xpetra_Utils.hpp"
21 
22 #include "Xpetra_Exceptions.hpp"
23 
24 namespace Xpetra {
25 
26 template <class LocalOrdinal, class GlobalOrdinal, class Node>
27 const RCP<Map<LocalOrdinal, GlobalOrdinal, Node> > toXpetraNonConst(const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > &map);
28 
29 template <class LocalOrdinal,
30  class GlobalOrdinal,
31  class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
32 class TpetraMap
33  : public virtual Map<LocalOrdinal, GlobalOrdinal, Node> {
34  public:
36 
38 
39 
41 
42  TpetraMap(global_size_t numGlobalElements,
43  GlobalOrdinal indexBase,
44  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
46 
48 
49  TpetraMap(global_size_t numGlobalElements,
50  size_t numLocalElements,
51  GlobalOrdinal indexBase,
52  const Teuchos::RCP<const Teuchos::Comm<int> > &comm);
53 
55 
56  TpetraMap(global_size_t numGlobalElements,
57  const Teuchos::ArrayView<const GlobalOrdinal> &elementList,
58  GlobalOrdinal indexBase,
59  const Teuchos::RCP<const Teuchos::Comm<int> > &comm);
60 
61 #ifdef HAVE_XPETRA_TPETRA
62  TpetraMap(global_size_t numGlobalElements,
64  const Kokkos::View<const GlobalOrdinal *, typename Node::device_type> &indexList,
65  GlobalOrdinal indexBase,
66  const Teuchos::RCP<const Teuchos::Comm<int> > &comm);
67 #endif
68 
70  ~TpetraMap();
71 
73 
74 
77 
79  size_t getLocalNumElements() const;
80 
82  GlobalOrdinal getIndexBase() const;
83 
85  LocalOrdinal getMinLocalIndex() const;
86 
88  LocalOrdinal getMaxLocalIndex() const;
89 
91  GlobalOrdinal getMinGlobalIndex() const;
92 
94  GlobalOrdinal getMaxGlobalIndex() const;
95 
97  GlobalOrdinal getMinAllGlobalIndex() const;
98 
100  GlobalOrdinal getMaxAllGlobalIndex() const;
101 
103  LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const;
104 
106  GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const;
107 
109  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList, const Teuchos::ArrayView<int> &nodeIDList, const Teuchos::ArrayView<LocalOrdinal> &LIDList) const;
110 
112  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList, const Teuchos::ArrayView<int> &nodeIDList) const;
113 
115  Teuchos::ArrayView<const GlobalOrdinal> getLocalElementList() const;
116 
119 
121 
123 
124 
126  bool isNodeLocalElement(LocalOrdinal localIndex) const;
127 
129  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const;
130 
132  bool isContiguous() const;
133 
135  bool isDistributed() const;
136 
139 
141  bool isSameAs(const Map<LocalOrdinal, GlobalOrdinal, Node> &map) const;
142 
144 
146 
147 
149  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
150 
152 
154 
155 
157  std::string description() const;
158 
160  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const;
161 
162  RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > removeEmptyProcesses() const;
163  RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int> > &newComm) const;
164 
166 
168 
169 
171  TpetraMap(const Teuchos::RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > &map);
172 
174  UnderlyingLib lib() const;
175 
177  RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > getTpetra_Map() const;
178 
179 #ifdef HAVE_XPETRA_TPETRA
182  local_map_type getLocalMap() const;
183 #endif
184 
186 
187  protected:
188  RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > map_;
189 
190 }; // TpetraMap class
191 
192 template <class LocalOrdinal, class GlobalOrdinal, class Node>
193 const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> &toTpetra(const Map<LocalOrdinal, GlobalOrdinal, Node> &map) {
194  // TODO: throw exception
196  return *tpetraMap.getTpetra_Map();
197 }
198 
199 template <class LocalOrdinal, class GlobalOrdinal, class Node>
200 const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > toTpetra(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
201  typedef TpetraMap<LocalOrdinal, GlobalOrdinal, Node> TpetraMapClass;
202  if (map != Teuchos::null) {
203  XPETRA_RCP_DYNAMIC_CAST(const TpetraMapClass, map->getMap(), tpetraMap, "toTpetra");
204  return tpetraMap->getTpetra_Map();
205  }
206  return Teuchos::null;
207 }
208 
209 // In some cases (for instance, in MueLu adapter to Tpetra operator), we need to return a reference. This is only possible if
210 // we assume that the map argument is nonzero
211 template <class LocalOrdinal, class GlobalOrdinal, class Node>
212 const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > toTpetraNonZero(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
213  TEUCHOS_TEST_FOR_EXCEPTION(map.is_null(), std::invalid_argument, "map must be nonzero");
214  typedef TpetraMap<LocalOrdinal, GlobalOrdinal, Node> TpetraMapClass;
215  XPETRA_RCP_DYNAMIC_CAST(const TpetraMapClass, map->getMap(), tpetraMap, "toTpetra");
216  return tpetraMap->getTpetra_Map();
217 }
218 
219 template <class LocalOrdinal, class GlobalOrdinal, class Node>
220 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > toXpetra(const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
221  if (!map.is_null())
223 
224  return Teuchos::null;
225 }
226 
227 template <class LocalOrdinal, class GlobalOrdinal, class Node>
228 const RCP<Map<LocalOrdinal, GlobalOrdinal, Node> > toXpetraNonConst(const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
229  if (!map.is_null())
231 
232  return Teuchos::null;
233 }
234 
235 namespace useTpetra {
236 
238 template <class LocalOrdinal, class GlobalOrdinal, class Node>
239 Teuchos::RCP<const TpetraMap<LocalOrdinal, GlobalOrdinal, Node> >
240 createLocalMapWithNode(size_t numElements, const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
241  XPETRA_MONITOR("useTpetra::createLocalMapWithNode");
242 
243  return rcp(new TpetraMap<LocalOrdinal, GlobalOrdinal, Node>(Tpetra::createLocalMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, comm)));
244 }
245 
247 template <class LocalOrdinal, class GlobalOrdinal>
248 Teuchos::RCP<const TpetraMap<LocalOrdinal, GlobalOrdinal, typename Tpetra::Map<>::node_type> >
249 createContigMap(global_size_t numElements, size_t localNumElements, const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
250  XPETRA_MONITOR("useTpetra::createContigMap");
251 
252  return rcp(new TpetraMap<LocalOrdinal, GlobalOrdinal, typename Tpetra::Map<>::node_type>(Tpetra::createContigMap<LocalOrdinal, GlobalOrdinal, typename Tpetra::Map<>::node_type>(numElements, localNumElements, comm)));
253 }
254 
256 template <class LocalOrdinal, class GlobalOrdinal, class Node>
257 Teuchos::RCP<const TpetraMap<LocalOrdinal, GlobalOrdinal, Node> >
258 createContigMapWithNode(global_size_t numElements, size_t localNumElements,
259  const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
260  XPETRA_MONITOR("useTpetra::createContigMap");
261  return rcp(new TpetraMap<LocalOrdinal, GlobalOrdinal, Node>(Tpetra::createContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
262 }
263 } // namespace useTpetra
264 
265 #define XPETRA_TPETRAMAP_SHORT
266 } // namespace Xpetra
267 #endif // XPETRA_TPETRAMAP_DECL_HPP
std::string description() const
Return a simple one-line description of this object.
Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
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.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
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.
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.
size_t getLocalNumElements() const
The number of elements belonging to the calling node.
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
LocalOrdinal getMinLocalIndex() const
The minimum local index.
Map< LocalOrdinal, GlobalOrdinal, Node >::global_indices_array_device_type global_indices_array_device_type
Teuchos::RCP< const TpetraMap< LocalOrdinal, GlobalOrdinal, Node > > createContigMapWithNode(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 a user-specified node...
global_indices_array_device_type getMyGlobalIndicesDevice() const
Return a view of the global indices owned by this process.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a view of the global indices owned by this node.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > toTpetraNonZero(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
size_t global_size_t
Global size_t object.
Teuchos::RCP< const TpetraMap< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member function to create a locally replicated Map with a specified node.
GlobalOrdinal getIndexBase() const
The index base for this Map.
RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Map() const
Get the underlying Tpetra map.
Kokkos::View< const global_ordinal_type *, typename Node::device_type > global_indices_array_device_type
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
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.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
True if the global index is found in this Map on this node, else false.
#define XPETRA_MONITOR(funcName)
Teuchos::RCP< const TpetraMap< LocalOrdinal, GlobalOrdinal, typename Tpetra::Map<>::node_type > > 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...
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > map_
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map&#39;s communicator with a subset communicator.
const RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > toXpetraNonConst(const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
TpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed)
Constructor with Tpetra-defined contiguous uniform distribution.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)