46 #include "Xpetra_MapFactory.hpp"
48 #include "Xpetra_BlockedMap.hpp"
50 #ifdef HAVE_XPETRA_TPETRA
51 #include "Xpetra_TpetraMap.hpp"
56 #if defined(HAVE_XPETRA_EPETRA)
59 #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
70 RCP<Map<int, int, EpetraNode>>
75 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
80 #ifdef HAVE_XPETRA_TPETRA
94 RCP<Map<int, int, EpetraNode> >
98 size_t numLocalElements,
100 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm)
104 #ifdef HAVE_XPETRA_TPETRA
118 RCP<Map<int, int, EpetraNode> >
122 const Teuchos::ArrayView<const int> &elementList,
124 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm)
128 #ifdef HAVE_XPETRA_TPETRA
131 #endif // HAVE_XPETRA_TPETRA
142 Teuchos::RCP<Map<int, int, EpetraNode> >
153 "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode <<
".");
157 LocalOrdinal N = Teuchos::as<LocalOrdinal>(map->getNodeNumElements());
158 Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getNodeElementList();
159 Teuchos::Array<GlobalOrdinal> newElements(map->getNodeNumElements()*numDofPerNode);
164 newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
168 #ifdef HAVE_XPETRA_TPETRA
173 #endif // HAVE_XPETRA_TPETRA
177 return rcp(
new EpetraMapT<int, Node>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
184 Teuchos::RCP<const Map<int, int, EpetraNode> >
188 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
192 #ifdef HAVE_XPETRA_TPETRA
194 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
195 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
199 "Xpetra::MapFactory::createLocalMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
201 #endif // HAVE_XPETRA_TPETRA
204 Teuchos::RCP< EpetraMapT<int, Node> > map;
209 return map.getConst();
220 Teuchos::RCP< const Map<int, int, EpetraNode> >
224 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
228 #ifdef HAVE_XPETRA_TPETRA
230 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
231 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
235 "Xpetra::MapFactory::createLocalMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
237 #endif // HAVE_XPETRA_TPETRA
240 Teuchos::RCP< EpetraMapT<int, Node> > map;
244 return map.getConst();
256 Teuchos::RCP< const Map<int, int, EpetraNode> >
260 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
264 #ifdef HAVE_XPETRA_TPETRA
266 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
267 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
271 "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
273 #endif // HAVE_XPETRA_TPETRA
276 Teuchos::RCP< EpetraMapT<int,Node> > map;
280 return map.getConst();
287 Teuchos::RCP< const Map<int, int, EpetraNode> >
291 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
295 #ifdef HAVE_XPETRA_TPETRA
297 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
298 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
302 "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
304 #endif // HAVE_XPETRA_TPETRA
308 Teuchos::RCP< EpetraMapT<int,Node> > map;
312 return map.getConst();
318 Teuchos::RCP< const Map<int, int, EpetraNode> >
322 size_t localNumElements,
323 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
327 #ifdef HAVE_XPETRA_TPETRA
329 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
330 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
334 "Xpetra::MapFactory::createContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
349 Teuchos::RCP< const Map<int, int, EpetraNode> >
353 size_t localNumElements,
354 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
358 #ifdef HAVE_XPETRA_TPETRA
360 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
361 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
365 "Xpetra::MapFactory::createContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
371 Teuchos::RCP< EpetraMapT<int, Node> > map;
375 return map.getConst();
382 #endif // #if !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES)
392 #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
405 RCP<Map<int, long long, EpetraNode>>
410 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
415 #ifdef HAVE_XPETRA_TPETRA
429 RCP<Map<int, long long, EpetraNode> >
433 size_t numLocalElements,
435 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm)
439 #ifdef HAVE_XPETRA_TPETRA
453 RCP<Map<int, long long, EpetraNode> >
457 const Teuchos::ArrayView<const long long> &elementList,
459 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm)
463 #ifdef HAVE_XPETRA_TPETRA
476 Teuchos::RCP<Map<int, long long, EpetraNode> >
484 if(!bmap.is_null()) {
486 "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode <<
".");
491 Teuchos::ArrayView<const GlobalOrdinal> oldElements = map->getNodeElementList();
492 Teuchos::Array<GlobalOrdinal> newElements(map->getNodeNumElements()*numDofPerNode);
495 newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
497 #ifdef HAVE_XPETRA_TPETRA
503 return rcp(
new EpetraMapT<long long, Node>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
509 Teuchos::RCP<const Map<int, long long, EpetraNode> >
513 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
517 #ifdef HAVE_XPETRA_TPETRA
519 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
520 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
524 "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");
537 Teuchos::RCP< const Map<int, long long, EpetraNode> >
541 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
545 #ifdef HAVE_XPETRA_TPETRA
547 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
548 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
552 "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");
558 Teuchos::RCP< EpetraMapT<long long, Node> > map;
562 return map.getConst();
570 Teuchos::RCP< const Map<int, long long, EpetraNode> >
574 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
578 #ifdef HAVE_XPETRA_TPETRA
580 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
581 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
585 "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");
591 Teuchos::RCP< EpetraMapT<long long, Node> > map;
595 return map.getConst();
601 Teuchos::RCP< const Map<int, long long, EpetraNode> >
605 const Teuchos::RCP<
const Teuchos::Comm< int > > &comm)
609 #ifdef HAVE_XPETRA_TPETRA
611 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
612 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
616 "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");
627 Teuchos::RCP<const Map<int, long long, EpetraNode>>
630 size_t localNumElements,
631 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
635 #ifdef HAVE_XPETRA_TPETRA
637 #if((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
638 || (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
640 Tpetra::createContigMapWithNode<int, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
642 TEUCHOS_TEST_FOR_EXCEPTION(
true,
644 "Xpetra::MapFactory::createContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on "
645 "EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
658 Teuchos::RCP<const Map<int, long long, EpetraNode>>
662 size_t localNumElements,
663 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
667 #ifdef HAVE_XPETRA_TPETRA
669 #if((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
670 || (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
672 Tpetra::createContigMapWithNode<int, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
674 TEUCHOS_TEST_FOR_EXCEPTION(
true,
676 "Xpetra::MapFactory::createContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not "
677 "instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
679 #endif // HAVE_XPETRA_TPETRA
683 Teuchos::RCP<EpetraMapT<long long, Node>> map;
688 return map.getConst();
696 #endif // #if !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES)
699 #endif // #if defined(HAVE_XPETRA_EPETRA)
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.
Exception throws to report errors in the internal logical of the program.
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.
#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.