All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Xpetra_EpetraMapFactory.cpp
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 #include "Xpetra_MapFactory.hpp"
47 
48 #include "Xpetra_BlockedMap.hpp"
49 #include "Xpetra_EpetraMap.hpp"
50 #include "Xpetra_TpetraMap.hpp"
51 
52 namespace Xpetra {
53 
54 #if defined(HAVE_XPETRA_EPETRA)
55 
56 
57 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
58 
59 
62  {
63  }
64 
65 
66 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
67  TPETRA_DEPRECATED
71  global_size_t numGlobalElements,
72  int indexBase,
73  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
74  LocalGlobal lg,
75  const Teuchos::RCP<EpetraNode>& /* node */ )
76  {
77  return Build(lib, numGlobalElements, indexBase, comm, lg);
78  }
79 #endif // TPETRA_ENABLE_DEPRECATED_CODE
80 
81 
82  RCP<Map<int, int, EpetraNode>>
85  global_size_t numGlobalElements,
86  int indexBase,
87  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
88  LocalGlobal lg)
89  {
90  XPETRA_MONITOR("MapFactory::Build");
91 
92  using LocalOrdinal = int;
93  using GlobalOrdinal = int;
94  using Node = EpetraNode;
95 
96 #ifdef HAVE_XPETRA_TPETRA
97  if (lib == UseTpetra)
98  return rcp( new Xpetra::TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, indexBase, comm, lg) );
99 #endif
100 
101  if (lib == UseEpetra)
102  return rcp( new EpetraMapT<int, Node>(numGlobalElements, indexBase, comm, lg) );
103 
105  }
106 
107 
108 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
109  TPETRA_DEPRECATED
112  Build (UnderlyingLib lib,
113  global_size_t numGlobalElements,
114  size_t numLocalElements,
115  int indexBase,
116  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
117  const Teuchos::RCP<EpetraNode>& /* node */ )
118  {
119  return Build(lib, numGlobalElements, numLocalElements, indexBase, comm);
120  }
121 #endif // TPETRA_ENABLE_DEPRECATED_CODE
122 
123 
124  RCP<Map<int, int, EpetraNode> >
127  global_size_t numGlobalElements,
128  size_t numLocalElements,
129  int indexBase,
130  const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
131  {
132  XPETRA_MONITOR("MapFactory::Build");
133 
134  using LocalOrdinal = int;
135  using GlobalOrdinal = int;
136  using Node = EpetraNode;
137 
138 #ifdef HAVE_XPETRA_TPETRA
139  if (lib == UseTpetra)
140  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, numLocalElements, indexBase, comm) );
141 #endif
142 
143  if (lib == UseEpetra)
144  return rcp( new EpetraMapT<int, Node>(numGlobalElements, numLocalElements, indexBase, comm) );
145 
147  }
148 
149 
150 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
151  TPETRA_DEPRECATED
155  global_size_t numGlobalElements,
156  const Teuchos::ArrayView<const int> &elementList,
157  int indexBase,
158  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
159  const Teuchos::RCP<EpetraNode>& /* node */ )
160  {
161  return Build(lib, numGlobalElements, elementList, indexBase, comm);
162  }
163 #endif // TPETRA_ENABLE_DEPRECATED_CODE
164 
165 
166  RCP<Map<int, int, EpetraNode> >
169  global_size_t numGlobalElements,
170  const Teuchos::ArrayView<const int> &elementList,
171  int indexBase,
172  const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
173  {
174  using LocalOrdinal = int;
175  using GlobalOrdinal = int;
176  using Node = EpetraNode;
177 
178  XPETRA_MONITOR("MapFactory::Build");
179 #ifdef HAVE_XPETRA_TPETRA
180  if (lib == UseTpetra)
181  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, elementList, indexBase, comm) );
182 #endif // HAVE_XPETRA_TPETRA
183 
184  if (lib == UseEpetra)
185  return rcp( new EpetraMapT<int, Node>(numGlobalElements, elementList, indexBase, comm) );
186 
188  }
189 
190 
196  int numDofPerNode)
197  {
198  XPETRA_MONITOR("MapFactory::Build");
199 
200  using LocalOrdinal = int;
201  using GlobalOrdinal = int;
202  using Node = EpetraNode;
203 
205  if(!bmap.is_null())
206  {
208  "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode << ".");
210  }
211 
212  LocalOrdinal N = Teuchos::as<LocalOrdinal>(map->getNodeNumElements());
213  Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getNodeElementList();
214  Teuchos::Array<GlobalOrdinal> newElements(map->getNodeNumElements()*numDofPerNode);
215  for (LocalOrdinal i = 0; i < N; i++)
216  {
217  for (LocalOrdinal j = 0; j < numDofPerNode; j++)
218  {
219  newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
220  }
221  }
222 
223 #ifdef HAVE_XPETRA_TPETRA
224  if (map->lib() == UseTpetra)
225  {
226  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
227  }
228 #endif // HAVE_XPETRA_TPETRA
229 
230  if (map->lib() == UseEpetra)
231  {
232  return rcp( new EpetraMapT<int, Node>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
233  }
234 
236  }
237 
238 
242  size_t numElements,
243  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
244  {
245  XPETRA_MONITOR("MapFactory::Build");
246 
247  using LocalOrdinal = int;
248  using GlobalOrdinal = int;
249  using Node = EpetraNode;
250 
251 #ifdef HAVE_XPETRA_TPETRA
252  if (lib == UseTpetra)
253 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
254  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
255  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
256 #else
258  "Xpetra::MapFactory::createLocalMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
259 #endif
260 #endif // HAVE_XPETRA_TPETRA
261 
262  if (lib == UseEpetra) {
264  map = Teuchos::rcp( new EpetraMapT<int, Node>( (Xpetra::global_size_t)numElements, // num elements, global and local
265  0, // index base is zero
266  comm, LocallyReplicated)
267  );
268  return map.getConst();
269  }
270 
272  }
273 
274 
275  // TODO remove this
276 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
277  TPETRA_DEPRECATED
281  size_t numElements,
282  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
283  const Teuchos::RCP<Node> & /* node */)
284  {
285  return createLocalMapWithNode(lib, numElements, comm);
286  }
287 #endif // TPETRA_ENABLE_DEPRECATED_CODE
288 
289 
290 
294  size_t numElements,
295  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
296  {
297  XPETRA_MONITOR("MapFactory::Build");
298 
299  using LocalOrdinal = int;
300  using GlobalOrdinal = int;
301  using Node = EpetraNode;
302 
303 #ifdef HAVE_XPETRA_TPETRA
304  if (lib == UseTpetra)
305 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
306  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
307  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<int, GlobalOrdinal, Node> (numElements, comm)));
308 #else
310  "Xpetra::MapFactory::createLocalMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
311 #endif
312 #endif // HAVE_XPETRA_TPETRA
313 
314  if (lib == UseEpetra) {
316  map = Teuchos::rcp( new EpetraMapT<int, Node>((Xpetra::global_size_t)numElements, // num elements, global and local
317  0, // index base is zero
318  comm, LocallyReplicated));
319  return map.getConst();
320  }
321 
323  }
324 
325 
326 
327  // TODO remove this
328 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
329  TPETRA_DEPRECATED
333  global_size_t numElements,
334  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
335  const Teuchos::RCP<Node>& /* node */)
336  {
337  return createUniformContigMapWithNode(lib, numElements, comm);
338  }
339 #endif // TPETRA_ENABLE_DEPRECATED_CODE
340 
341 
342 
346  global_size_t numElements,
347  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
348  {
349  XPETRA_MONITOR("MapFactory::Build");
350 
351  using LocalOrdinal = int;
352  using GlobalOrdinal = int;
353  using Node = EpetraNode;
354 
355 #ifdef HAVE_XPETRA_TPETRA
356  if (lib == UseTpetra)
357 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
358  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
359  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<int,GlobalOrdinal,Node> (numElements, comm)));
360 #else
362  "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
363 #endif
364 #endif // HAVE_XPETRA_TPETRA
365 
366  if (lib == UseEpetra) {
368  map = Teuchos::rcp( new EpetraMapT<int,Node>(numElements, // num elements, global and local
369  0, //index base is zero
370  comm, GloballyDistributed));
371  return map.getConst();
372  }
373 
375  }
376 
377 
381  global_size_t numElements,
382  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
383  {
384  XPETRA_MONITOR("MapFactory::Build");
385 
386  using LocalOrdinal = int;
387  using GlobalOrdinal = int;
388  using Node = EpetraNode;
389 
390 #ifdef HAVE_XPETRA_TPETRA
391  if (lib == UseTpetra)
392 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
393  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
394  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
395 #else
397  "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
398 #endif
399 #endif // HAVE_XPETRA_TPETRA
400 
401  if (lib == UseEpetra)
402  {
404  map = Teuchos::rcp( new EpetraMapT<int,Node>(numElements, // num elements, global and local
405  0, //index base is zero
406  comm, GloballyDistributed));
407  return map.getConst();
408  }
410  }
411 
412 
416  global_size_t numElements,
417  size_t localNumElements,
418  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
419  {
420  XPETRA_MONITOR("MapFactory::Build");
421 
422  using LocalOrdinal = int;
423  using GlobalOrdinal = int;
424  using Node = EpetraNode;
425 
426  #ifdef HAVE_XPETRA_TPETRA
427  if (lib == UseTpetra)
428  #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
429  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
430  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createContigMapWithNode<int,GlobalOrdinal,Node>(numElements, localNumElements, comm)));
431  #else
433  "Xpetra::MapFactory::createContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
434  #endif
435  #endif
436 
437  if (lib == UseEpetra)
438  {
439  return MapFactory<int, GlobalOrdinal, Node>::createContigMapWithNode(lib, numElements, localNumElements, comm);
440  }
441 
443  }
444 
445 
446 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
447  TPETRA_DEPRECATED
451  global_size_t numElements,
452  size_t localNumElements,
453  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
454  const Teuchos::RCP<Node> & /* node */)
455  {
456  return createContigMapWithNode(lib, numElements, localNumElements, comm);
457  }
458 #endif // TPETRA_ENABLE_DEPRECATED_CODE
459 
460 
464  global_size_t numElements,
465  size_t localNumElements,
466  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
467  {
468  XPETRA_MONITOR("MapFactory::Build");
469 
470  using LocalOrdinal = int;
471  using GlobalOrdinal = int;
472  using Node = EpetraNode;
473 
474 #ifdef HAVE_XPETRA_TPETRA
475  if (lib == UseTpetra)
476 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
477  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
478  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createContigMapWithNode<int,GlobalOrdinal,Node>(numElements, localNumElements, comm)));
479 #else
481  "Xpetra::MapFactory::createContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
482 #endif
483 #endif
484 
485  if (lib == UseEpetra)
486  {
488  map = Teuchos::rcp( new EpetraMapT<int, Node>(numElements,localNumElements,
489  0, // index base is zero
490  comm) );
491  return map.getConst();
492  }
494  }
495 
496 
497 
498 #endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
499 
500 
501 
502 
503 
504 
505 
506 
507 // we need the Epetra specialization only if Epetra is enabled
508 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
509 
510 
511 
515  {
516  }
517 
518 
519 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
520  TPETRA_DEPRECATED
523  Build (UnderlyingLib lib,
524  global_size_t numGlobalElements,
525  int indexBase,
526  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
527  LocalGlobal lg,
528  const Teuchos::RCP<Node>& /* node */)
529  {
530  return Build(lib, numGlobalElements, indexBase, comm, lg);
531  }
532 #endif // TPETRA_ENABLE_DEPRECATED_CODE
533 
534 
535  RCP<Map<int, long long, EpetraNode>>
538  global_size_t numGlobalElements,
539  int indexBase,
540  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
541  LocalGlobal lg)
542  {
543  XPETRA_MONITOR("MapFactory::Build");
544 
545  using LocalOrdinal = int;
546  using GlobalOrdinal = long long;
547  using Node = EpetraNode;
548 
549 #ifdef HAVE_XPETRA_TPETRA
550  if (lib == UseTpetra)
551  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, indexBase, comm, lg) );
552 #endif
553 
554  if (lib == UseEpetra)
555  return rcp( new EpetraMapT<long long, Node>(numGlobalElements, indexBase, comm, lg) );
556 
558  }
559 
560 
561 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
562  TPETRA_DEPRECATED
565  Build (UnderlyingLib lib,
566  global_size_t numGlobalElements,
567  size_t numLocalElements,
568  int indexBase,
569  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
570  const Teuchos::RCP<EpetraNode>& /* node */)
571  {
572  return Build(lib, numGlobalElements, numLocalElements, indexBase, comm);
573  }
574 #endif // TPETRA_ENABLE_DEPRECATED_CODE
575 
576 
577  RCP<Map<int, long long, EpetraNode> >
580  global_size_t numGlobalElements,
581  size_t numLocalElements,
582  int indexBase,
583  const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
584  {
585  XPETRA_MONITOR("MapFactory::Build");
586 
587  using LocalOrdinal = int;
588  using GlobalOrdinal = long long;
589  using Node = EpetraNode;
590 
591 #ifdef HAVE_XPETRA_TPETRA
592  if (lib == UseTpetra)
593  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, numLocalElements, indexBase, comm) );
594 #endif
595 
596  if (lib == UseEpetra)
597  return rcp( new EpetraMapT<long long, Node>(numGlobalElements, numLocalElements, indexBase, comm) );
598 
600  }
601 
602 
603 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
604  TPETRA_DEPRECATED
608  global_size_t numGlobalElements,
609  const Teuchos::ArrayView<const long long> &elementList,
610  int indexBase,
611  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
612  const Teuchos::RCP<EpetraNode>& /* node */)
613  {
614  return Build(lib, numGlobalElements, elementList, indexBase, comm);
615  }
616 #endif // TPETRA_ENABLE_DEPRECATED_CODE
617 
618 
619  RCP<Map<int, long long, EpetraNode> >
622  global_size_t numGlobalElements,
623  const Teuchos::ArrayView<const long long> &elementList,
624  int indexBase,
625  const Teuchos::RCP<const Teuchos::Comm<int> > &comm)
626  {
627  XPETRA_MONITOR("MapFactory::Build");
628 
629  using LocalOrdinal = int;
630  using GlobalOrdinal = long long;
631  using Node = EpetraNode;
632 
633 #ifdef HAVE_XPETRA_TPETRA
634  if (lib == UseTpetra)
635  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, elementList, indexBase, comm) );
636 #endif
637 
638  if (lib == UseEpetra)
639  return rcp( new EpetraMapT<long long, Node>(numGlobalElements, elementList, indexBase, comm) );
640 
642  }
643 
649  int numDofPerNode)
650  {
651  XPETRA_MONITOR("MapFactory::Build");
652 
653  using LocalOrdinal = int;
654  using GlobalOrdinal = long long;
655  using Node = EpetraNode;
656 
658  if(!bmap.is_null()) {
660  "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode << ".");
662  }
663 
664  LocalOrdinal N = map->getNodeNumElements();
665  Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getNodeElementList();
666  Teuchos::Array<GlobalOrdinal> newElements(map->getNodeNumElements()*numDofPerNode);
667  for (LocalOrdinal i = 0; i < N; i++)
668  for (LocalOrdinal j = 0; j < numDofPerNode; j++)
669  newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
670 
671 #ifdef HAVE_XPETRA_TPETRA
672  if (map->lib() == UseTpetra)
673  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
674 #endif
675 
676  if (map->lib() == UseEpetra)
677  return rcp( new EpetraMapT<long long, Node>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
678 
680  }
681 
682 
686  size_t numElements,
687  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
688  {
689  XPETRA_MONITOR("MapFactory::Build");
690 
691  using LocalOrdinal = int;
692  using GlobalOrdinal = long long;
693  using Node = EpetraNode;
694 
695 #ifdef HAVE_XPETRA_TPETRA
696  if (lib == UseTpetra)
697 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
698  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
699  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
700 #else
702  "Xpetra::MapFactory::createLocalMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
703 #endif
704 #endif
705 
706  if (lib == UseEpetra)
707  return MapFactory<int, GlobalOrdinal, Node>::createLocalMapWithNode (lib, numElements, comm);
708 
710  }
711 
712 
713 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
714  TPETRA_DEPRECATED
718  size_t numElements,
719  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
720  const Teuchos::RCP<EpetraNode> & /* node */)
721  {
722  return createLocalMapWithNode(lib, numElements, comm);
723  }
724 #endif // TPETRA_ENABLE_DEPRECATED_CODE
725 
726 
730  size_t numElements,
731  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
732  {
733  XPETRA_MONITOR("MapFactory::Build");
734 
735  using LocalOrdinal = int;
736  using GlobalOrdinal = long long;
737  using Node = EpetraNode;
738 
739 #ifdef HAVE_XPETRA_TPETRA
740  if (lib == UseTpetra)
741 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
742  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
743  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<int, GlobalOrdinal, Node> (numElements, comm)));
744 #else
746  "Xpetra::MapFactory::createLocalMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
747 #endif
748 #endif
749 
750  if (lib == UseEpetra)
751  {
753  map = Teuchos::rcp( new EpetraMapT<long long, Node>((Xpetra::global_size_t)numElements, // num elements, global and local
754  0, // index base is zero
755  comm, LocallyReplicated));
756  return map.getConst();
757  }
759  }
760 
761 
762 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
763  TPETRA_DEPRECATED
767  global_size_t numElements,
768  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
769  const Teuchos::RCP<EpetraNode>& /* node */)
770  {
771  return createUniformContigMapWithNode(lib, numElements, comm);
772  }
773 #endif // TPETRA_ENABLE_DEPRECATED_CODE
774 
775 
779  global_size_t numElements,
780  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
781  {
782  XPETRA_MONITOR("MapFactory::Build");
783 
784  using LocalOrdinal = int;
785  using GlobalOrdinal = long long;
786  using Node = EpetraNode;
787 
788 #ifdef HAVE_XPETRA_TPETRA
789  if (lib == UseTpetra)
790 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
791  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
792  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<int,GlobalOrdinal,Node> (numElements, comm)));
793 #else
795  "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
796 #endif
797 #endif
798 
799  if (lib == UseEpetra)
800  {
802  map = Teuchos::rcp( new EpetraMapT<long long, Node>(numElements, // num elements, global and local
803  0, //index base is zero
804  comm, GloballyDistributed));
805  return map.getConst();
806  }
808  }
809 
810 
814  global_size_t numElements,
815  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
816  {
817  XPETRA_MONITOR("MapFactory::Build");
818 
819  using LocalOrdinal = int;
820  using GlobalOrdinal = long long;
821  using Node = EpetraNode;
822 
823 #ifdef HAVE_XPETRA_TPETRA
824  if (lib == UseTpetra)
825 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
826  (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
827  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
828 #else
830  "Xpetra::MapFactory::createUniformContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
831 #endif
832 #endif
833 
834  if (lib == UseEpetra)
836 
838  }
839 
840 
843  global_size_t numElements,
844  size_t localNumElements,
845  const Teuchos::RCP<const Teuchos::Comm<int>>& comm)
846  {
847  XPETRA_MONITOR("MapFactory::Build");
848 
849  using LocalOrdinal = int;
850  using GlobalOrdinal = long long;
851  using Node = EpetraNode;
852 
853 #ifdef HAVE_XPETRA_TPETRA
854  if(lib == UseTpetra)
855 #if((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
856  || (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
858  Tpetra::createContigMapWithNode<int, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
859 #else
862  "Xpetra::MapFactory::createContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on "
863  "EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
864 #endif
865 #endif
866 
867  if(lib == UseEpetra)
868  return MapFactory<int, GlobalOrdinal, Node>::createContigMapWithNode(lib, numElements, localNumElements, comm);
869 
871  }
872 
873 
874 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
875  TPETRA_DEPRECATED
879  global_size_t numElements,
880  size_t localNumElements,
881  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
882  const Teuchos::RCP<EpetraNode> & /* node */ )
883  {
884  return createContigMapWithNode(lib, numElements, localNumElements, comm);
885  }
886 #endif // TPETRA_ENABLE_DEPRECATED_CODE
887 
888 
892  global_size_t numElements,
893  size_t localNumElements,
894  const Teuchos::RCP<const Teuchos::Comm<int>>& comm)
895  {
896  XPETRA_MONITOR("MapFactory::Build");
897 
898  using LocalOrdinal = int;
899  using GlobalOrdinal = long long;
900  using Node = EpetraNode;
901 
902 #ifdef HAVE_XPETRA_TPETRA
903  if(lib == UseTpetra)
904 #if((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
905  || (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
907  Tpetra::createContigMapWithNode<int, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
908 #else
911  "Xpetra::MapFactory::createContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not "
912  "instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
913 #endif
914 #endif // HAVE_XPETRA_TPETRA
915 
916  if(lib == UseEpetra)
917  {
919  map = Teuchos::rcp(new EpetraMapT<long long, Node>(numElements,
920  localNumElements,
921  0, // index base is zero
922  comm));
923  return map.getConst();
924  }
925 
927  }
928 
929 
930 
931 #endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
932 
933 
934 #endif // #if defined(HAVE_XPETRA_EPETRA)
935 
936 
937 
938 } // namespace Xpetra
939 
940 // EOF
RCP< const T > getConst() const
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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.
Exception throws to report errors in the internal logical of the program.
Kokkos::Compat::KokkosSerialWrapperNode EpetraNode
MapFactory()
Private constructor. This is a static class.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.
#define XPETRA_FACTORY_END
size_t global_size_t
Global size_t object.
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.
#define XPETRA_MONITOR(funcName)
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.
bool is_null() const