Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_MapFactory_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_MAPFACTORY_DECL_HPP
11 #define XPETRA_MAPFACTORY_DECL_HPP
12 
13 #include "Xpetra_ConfigDefs.hpp"
14 
15 #include "Xpetra_Map_decl.hpp"
16 #include "Xpetra_Exceptions.hpp"
17 
18 namespace Xpetra {
19 
25 template <class LocalOrdinal,
26  class GlobalOrdinal,
27  class Node = typename Map<LocalOrdinal, GlobalOrdinal>::node_type>
28 class MapFactory {
29  private:
32 
33  public:
35 
36  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
37  Build(UnderlyingLib lib,
38  global_size_t numGlobalElements,
39  GlobalOrdinal indexBase,
40  const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
42 
44 
45  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
46  Build(UnderlyingLib lib,
47  global_size_t numGlobalElements,
48  size_t numLocalElements,
49  GlobalOrdinal indexBase,
50  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
51 
53 
54  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
55  Build(UnderlyingLib lib,
56  global_size_t numGlobalElements,
57  const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
58  GlobalOrdinal indexBase,
59  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
60 
71  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
72  Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& nodeMap,
73  const LocalOrdinal numDofPerNode,
74  const GlobalOrdinal gidOffset = Teuchos::ScalarTraits<GlobalOrdinal>::zero());
75 
76 #ifdef HAVE_XPETRA_TPETRA
77  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
78  Build(UnderlyingLib lib,
79  global_size_t numGlobalElements,
80  const Kokkos::View<const GlobalOrdinal*, typename Node::device_type>& indexList,
81  GlobalOrdinal indexBase,
82  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
83 #endif
84 
86  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
88  size_t numElements,
89  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
90 
92 
93  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
95  size_t numElements,
96  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
97 
99 
100  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
102  global_size_t numElements,
103  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
104 
106  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
108  global_size_t numElements,
109  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
110 
112  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
114  global_size_t numElements,
115  size_t localNumElements,
116  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
117 
119 
120  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
122  global_size_t numElements,
123  size_t localNumElements,
124  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
125 
127  // for this map.
128  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
129  copyMapWithNewComm(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& oldmap,
130  const Teuchos::RCP<const Teuchos::Comm<int>>& newComm);
131 
132 }; // class MapFactory
133 
137 
138 #if defined(HAVE_XPETRA_EPETRA)
139 
140 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
141 
142 template <>
143 class MapFactory<int, int, EpetraNode> {
144  typedef int LocalOrdinal;
145  typedef int GlobalOrdinal;
146  typedef EpetraNode Node;
147 
148  private:
150  MapFactory();
151 
152  public:
153  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
154  Build(UnderlyingLib lib,
155  global_size_t numGlobalElements,
156  int indexBase,
157  const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
159 
160  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
161  Build(UnderlyingLib lib,
162  global_size_t numGlobalElements,
163  size_t numLocalElements,
164  int indexBase,
165  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
166 
167  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
168  Build(UnderlyingLib lib,
169  global_size_t numGlobalElements,
170  const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
171  int indexBase,
172  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
173 
184  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
185  Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
186  const LocalOrdinal numDofPerNode,
187  const GlobalOrdinal gidOffset = Teuchos::ScalarTraits<GlobalOrdinal>::zero());
188 
189 #ifdef HAVE_XPETRA_TPETRA
190  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
191  Build(UnderlyingLib lib,
192  global_size_t numGlobalElements,
193  const Kokkos::View<const GlobalOrdinal*, typename Node::device_type>& indexList,
194  GlobalOrdinal indexBase,
195  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
196 #endif
197 
198  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
200  size_t numElements,
201  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
202 
203  // TODO remove this
204 
205  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
207  size_t numElements,
208  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
209 
210  // TODO remove this
211 
212  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
214  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
215 
216  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
218  global_size_t numElements,
219  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
220 
221  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
223  global_size_t numElements,
224  size_t localNumElements,
225  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
226 
227  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
229  global_size_t numElements,
230  size_t localNumElements,
231  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
232 
233  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
234  copyMapWithNewComm(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& oldmap,
235  const Teuchos::RCP<const Teuchos::Comm<int>>& newComm);
236 
237 }; // class MapFactory<int, int ... > specialization
238 
239 #endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
240 
241 // we need the Epetra specialization only if Epetra is enabled
242 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
243 
244 template <>
245 class MapFactory<int, long long, EpetraNode> {
246  typedef int LocalOrdinal;
247  typedef long long GlobalOrdinal;
248  typedef EpetraNode Node;
249 
250  private:
252  MapFactory();
253 
254  public:
255  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
256  Build(UnderlyingLib lib,
257  global_size_t numGlobalElements,
258  int indexBase,
259  const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
261 
262  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
263  Build(UnderlyingLib lib,
264  global_size_t numGlobalElements,
265  size_t numLocalElements,
266  int indexBase,
267  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
268 
269  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
270  Build(UnderlyingLib lib,
271  global_size_t numGlobalElements,
272  const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
273  int indexBase,
274  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
275 
278  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
279  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
280  LocalOrdinal numDofPerNode);
281 
282 #ifdef HAVE_XPETRA_TPETRA
283  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
284  Build(UnderlyingLib lib,
285  global_size_t numGlobalElements,
286  const Kokkos::View<const GlobalOrdinal*, typename Node::device_type>& indexList,
287  GlobalOrdinal indexBase,
288  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
289 #endif
290 
291  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
293  size_t numElements,
294  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
295 
296  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
298  size_t numElements,
299  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
300 
301  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
303  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
304 
305  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
307  global_size_t numElements,
308  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
309 
310  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
312  global_size_t numElements,
313  size_t localNumElements,
314  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
315 
316  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
318  global_size_t numElements,
319  size_t localNumElements,
320  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
321 
322  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
323  copyMapWithNewComm(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& oldmap,
324  const Teuchos::RCP<const Teuchos::Comm<int>>& newComm);
325 
326 }; // class MapFactory<int, long long, EpetraNode> specialization
327 
328 #endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
329 
330 #endif // #if defined(HAVE_XPETRA_EPETRA)
331 
332 } // namespace Xpetra
333 
334 #define XPETRA_MAPFACTORY_SHORT
335 
336 #endif // XPETRA_MAPFACTORY_DECL_HPP
337 
338 // TODO: removed unused methods
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > copyMapWithNewComm(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &oldmap, const Teuchos::RCP< const Teuchos::Comm< int >> &newComm)
Create a copy of the map, only using the new Comm object if the Comm would be valid.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMap(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a locally replicated Map with the default node.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMap(UnderlyingLib lib, global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a (potentially) non-uniform, contiguous Map with the default node.
MapFactory()
Private constructor. This is a static class.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int >> &comm, LocalGlobal lg=Xpetra::GloballyDistributed)
Map constructor with Xpetra-defined contiguous uniform distribution.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMapWithNode(UnderlyingLib lib, global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a (potentially) non-uniform, contiguous Map with a user-specified node.
size_t global_size_t
Global size_t object.
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(UnderlyingLib lib, global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a uniform, contiguous Map with a user-specified node.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a locally replicated Map with a specified node.
Create an Xpetra::Map instance.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMap(UnderlyingLib lib, global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Create a uniform, contiguous Map with the default node.