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 // ***********************************************************************
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_MAPFACTORY_DECL_HPP
47 #define XPETRA_MAPFACTORY_DECL_HPP
48 
49 #include "Xpetra_ConfigDefs.hpp"
50 
51 #include "Xpetra_Map_decl.hpp"
52 #include "Xpetra_Exceptions.hpp"
53 
54 namespace Xpetra {
55 
61 template <class LocalOrdinal,
62  class GlobalOrdinal,
63  class Node = typename Map<LocalOrdinal, GlobalOrdinal>::node_type>
64 class MapFactory {
65  private:
68 
69  public:
71 
72  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
73  Build(UnderlyingLib lib,
74  global_size_t numGlobalElements,
75  GlobalOrdinal indexBase,
76  const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
78 
80 
81  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
82  Build(UnderlyingLib lib,
83  global_size_t numGlobalElements,
84  size_t numLocalElements,
85  GlobalOrdinal indexBase,
86  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
87 
89 
90  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
91  Build(UnderlyingLib lib,
92  global_size_t numGlobalElements,
93  const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
94  GlobalOrdinal indexBase,
95  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
96 
107  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
108  Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& nodeMap,
109  const LocalOrdinal numDofPerNode,
110  const GlobalOrdinal gidOffset = Teuchos::ScalarTraits<GlobalOrdinal>::zero());
111 
112 #ifdef HAVE_XPETRA_TPETRA
113  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
114  Build(UnderlyingLib lib,
115  global_size_t numGlobalElements,
116  const Kokkos::View<const GlobalOrdinal*, typename Node::device_type>& indexList,
117  GlobalOrdinal indexBase,
118  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
119 #endif
120 
122  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
124  size_t numElements,
125  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
126 
128 
129  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
131  size_t numElements,
132  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
133 
135 
136  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
138  global_size_t numElements,
139  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
140 
142  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
144  global_size_t numElements,
145  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
146 
148  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
150  global_size_t numElements,
151  size_t localNumElements,
152  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
153 
155 
156  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
158  global_size_t numElements,
159  size_t localNumElements,
160  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
161 
163  // for this map.
164  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
165  copyMapWithNewComm(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& oldmap,
166  const Teuchos::RCP<const Teuchos::Comm<int>>& newComm);
167 
168 }; // class MapFactory
169 
173 
174 #if defined(HAVE_XPETRA_EPETRA)
175 
176 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
177 
178 template <>
179 class MapFactory<int, int, EpetraNode> {
180  typedef int LocalOrdinal;
181  typedef int GlobalOrdinal;
182  typedef EpetraNode Node;
183 
184  private:
186  MapFactory();
187 
188  public:
189  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
190  Build(UnderlyingLib lib,
191  global_size_t numGlobalElements,
192  int indexBase,
193  const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
195 
196  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
197  Build(UnderlyingLib lib,
198  global_size_t numGlobalElements,
199  size_t numLocalElements,
200  int indexBase,
201  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
202 
203  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
204  Build(UnderlyingLib lib,
205  global_size_t numGlobalElements,
206  const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
207  int indexBase,
208  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
209 
220  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
221  Build(const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
222  const LocalOrdinal numDofPerNode,
223  const GlobalOrdinal gidOffset = Teuchos::ScalarTraits<GlobalOrdinal>::zero());
224 
225 #ifdef HAVE_XPETRA_TPETRA
226  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
227  Build(UnderlyingLib lib,
228  global_size_t numGlobalElements,
229  const Kokkos::View<const GlobalOrdinal*, typename Node::device_type>& indexList,
230  GlobalOrdinal indexBase,
231  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
232 #endif
233 
234  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
236  size_t numElements,
237  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
238 
239  // TODO remove this
240 
241  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
243  size_t numElements,
244  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
245 
246  // TODO remove this
247 
248  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
250  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
251 
252  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
254  global_size_t numElements,
255  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
256 
257  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
259  global_size_t numElements,
260  size_t localNumElements,
261  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
262 
263  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
265  global_size_t numElements,
266  size_t localNumElements,
267  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
268 
269  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
270  copyMapWithNewComm(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& oldmap,
271  const Teuchos::RCP<const Teuchos::Comm<int>>& newComm);
272 
273 }; // class MapFactory<int, int ... > specialization
274 
275 #endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
276 
277 // we need the Epetra specialization only if Epetra is enabled
278 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
279 
280 template <>
281 class MapFactory<int, long long, EpetraNode> {
282  typedef int LocalOrdinal;
283  typedef long long GlobalOrdinal;
284  typedef EpetraNode Node;
285 
286  private:
288  MapFactory();
289 
290  public:
291  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
292  Build(UnderlyingLib lib,
293  global_size_t numGlobalElements,
294  int indexBase,
295  const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
297 
298  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
299  Build(UnderlyingLib lib,
300  global_size_t numGlobalElements,
301  size_t numLocalElements,
302  int indexBase,
303  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
304 
305  static RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
306  Build(UnderlyingLib lib,
307  global_size_t numGlobalElements,
308  const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
309  int indexBase,
310  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
311 
314  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
315  Build(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
316  LocalOrdinal numDofPerNode);
317 
318 #ifdef HAVE_XPETRA_TPETRA
319  static Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
320  Build(UnderlyingLib lib,
321  global_size_t numGlobalElements,
322  const Kokkos::View<const GlobalOrdinal*, typename Node::device_type>& indexList,
323  GlobalOrdinal indexBase,
324  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
325 #endif
326 
327  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
329  size_t numElements,
330  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
331 
332  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
334  size_t numElements,
335  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
336 
337  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
339  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
340 
341  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
343  global_size_t numElements,
344  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
345 
346  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
348  global_size_t numElements,
349  size_t localNumElements,
350  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
351 
352  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
354  global_size_t numElements,
355  size_t localNumElements,
356  const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
357 
358  static Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
359  copyMapWithNewComm(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>& oldmap,
360  const Teuchos::RCP<const Teuchos::Comm<int>>& newComm);
361 
362 }; // class MapFactory<int, long long, EpetraNode> specialization
363 
364 #endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
365 
366 #endif // #if defined(HAVE_XPETRA_EPETRA)
367 
368 } // namespace Xpetra
369 
370 #define XPETRA_MAPFACTORY_SHORT
371 
372 #endif // XPETRA_MAPFACTORY_DECL_HPP
373 
374 // 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.