46 #ifndef XPETRA_MAPFACTORY_HPP
47 #define XPETRA_MAPFACTORY_HPP
52 #ifdef HAVE_XPETRA_TPETRA
55 #ifdef HAVE_XPETRA_EPETRA
69 template <class LocalOrdinal = Map<>::local_ordinal_type,
70 class GlobalOrdinal =
typename Map<LocalOrdinal>::global_ordinal_type,
71 class Node =
typename Map<LocalOrdinal, GlobalOrdinal>::node_type>
80 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
85 GlobalOrdinal indexBase,
90 return Build(lib, numGlobalElements, indexBase, comm, lg);
92 #endif // TPETRA_ENABLE_DEPRECATED_CODE
96 GlobalOrdinal indexBase,
102 #ifdef HAVE_XPETRA_TPETRA
112 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
117 size_t numLocalElements,
118 GlobalOrdinal indexBase,
122 return Build(lib, numGlobalElements, numLocalElements, indexBase, comm);
124 #endif // TPETRA_ENABLE_DEPRECATED_CODE
128 size_t numLocalElements,
129 GlobalOrdinal indexBase,
134 #ifdef HAVE_XPETRA_TPETRA
144 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
150 GlobalOrdinal indexBase,
154 return Build(lib, numGlobalElements, elementList, indexBase, comm);
156 #endif // TPETRA_ENABLE_DEPRECATED_CODE
161 GlobalOrdinal indexBase,
166 #ifdef HAVE_XPETRA_TPETRA
179 LocalOrdinal numDofPerNode)
186 "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode <<
".");
190 #ifdef HAVE_XPETRA_TPETRA
191 LocalOrdinal N = map->getNodeNumElements();
194 for (LocalOrdinal i = 0; i < N; i++)
195 for (LocalOrdinal j = 0; j < numDofPerNode; j++)
196 newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
206 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
207 #ifdef HAVE_XPETRA_TPETRA
211 const Kokkos::View<const GlobalOrdinal*, typename Node::device_type>& indexList,
212 GlobalOrdinal indexBase,
235 #ifdef HAVE_XPETRA_TPETRA
245 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
255 #endif // TPETRA_ENABLE_DEPRECATED_CODE
263 #ifdef HAVE_XPETRA_TPETRA
273 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
283 #endif // TPETRA_ENABLE_DEPRECATED_CODE
291 #ifdef HAVE_XPETRA_TPETRA
308 #ifdef HAVE_XPETRA_TPETRA
321 size_t localNumElements,
326 #ifdef HAVE_XPETRA_TPETRA
336 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
341 size_t localNumElements,
347 #endif // TPETRA_ENABLE_DEPRECATED_CODE
351 size_t localNumElements,
356 #ifdef HAVE_XPETRA_TPETRA
367 #if (defined(HAVE_XPETRA_EPETRA) && !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES))
381 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
391 return Build(lib, numGlobalElements, indexBase, comm, lg);
393 #endif // TPETRA_ENABLE_DEPRECATED_CODE
394 static RCP<Map<LocalOrdinal,GlobalOrdinal, Node> >
403 #ifdef HAVE_XPETRA_TPETRA
414 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
419 size_t numLocalElements,
424 return Build(lib, numGlobalElements, numLocalElements, indexBase, comm);
426 #endif // TPETRA_ENABLE_DEPRECATED_CODE
427 static RCP<Map<LocalOrdinal,GlobalOrdinal, Node> >
430 size_t numLocalElements,
435 #ifdef HAVE_XPETRA_TPETRA
446 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
456 return Build(lib, numGlobalElements, elementList, indexBase, comm);
458 #endif // TPETRA_ENABLE_DEPRECATED_CODE
459 static RCP<Map<LocalOrdinal,GlobalOrdinal, Node> >
467 #ifdef HAVE_XPETRA_TPETRA
487 "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode <<
".");
491 LocalOrdinal N = Teuchos::as<LocalOrdinal>(map->getNodeNumElements());
496 newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
498 #ifdef HAVE_XPETRA_TPETRA
504 return rcp(
new EpetraMapT<int, Node>(map->getGlobalNumElements()*numDofPerNode, newElements, map->getIndexBase(), map->getComm()) );
515 #ifdef HAVE_XPETRA_TPETRA
517 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
518 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
522 "Xpetra::MapFactory::createLocalMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
538 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
548 #endif // TPETRA_ENABLE_DEPRECATED_CODE
556 #ifdef HAVE_XPETRA_TPETRA
558 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
559 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
563 "Xpetra::MapFactory::createLocalMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
579 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
588 #endif // TPETRA_ENABLE_DEPRECATED_CODE
595 #ifdef HAVE_XPETRA_TPETRA
597 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
598 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
602 "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
623 #ifdef HAVE_XPETRA_TPETRA
625 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
626 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
630 "Xpetra::MapFactory::createUniformContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
649 size_t localNumElements,
653 #ifdef HAVE_XPETRA_TPETRA
655 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
656 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
660 "Xpetra::MapFactory::createContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
670 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
675 size_t localNumElements,
681 #endif // TPETRA_ENABLE_DEPRECATED_CODE
685 size_t localNumElements,
690 #ifdef HAVE_XPETRA_TPETRA
692 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT))) || \
693 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))))
697 "Xpetra::MapFactory::createContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=int");
717 #if (defined(HAVE_XPETRA_EPETRA) && !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES))
731 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
741 return Build(lib, numGlobalElements, indexBase, comm, lg);
743 #endif // TPETRA_ENABLE_DEPRECATED_CODE
744 static RCP<Map<LocalOrdinal,GlobalOrdinal, Node> >
753 #ifdef HAVE_XPETRA_TPETRA
764 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
769 size_t numLocalElements,
774 return Build(lib, numGlobalElements, numLocalElements, indexBase, comm);
776 #endif // TPETRA_ENABLE_DEPRECATED_CODE
777 static RCP<Map<LocalOrdinal,GlobalOrdinal, Node> >
780 size_t numLocalElements,
786 #ifdef HAVE_XPETRA_TPETRA
797 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
807 return Build(lib, numGlobalElements, elementList, indexBase, comm);
809 #endif // TPETRA_ENABLE_DEPRECATED_CODE
810 static RCP<Map<LocalOrdinal,GlobalOrdinal, Node> >
819 #ifdef HAVE_XPETRA_TPETRA
839 "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to " << numDofPerNode <<
".");
848 newElements[i*numDofPerNode + j] = oldElements[i]*numDofPerNode + j;
850 #ifdef HAVE_XPETRA_TPETRA
867 #ifdef HAVE_XPETRA_TPETRA
869 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
870 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
874 "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");
884 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
894 #endif // TPETRA_ENABLE_DEPRECATED_CODE
903 #ifdef HAVE_XPETRA_TPETRA
905 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
906 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
910 "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");
925 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
934 #endif // TPETRA_ENABLE_DEPRECATED_CODE
941 #ifdef HAVE_XPETRA_TPETRA
943 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
944 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
948 "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");
969 #ifdef HAVE_XPETRA_TPETRA
971 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
972 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
976 "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");
989 size_t localNumElements,
993 #ifdef HAVE_XPETRA_TPETRA
995 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
996 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
1000 "Xpetra::MapFactory::createContigMap: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
1010 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1015 size_t localNumElements,
1021 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1025 size_t localNumElements,
1030 #ifdef HAVE_XPETRA_TPETRA
1032 #if ((defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
1033 (!defined(EPETRA_HAVE_OMP) && (defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
1037 "Xpetra::MapFactory::createContigMapWithNode: Cannot create Xpetra::TpetraMap, since Tpetra is not instantiated on EpetraNode (Serial or OpenMP, depending on configuration) and/or GO=long long");
1057 #define XPETRA_MAPFACTORY_SHORT
RCP< const T > getConst() const
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, LocalOrdinal numDofPerNode)
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.
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)
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, LocalOrdinal numDofPerNode)
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 > > 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.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, LocalOrdinal numDofPerNode)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
MapFactory()
Private constructor. This is a static class.
Exception throws to report errors in the internal logical of the program.
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
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)
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(UnderlyingLib lib, global_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)
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)
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 > > 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< 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)
Map constructor with user-defined non-contiguous (arbitrary) distribution.
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.
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)
Map constructor with a user-defined contiguous distribution.
MapFactory()
Private constructor. This is a static class.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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)
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 > > createUniformContigMapWithNode(UnderlyingLib lib, global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
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)
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.
static Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(UnderlyingLib lib, size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
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< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMap(UnderlyingLib lib, global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
size_t global_size_t
Global size_t object.
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)
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)
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)
#define XPETRA_MONITOR(funcName)
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 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)
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)
MapFactory()
Private constructor. This is a static class.