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 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_TPETRAMAP_DECL_HPP
47 #define XPETRA_TPETRAMAP_DECL_HPP
48 
49 /* this file is automatically generated - do not edit (see script/tpetra.py) */
50 
52 
53 #include <Tpetra_Map.hpp>
54 
55 #include "Xpetra_Map_decl.hpp"
56 #include "Xpetra_Utils.hpp"
57 
58 #include "Xpetra_Exceptions.hpp"
59 
60 namespace Xpetra {
61 
62 template <class LocalOrdinal, class GlobalOrdinal, class Node>
63 const RCP<Map<LocalOrdinal, GlobalOrdinal, Node> > toXpetraNonConst(const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > &map);
64 
65 template <class LocalOrdinal,
66  class GlobalOrdinal,
67  class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
68 class TpetraMap
69  : public virtual Map<LocalOrdinal, GlobalOrdinal, Node> {
70  public:
72 
74 
75 
77 
78  TpetraMap(global_size_t numGlobalElements,
79  GlobalOrdinal indexBase,
80  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
82 
84 
85  TpetraMap(global_size_t numGlobalElements,
86  size_t numLocalElements,
87  GlobalOrdinal indexBase,
88  const Teuchos::RCP<const Teuchos::Comm<int> > &comm);
89 
91 
92  TpetraMap(global_size_t numGlobalElements,
93  const Teuchos::ArrayView<const GlobalOrdinal> &elementList,
94  GlobalOrdinal indexBase,
95  const Teuchos::RCP<const Teuchos::Comm<int> > &comm);
96 
97 #ifdef HAVE_XPETRA_TPETRA
98  TpetraMap(global_size_t numGlobalElements,
100  const Kokkos::View<const GlobalOrdinal *, typename Node::device_type> &indexList,
101  GlobalOrdinal indexBase,
102  const Teuchos::RCP<const Teuchos::Comm<int> > &comm);
103 #endif
104 
106  ~TpetraMap();
107 
109 
110 
113 
115  size_t getLocalNumElements() const;
116 
118  GlobalOrdinal getIndexBase() const;
119 
121  LocalOrdinal getMinLocalIndex() const;
122 
124  LocalOrdinal getMaxLocalIndex() const;
125 
127  GlobalOrdinal getMinGlobalIndex() const;
128 
130  GlobalOrdinal getMaxGlobalIndex() const;
131 
133  GlobalOrdinal getMinAllGlobalIndex() const;
134 
136  GlobalOrdinal getMaxAllGlobalIndex() const;
137 
139  LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const;
140 
142  GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const;
143 
145  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList, const Teuchos::ArrayView<int> &nodeIDList, const Teuchos::ArrayView<LocalOrdinal> &LIDList) const;
146 
148  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList, const Teuchos::ArrayView<int> &nodeIDList) const;
149 
151  Teuchos::ArrayView<const GlobalOrdinal> getLocalElementList() const;
152 
155 
157 
159 
160 
162  bool isNodeLocalElement(LocalOrdinal localIndex) const;
163 
165  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const;
166 
168  bool isContiguous() const;
169 
171  bool isDistributed() const;
172 
175 
177  bool isSameAs(const Map<LocalOrdinal, GlobalOrdinal, Node> &map) const;
178 
180 
182 
183 
185  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
186 
188 
190 
191 
193  std::string description() const;
194 
196  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const;
197 
198  RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > removeEmptyProcesses() const;
199  RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int> > &newComm) const;
200 
202 
204 
205 
207  TpetraMap(const Teuchos::RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > &map);
208 
210  UnderlyingLib lib() const;
211 
213  RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > getTpetra_Map() const;
214 
215 #ifdef HAVE_XPETRA_TPETRA
218  local_map_type getLocalMap() const;
219 #endif
220 
222 
223  protected:
224  RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > map_;
225 
226 }; // TpetraMap class
227 
228 template <class LocalOrdinal, class GlobalOrdinal, class Node>
229 const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> &toTpetra(const Map<LocalOrdinal, GlobalOrdinal, Node> &map) {
230  // TODO: throw exception
232  return *tpetraMap.getTpetra_Map();
233 }
234 
235 template <class LocalOrdinal, class GlobalOrdinal, class Node>
236 const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > toTpetra(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
237  typedef TpetraMap<LocalOrdinal, GlobalOrdinal, Node> TpetraMapClass;
238  if (map != Teuchos::null) {
239  XPETRA_RCP_DYNAMIC_CAST(const TpetraMapClass, map->getMap(), tpetraMap, "toTpetra");
240  return tpetraMap->getTpetra_Map();
241  }
242  return Teuchos::null;
243 }
244 
245 // In some cases (for instance, in MueLu adapter to Tpetra operator), we need to return a reference. This is only possible if
246 // we assume that the map argument is nonzero
247 template <class LocalOrdinal, class GlobalOrdinal, class Node>
248 const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > toTpetraNonZero(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
249  TEUCHOS_TEST_FOR_EXCEPTION(map.is_null(), std::invalid_argument, "map must be nonzero");
250  typedef TpetraMap<LocalOrdinal, GlobalOrdinal, Node> TpetraMapClass;
251  XPETRA_RCP_DYNAMIC_CAST(const TpetraMapClass, map->getMap(), tpetraMap, "toTpetra");
252  return tpetraMap->getTpetra_Map();
253 }
254 
255 template <class LocalOrdinal, class GlobalOrdinal, class Node>
256 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > toXpetra(const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
257  if (!map.is_null())
259 
260  return Teuchos::null;
261 }
262 
263 template <class LocalOrdinal, class GlobalOrdinal, class Node>
264 const RCP<Map<LocalOrdinal, GlobalOrdinal, Node> > toXpetraNonConst(const RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
265  if (!map.is_null())
267 
268  return Teuchos::null;
269 }
270 
271 namespace useTpetra {
272 
274 template <class LocalOrdinal, class GlobalOrdinal, class Node>
275 Teuchos::RCP<const TpetraMap<LocalOrdinal, GlobalOrdinal, Node> >
276 createLocalMapWithNode(size_t numElements, const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
277  XPETRA_MONITOR("useTpetra::createLocalMapWithNode");
278 
279  return rcp(new TpetraMap<LocalOrdinal, GlobalOrdinal, Node>(Tpetra::createLocalMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, comm)));
280 }
281 
283 template <class LocalOrdinal, class GlobalOrdinal>
284 Teuchos::RCP<const TpetraMap<LocalOrdinal, GlobalOrdinal, typename Tpetra::Map<>::node_type> >
285 createContigMap(global_size_t numElements, size_t localNumElements, const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
286  XPETRA_MONITOR("useTpetra::createContigMap");
287 
288  return rcp(new TpetraMap<LocalOrdinal, GlobalOrdinal, typename Tpetra::Map<>::node_type>(Tpetra::createContigMap<LocalOrdinal, GlobalOrdinal, typename Tpetra::Map<>::node_type>(numElements, localNumElements, comm)));
289 }
290 
292 template <class LocalOrdinal, class GlobalOrdinal, class Node>
293 Teuchos::RCP<const TpetraMap<LocalOrdinal, GlobalOrdinal, Node> >
294 createContigMapWithNode(global_size_t numElements, size_t localNumElements,
295  const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
296  XPETRA_MONITOR("useTpetra::createContigMap");
297  return rcp(new TpetraMap<LocalOrdinal, GlobalOrdinal, Node>(Tpetra::createContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
298 }
299 } // namespace useTpetra
300 
301 #define XPETRA_TPETRAMAP_SHORT
302 } // namespace Xpetra
303 #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.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
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.