Xpetra_MapFactory.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_HPP
47 #define XPETRA_MAPFACTORY_HPP
48 
49 #include "Xpetra_ConfigDefs.hpp"
50 #include "Xpetra_Map.hpp"
51 
52 #ifdef HAVE_XPETRA_TPETRA
53 # include "Xpetra_TpetraMap.hpp"
54 #endif
55 #ifdef HAVE_XPETRA_EPETRA
56 # include "Xpetra_EpetraMap.hpp"
57 #endif
58 
59 #include "Xpetra_Exceptions.hpp"
60 
61 namespace Xpetra {
67  template <class LocalOrdinal = Map<>::local_ordinal_type,
68  class GlobalOrdinal = typename Map<LocalOrdinal>::global_ordinal_type,
69  class Node = typename Map<LocalOrdinal, GlobalOrdinal>::node_type>
70  class MapFactory {
71 
72  private:
75 
76  public:
78  // Workaround function for a deferred visual studio bug
79  //
80  // http://connect.microsoft.com/VisualStudio/feedback/details/719847/erroneous-error-c2783-could-not-deduce-template-argument
81  //
82  // Use this function for default arguments rather than calling
83  // what is the return value below. Also helps in reducing
84  // duplication in various constructors.
85  return KokkosClassic::Details::getNode<Node>();
86  }
87 
91  global_size_t numGlobalElements,
92  GlobalOrdinal indexBase,
93  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
95  const Teuchos::RCP<Node> &node = defaultArgNode ())
96  {
97  XPETRA_MONITOR("MapFactory::Build");
98 
99 #ifdef HAVE_XPETRA_TPETRA
100  if (lib == UseTpetra)
101  return Teuchos::rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, indexBase, comm, lg, node) );
102 #endif
103 
106  }
107 
111  global_size_t numGlobalElements,
112  size_t numLocalElements,
113  GlobalOrdinal indexBase,
114  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
115  const Teuchos::RCP<Node> &node = defaultArgNode ())
116  {
117  XPETRA_MONITOR("MapFactory::Build");
118 
119 #ifdef HAVE_XPETRA_TPETRA
120  if (lib == UseTpetra)
121  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, numLocalElements, indexBase, comm, node) );
122 #endif
123 
126  }
127 
131  global_size_t numGlobalElements,
132  const Teuchos::ArrayView<const GlobalOrdinal> &elementList,
133  GlobalOrdinal indexBase,
134  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
135  const Teuchos::RCP<Node> &node = defaultArgNode ())
136  {
137  XPETRA_MONITOR("MapFactory::Build");
138 
139 #ifdef HAVE_XPETRA_TPETRA
140  if (lib == UseTpetra)
141  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, elementList, indexBase, comm, node) );
142 #endif
143 
146  }
147 
151  LocalOrdinal numDofPerNode)
152  {
153  XPETRA_MONITOR("MapFactory::Build");
154 
155 #ifdef HAVE_XPETRA_TPETRA
156  LocalOrdinal N = map->getNodeNumElements();
157  Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getNodeElementList();
158  Teuchos::Array<GlobalOrdinal> newElements(map->getNodeNumElements()*numDofPerNode);
159  for (LocalOrdinal i = 0; i < N; i++)
160  for (LocalOrdinal j = 0; j < numDofPerNode; j++)
161  newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
162  if (map->lib() == UseTpetra)
163  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm(), map->getNode()) );
164 #endif
165 
166  XPETRA_FACTORY_ERROR_IF_EPETRA(map->lib());
168  }
169 
173  size_t numElements,
174  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
175  {
176  XPETRA_MONITOR("MapFactory::Build");
177 
178 #ifdef HAVE_XPETRA_TPETRA
179  if (lib == UseTpetra)
180  return rcp(new Xpetra::TpetraMap<LocalOrdinal,GlobalOrdinal>(Tpetra::createLocalMap<LocalOrdinal,GlobalOrdinal>(numElements, comm)));
181 #endif
182 
185  }
186 
190  size_t numElements,
191  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
192  const Teuchos::RCP< Node > &node)
193  {
194  XPETRA_MONITOR("MapFactory::Build");
195 
196 #ifdef HAVE_XPETRA_TPETRA
197  if (lib == UseTpetra)
198  return rcp(new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(numElements, comm, node)));
199 #endif
200 
203  }
204 
208  global_size_t numElements,
209  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
210  const Teuchos::RCP< Node > &node)
211  {
212  XPETRA_MONITOR("MapFactory::Build");
213 
214 #ifdef HAVE_XPETRA_TPETRA
215  if (lib == UseTpetra)
216  return rcp(new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(numElements, comm, node)));
217 #endif
218 
221  }
222 
226  global_size_t numElements,
227  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
228  {
229  XPETRA_MONITOR("MapFactory::Build");
230 
231 #ifdef HAVE_XPETRA_TPETRA
232  if (lib == UseTpetra)
233  return rcp(new Xpetra::TpetraMap<LocalOrdinal,GlobalOrdinal>(Tpetra::createUniformContigMap<LocalOrdinal,GlobalOrdinal>(numElements, comm)));
234 #endif
235 
238  }
239 
243  global_size_t numElements,
244  size_t localNumElements,
245  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
246  {
247  XPETRA_MONITOR("MapFactory::Build");
248 
249 #ifdef HAVE_XPETRA_TPETRA
250  if (lib == UseTpetra)
251  return rcp(new Xpetra::TpetraMap<LocalOrdinal,GlobalOrdinal>(Tpetra::createContigMap<LocalOrdinal,GlobalOrdinal>(numElements, localNumElements, comm)));
252 #endif
253 
256  }
257 
261  global_size_t numElements,
262  size_t localNumElements,
263  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
264  const Teuchos::RCP< Node > &node)
265  {
266  XPETRA_MONITOR("MapFactory::Build");
267 
268 #ifdef HAVE_XPETRA_TPETRA
269  if (lib == UseTpetra)
270  return rcp(new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(numElements, localNumElements, comm, node)));
271 #endif
272 
275  }
276  };
277 
278  template <>
279  class MapFactory<int, int> {
280 
281  typedef int LocalOrdinal;
282  typedef int GlobalOrdinal;
284 
285  private:
288 
289  public:
290 
292  // Workaround function for a deferred visual studio bug
293  //
294  // http://connect.microsoft.com/VisualStudio/feedback/details/719847/erroneous-error-c2783-could-not-deduce-template-argument
295  //
296  // Use this function for default arguments rather than calling
297  // what is the return value below. Also helps in reducing
298  // duplication in various constructors.
299  return KokkosClassic::Details::getNode<Node>();
300  }
301 
304  global_size_t numGlobalElements,
305  int indexBase,
306  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
308  const Teuchos::RCP<Node>& node = defaultArgNode ()) {
309  XPETRA_MONITOR("MapFactory::Build");
310 
311 #ifdef HAVE_XPETRA_TPETRA
312  if (lib == UseTpetra)
313  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, indexBase, comm, lg, node) );
314 #endif
315 
316 #ifdef HAVE_XPETRA_EPETRA
317 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
318  if (lib == UseEpetra)
319  return rcp( new EpetraMapT<int>(numGlobalElements, indexBase, comm, lg, node) );
320 #endif
321 #endif
322 
324  }
325 
328  global_size_t numGlobalElements,
329  size_t numLocalElements,
330  int indexBase,
331  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
332  const Teuchos::RCP<Node>& node = defaultArgNode())
333  {
334  XPETRA_MONITOR("MapFactory::Build");
335 
336 #ifdef HAVE_XPETRA_TPETRA
337  if (lib == UseTpetra)
338  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, numLocalElements, indexBase, comm, node) );
339 #endif
340 
341 #ifdef HAVE_XPETRA_EPETRA
342 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
343  if (lib == UseEpetra)
344  return rcp( new EpetraMapT<int>(numGlobalElements, numLocalElements, indexBase, comm, node) );
345 #endif
346 #endif
347 
349  }
350 
351  static RCP<Map<LocalOrdinal,GlobalOrdinal, Node> > Build(UnderlyingLib lib, global_size_t numGlobalElements, const Teuchos::ArrayView<const GlobalOrdinal> &elementList, int indexBase, const Teuchos::RCP<const Teuchos::Comm<int> > &comm, const Teuchos::RCP<Node>& node = defaultArgNode ()) {
352  XPETRA_MONITOR("MapFactory::Build");
353 
354 #ifdef HAVE_XPETRA_TPETRA
355  if (lib == UseTpetra)
356  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, elementList, indexBase, comm, node) );
357 #endif
358 
359 #ifdef HAVE_XPETRA_EPETRA
360 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
361  if (lib == UseEpetra)
362  return rcp( new EpetraMapT<int>(numGlobalElements, elementList, indexBase, comm, node) );
363 #endif
364 #endif
365 
367  }
368 
371  XPETRA_MONITOR("MapFactory::Build");
372 
373  LocalOrdinal N = map->getNodeNumElements();
374  Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getNodeElementList();
375  Teuchos::Array<GlobalOrdinal> newElements(map->getNodeNumElements()*numDofPerNode);
376  for (LocalOrdinal i = 0; i < N; i++)
377  for (LocalOrdinal j = 0; j < numDofPerNode; j++)
378  newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
379 
380 #ifdef HAVE_XPETRA_TPETRA
381  if (map->lib() == UseTpetra)
382  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm(), map->getNode()) );
383 #endif
384 
385 #ifdef HAVE_XPETRA_EPETRA
386 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
387  if (map->lib() == UseEpetra)
388  return rcp( new EpetraMapT<int>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm(), map->getNode()) );
389 #endif
390 #endif
391 
393  }
394 
396  createLocalMap(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm) {
397  XPETRA_MONITOR("MapFactory::Build");
398 
399 #ifdef HAVE_XPETRA_TPETRA
400  if (lib == UseTpetra)
401  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
402 #endif
403 
404 #ifdef HAVE_XPETRA_EPETRA
405 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
406  if (lib == UseEpetra)
407  return MapFactory<int, GlobalOrdinal>::createLocalMapWithNode (lib, numElements, comm,
408  defaultArgNode());
409 #endif
410 #endif
411 
413  }
414 
416  createLocalMapWithNode(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP<Node> &node) {
417  XPETRA_MONITOR("MapFactory::Build");
418 
419 #ifdef HAVE_XPETRA_TPETRA
420  if (lib == UseTpetra)
421  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<int, GlobalOrdinal, Node> (numElements, comm, node)));
422 #endif
423 
424 #ifdef HAVE_XPETRA_EPETRA
425 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
426  if (lib == UseEpetra)
427  {
428 
430  map = Teuchos::rcp( new EpetraMapT<int>((Xpetra::global_size_t)numElements, // num elements, global and local
431  0, // index base is zero
432  comm, LocallyReplicated, node));
433  return map.getConst();
434  }
435 #endif
436 #endif
437 
439  }
440 
443  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
444  const Teuchos::RCP<Node>& node)
445  {
446  XPETRA_MONITOR("MapFactory::Build");
447 
448 #ifdef HAVE_XPETRA_TPETRA
449  if (lib == UseTpetra)
450  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<int,GlobalOrdinal,Node> (numElements, comm, node)));
451 #endif
452 
453 #ifdef HAVE_XPETRA_EPETRA
454 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
455  if (lib == UseEpetra)
456  {
457 
459  map = Teuchos::rcp( new EpetraMapT<int>(numElements, // num elements, global and local
460  0, //index base is zero
461  comm, GloballyDistributed, node));
462  return map.getConst();
463  }
464 #endif
465 #endif
466 
468  }
469 
472  XPETRA_MONITOR("MapFactory::Build");
473 
474 #ifdef HAVE_XPETRA_TPETRA
475  if (lib == UseTpetra)
476  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
477 #endif
478 
479 #ifdef HAVE_XPETRA_EPETRA
480 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
481  if (lib == UseEpetra)
483  defaultArgNode());
484 #endif
485 #endif
486 
488  }
489 
491  createContigMap(UnderlyingLib lib, global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm) {
492  XPETRA_MONITOR("MapFactory::Build");
493 
494 #ifdef HAVE_XPETRA_TPETRA
495  if (lib == UseTpetra)
496  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createContigMap<int,GlobalOrdinal>(numElements, localNumElements, comm)));
497 #endif
498 
499 #ifdef HAVE_XPETRA_EPETRA
500 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
501  if (lib == UseEpetra)
502  return MapFactory<int, GlobalOrdinal, Node>::createContigMapWithNode(lib, numElements, localNumElements, comm, defaultArgNode() );
503 #endif
504 #endif
505 
507  }
508 
510  createContigMapWithNode(UnderlyingLib lib, global_size_t numElements, size_t localNumElements,
511  const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP<Node> &node) {
512  XPETRA_MONITOR("MapFactory::Build");
513 
514 #ifdef HAVE_XPETRA_TPETRA
515  if (lib == UseTpetra)
516  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createContigMapWithNode<int,GlobalOrdinal,Node>(numElements, localNumElements, comm, node)));
517 #endif
518 
519 #ifdef HAVE_XPETRA_EPETRA
520 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
521  if (lib == UseEpetra)
522  {
523 
525  map = Teuchos::rcp( new EpetraMapT<int>(numElements,localNumElements,
526  0, // index base is zero
527  comm, node) );
528  return map.getConst();
529  }
530 #endif
531 #endif
532 
534  }
535 
536  };
537 
538 #ifdef HAVE_XPETRA_INT_LONG_LONG
539  template <>
540  class MapFactory<int, long long> {
541 
542  typedef int LocalOrdinal;
543  typedef long long GlobalOrdinal;
545 
546  private:
548  MapFactory() {}
549 
550  public:
551 
553  // Workaround function for a deferred visual studio bug
554  //
555  // http://connect.microsoft.com/VisualStudio/feedback/details/719847/erroneous-error-c2783-could-not-deduce-template-argument
556  //
557  // Use this function for default arguments rather than calling
558  // what is the return value below. Also helps in reducing
559  // duplication in various constructors.
560  return KokkosClassic::Details::getNode<Node>();
561  }
562 
564  Build (UnderlyingLib lib,
565  global_size_t numGlobalElements,
566  int indexBase,
567  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
569  const Teuchos::RCP<Node>& node = defaultArgNode ()) {
570  XPETRA_MONITOR("MapFactory::Build");
571 
572 #ifdef HAVE_XPETRA_TPETRA
573  if (lib == UseTpetra)
574  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, indexBase, comm, lg, node) );
575 #endif
576 
577 #ifdef HAVE_XPETRA_EPETRA
578 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
579  if (lib == UseEpetra)
580  return rcp( new EpetraMapT<long long>(numGlobalElements, indexBase, comm, lg, node) );
581 #endif
582 #endif
583 
585  }
586 
588  Build (UnderlyingLib lib,
589  global_size_t numGlobalElements,
590  size_t numLocalElements,
591  int indexBase,
592  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
593  const Teuchos::RCP<Node>& node = defaultArgNode())
594  {
595  XPETRA_MONITOR("MapFactory::Build");
596 
597 #ifdef HAVE_XPETRA_TPETRA
598  if (lib == UseTpetra)
599  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, numLocalElements, indexBase, comm, node) );
600 #endif
601 
602 #ifdef HAVE_XPETRA_EPETRA
603 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
604  if (lib == UseEpetra)
605  return rcp( new EpetraMapT<long long>(numGlobalElements, numLocalElements, indexBase, comm, node) );
606 #endif
607 #endif
608 
610  }
611 
612  static RCP<Map<LocalOrdinal,GlobalOrdinal, Node> > Build(UnderlyingLib lib, global_size_t numGlobalElements, const Teuchos::ArrayView<const GlobalOrdinal> &elementList, int indexBase, const Teuchos::RCP<const Teuchos::Comm<int> > &comm, const Teuchos::RCP<Node>& node = defaultArgNode ()) {
613  XPETRA_MONITOR("MapFactory::Build");
614 
615 #ifdef HAVE_XPETRA_TPETRA
616  if (lib == UseTpetra)
617  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (numGlobalElements, elementList, indexBase, comm, node) );
618 #endif
619 
620 #ifdef HAVE_XPETRA_EPETRA
621 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
622  if (lib == UseEpetra)
623  return rcp( new EpetraMapT<long long>(numGlobalElements, elementList, indexBase, comm, node) );
624 #endif
625 #endif
626 
628  }
629 
631  static Teuchos::RCP<Map<LocalOrdinal,GlobalOrdinal, Node> > Build(const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map, LocalOrdinal numDofPerNode) {
632  XPETRA_MONITOR("MapFactory::Build");
633 
634  LocalOrdinal N = map->getNodeNumElements();
635  Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getNodeElementList();
636  Teuchos::Array<GlobalOrdinal> newElements(map->getNodeNumElements()*numDofPerNode);
637  for (LocalOrdinal i = 0; i < N; i++)
638  for (LocalOrdinal j = 0; j < numDofPerNode; j++)
639  newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
640 
641 #ifdef HAVE_XPETRA_TPETRA
642  if (map->lib() == UseTpetra)
643  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm(), map->getNode()) );
644 #endif
645 
646 #ifdef HAVE_XPETRA_EPETRA
647 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
648  if (map->lib() == UseEpetra)
649  return rcp( new EpetraMapT<long long>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm(), map->getNode()) );
650 #endif
651 #endif
652 
654  }
655 
657  createLocalMap(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm) {
658  XPETRA_MONITOR("MapFactory::Build");
659 
660 #ifdef HAVE_XPETRA_TPETRA
661  if (lib == UseTpetra)
662  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
663 #endif
664 
665 #ifdef HAVE_XPETRA_EPETRA
666 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
667  if (lib == UseEpetra)
668  return MapFactory<int, GlobalOrdinal>::createLocalMapWithNode (lib, numElements, comm,
669  defaultArgNode());
670 #endif
671 #endif
672 
674  }
675 
677  createLocalMapWithNode(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP<Node> &node) {
678  XPETRA_MONITOR("MapFactory::Build");
679 
680 #ifdef HAVE_XPETRA_TPETRA
681  if (lib == UseTpetra)
682  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createLocalMapWithNode<int, GlobalOrdinal, Node> (numElements, comm, node)));
683 #endif
684 
685 #ifdef HAVE_XPETRA_EPETRA
686 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
687  if (lib == UseEpetra)
688  {
689 
691  map = Teuchos::rcp( new EpetraMapT<long long>((Xpetra::global_size_t)numElements, // num elements, global and local
692  0, // index base is zero
693  comm, LocallyReplicated, node));
694  return map.getConst();
695  }
696 #endif
697 #endif
698 
700  }
701 
704  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
705  const Teuchos::RCP<Node>& node)
706  {
707  XPETRA_MONITOR("MapFactory::Build");
708 
709 #ifdef HAVE_XPETRA_TPETRA
710  if (lib == UseTpetra)
711  return rcp (new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<int,GlobalOrdinal,Node> (numElements, comm, node)));
712 #endif
713 
714 #ifdef HAVE_XPETRA_EPETRA
715 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
716  if (lib == UseEpetra)
717  {
718 
720  map = Teuchos::rcp( new EpetraMapT<long long>(numElements, // num elements, global and local
721  0, //index base is zero
722  comm, GloballyDistributed, node));
723  return map.getConst();
724  }
725 #endif
726 #endif
727 
729  }
730 
733  XPETRA_MONITOR("MapFactory::Build");
734 
735 #ifdef HAVE_XPETRA_TPETRA
736  if (lib == UseTpetra)
737  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal, Node>(numElements, comm)));
738 #endif
739 
740 #ifdef HAVE_XPETRA_EPETRA
741 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
742  if (lib == UseEpetra)
744  defaultArgNode());
745 #endif
746 #endif
747 
749  }
750 
752  createContigMap(UnderlyingLib lib, global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm) {
753  XPETRA_MONITOR("MapFactory::Build");
754 
755 #ifdef HAVE_XPETRA_TPETRA
756  if (lib == UseTpetra)
757  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createContigMap<int,GlobalOrdinal>(numElements, localNumElements, comm)));
758 #endif
759 
760 #ifdef HAVE_XPETRA_EPETRA
761 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
762  if (lib == UseEpetra)
763  return MapFactory<int, GlobalOrdinal, Node>::createContigMapWithNode(lib, numElements, localNumElements, comm, defaultArgNode() );
764 #endif
765 #endif
766 
768  }
769 
771  createContigMapWithNode(UnderlyingLib lib, global_size_t numElements, size_t localNumElements,
772  const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP<Node> &node) {
773  XPETRA_MONITOR("MapFactory::Build");
774 
775 #ifdef HAVE_XPETRA_TPETRA
776  if (lib == UseTpetra)
777  return rcp( new TpetraMap<LocalOrdinal,GlobalOrdinal, Node> (Tpetra::createContigMapWithNode<int,GlobalOrdinal,Node>(numElements, localNumElements, comm, node)));
778 #endif
779 
780 #ifdef HAVE_XPETRA_EPETRA
781 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
782  if (lib == UseEpetra)
783  {
784 
786  map = Teuchos::rcp( new EpetraMapT<long long>(numElements,localNumElements,
787  0, // index base is zero
788  comm, node) );
789  return map.getConst();
790  }
791 #endif
792 #endif
793 
795  }
796 
797  };
798 #endif // HAVE_XPETRA_INT_LONG_LONG
799 
800 }
801 
802 #define XPETRA_MAPFACTORY_SHORT
803 #endif
804 //TODO: removed unused methods
RCP< const T > getConst() const
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, const Teuchos::RCP< Node > &node)
Create a (potentially) non-uniform, contiguous Map with a user-specified node.
static Teuchos::RCP< Node > defaultArgNode()
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, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with Xpetra-defined contiguous uniform distribution.
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.
GlobalOrdinal global_ordinal_type
Definition: Xpetra_Map.hpp:71
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(UnderlyingLib lib, global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node)
Create a uniform, contiguous Map with a user-specified node.
MapFactory()
Private constructor. This is a static class.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, LocalOrdinal numDofPerNode)
Map constructor transforming degrees of freedom.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMap(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node)
Node node_type
Definition: Xpetra_Map.hpp:72
Xpetra namespace
static RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, int indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode())
static RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, int indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=defaultArgNode())
static RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, size_t numLocalElements, int indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode())
Map< int, GlobalOrdinal >::node_type Node
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
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, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with a user-defined contiguous distribution.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMap(UnderlyingLib lib, global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
#define XPETRA_FACTORY_END
static Teuchos::RCP< Node > defaultArgNode()
size_t global_size_t
Global size_t object.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node)
Create a locally replicated Map with a specified node.
Create an Xpetra::Map instance.
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)
#define XPETRA_MONITOR(funcName)
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, const Teuchos::RCP< Node > &node)
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, LocalOrdinal numDofPerNode)
Map constructor transforming degrees of freedom.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with user-defined non-contiguous (arbitrary) distribution.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(UnderlyingLib lib, global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node)