10 #ifndef XPETRA_MAPFACTORY_DEF_HPP
11 #define XPETRA_MAPFACTORY_DEF_HPP
13 #include "Teuchos_CompilerCodeTweakMacros.hpp"
14 #include "Teuchos_ENull.hpp"
17 #ifdef HAVE_XPETRA_TPETRA
18 #include "Xpetra_TpetraMap.hpp"
20 #ifdef HAVE_XPETRA_EPETRA
24 #include "Xpetra_BlockedMap.hpp"
28 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
29 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
33 GlobalOrdinal indexBase,
34 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm,
38 #ifdef HAVE_XPETRA_TPETRA
47 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
48 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
52 size_t numLocalElements,
53 GlobalOrdinal indexBase,
54 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
57 #ifdef HAVE_XPETRA_TPETRA
66 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
71 const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
72 GlobalOrdinal indexBase,
73 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
76 #ifdef HAVE_XPETRA_TPETRA
85 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
86 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
89 const LocalOrdinal numDofPerNode,
const GlobalOrdinal gidOffset) {
92 RCP<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> bmap =
95 if (!bmap.is_null()) {
97 "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to "
98 << numDofPerNode <<
".");
102 #ifdef HAVE_XPETRA_TPETRA
103 LocalOrdinal numLocalElements = nodeMap->getLocalNumElements();
104 Teuchos::ArrayView<const GlobalOrdinal> oldElements = nodeMap->getLocalElementList();
105 Teuchos::Array<GlobalOrdinal> newElements(nodeMap->getLocalNumElements() * numDofPerNode);
106 for (LocalOrdinal i = 0; i < numLocalElements; i++) {
107 for (LocalOrdinal j = 0; j < numDofPerNode; j++) {
108 newElements[i * numDofPerNode + j] = oldElements[i] * numDofPerNode + j + gidOffset;
112 return rcp(
new TpetraMap<LocalOrdinal, GlobalOrdinal, Node>(nodeMap->getGlobalNumElements() * numDofPerNode, newElements, nodeMap->getIndexBase(), nodeMap->getComm()));
118 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
121 #ifdef HAVE_XPETRA_TPETRA
122 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
123 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
127 const Kokkos::View<const GlobalOrdinal*, typename Node::device_type>& indexList,
128 GlobalOrdinal indexBase,
129 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
136 #endif // HAVE_XPETRA_TPETRA
138 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
139 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
143 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
146 #ifdef HAVE_XPETRA_TPETRA
156 #endif // HAVE_XPETRA_TPETRA
162 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
163 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
167 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
170 #ifdef HAVE_XPETRA_TPETRA
174 #endif // HAVE_XPETRA_TPETRA
180 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
181 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
185 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
188 #ifdef HAVE_XPETRA_TPETRA
191 Tpetra::createUniformContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, comm)));
192 #endif // HAVE_XPETRA_TPETRA
198 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
199 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
203 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
206 #ifdef HAVE_XPETRA_TPETRA
209 Tpetra::createUniformContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, comm)));
210 #endif // HAVE_XPETRA_TPETRA
216 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
217 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
221 size_t localNumElements,
222 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
225 #ifdef HAVE_XPETRA_TPETRA
228 Tpetra::createContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
229 #endif // HAVE_XPETRA_TPETRA
235 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
236 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
240 size_t localNumElements,
241 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
244 #ifdef HAVE_XPETRA_TPETRA
247 Tpetra::createContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
249 #endif // HAVE_XPETRA_TPETRA
255 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
256 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
259 const Teuchos::RCP<
const Teuchos::Comm<int>>& newComm) {
262 global_size_t INVALID = Teuchos::OrdinalTraits<global_size_t>::invalid();
264 size_t Nlocal = oldmap->getLocalNumElements();
268 TEUCHOS_TEST_FOR_EXCEPTION(Nlocal && newComm.is_null(),
269 std::logic_error,
"MapFactory::copyMapWithNewComm needs the comm to match the map.");
272 RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> newMap;
273 if (!newComm.is_null()) {
274 if (oldmap->isContiguous()) {
275 newMap = XMF::Build(oldmap->lib(), INVALID, Nlocal, oldmap->getIndexBase(), newComm);
277 newMap = XMF::Build(oldmap->lib(), Nglobal, oldmap->getLocalElementList(), oldmap->getIndexBase(), newComm);
287 #endif // XPETRA_MAPFACTORY_DEF_HPP
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.
Exception throws to report errors in the internal logical of the program.
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
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.
Create an Xpetra::Map instance.
#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.