10 #ifndef XPETRA_MAPFACTORY_DEF_HPP
11 #define XPETRA_MAPFACTORY_DEF_HPP
15 #ifdef HAVE_XPETRA_TPETRA
16 #include "Xpetra_TpetraMap.hpp"
18 #ifdef HAVE_XPETRA_EPETRA
22 #include "Xpetra_BlockedMap.hpp"
26 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
27 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
31 GlobalOrdinal indexBase,
32 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm,
36 #ifdef HAVE_XPETRA_TPETRA
45 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
46 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
50 size_t numLocalElements,
51 GlobalOrdinal indexBase,
52 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
55 #ifdef HAVE_XPETRA_TPETRA
64 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
65 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
69 const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
70 GlobalOrdinal indexBase,
71 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
74 #ifdef HAVE_XPETRA_TPETRA
83 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
84 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
87 const LocalOrdinal numDofPerNode,
const GlobalOrdinal gidOffset) {
90 RCP<const BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> bmap =
93 if (!bmap.is_null()) {
95 "Xpetra::MapFactory::Build: When provided a BlockedMap numDofPerNode must set to be one. It is set to "
96 << numDofPerNode <<
".");
100 #ifdef HAVE_XPETRA_TPETRA
101 LocalOrdinal numLocalElements = nodeMap->getLocalNumElements();
102 Teuchos::ArrayView<const GlobalOrdinal> oldElements = nodeMap->getLocalElementList();
103 Teuchos::Array<GlobalOrdinal> newElements(nodeMap->getLocalNumElements() * numDofPerNode);
104 for (LocalOrdinal i = 0; i < numLocalElements; i++) {
105 for (LocalOrdinal j = 0; j < numDofPerNode; j++) {
106 newElements[i * numDofPerNode + j] = oldElements[i] * numDofPerNode + j + gidOffset;
110 return rcp(
new TpetraMap<LocalOrdinal, GlobalOrdinal, Node>(nodeMap->getGlobalNumElements() * numDofPerNode, newElements, nodeMap->getIndexBase(), nodeMap->getComm()));
118 #ifdef HAVE_XPETRA_TPETRA
119 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 Teuchos::RCP<Map<LocalOrdinal, GlobalOrdinal, Node>>
124 const Kokkos::View<const GlobalOrdinal*, typename Node::device_type>& indexList,
125 GlobalOrdinal indexBase,
126 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
133 #endif // HAVE_XPETRA_TPETRA
135 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
136 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
140 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
143 #ifdef HAVE_XPETRA_TPETRA
153 #endif // HAVE_XPETRA_TPETRA
159 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
160 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
164 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
167 #ifdef HAVE_XPETRA_TPETRA
171 #endif // HAVE_XPETRA_TPETRA
177 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
178 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
182 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
185 #ifdef HAVE_XPETRA_TPETRA
188 Tpetra::createUniformContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, comm)));
189 #endif // HAVE_XPETRA_TPETRA
195 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
196 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
200 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
203 #ifdef HAVE_XPETRA_TPETRA
206 Tpetra::createUniformContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, comm)));
207 #endif // HAVE_XPETRA_TPETRA
213 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
214 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
218 size_t localNumElements,
219 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
222 #ifdef HAVE_XPETRA_TPETRA
225 Tpetra::createContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
226 #endif // HAVE_XPETRA_TPETRA
232 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
233 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
237 size_t localNumElements,
238 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
241 #ifdef HAVE_XPETRA_TPETRA
244 Tpetra::createContigMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(numElements, localNumElements, comm)));
246 #endif // HAVE_XPETRA_TPETRA
252 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
253 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
256 const Teuchos::RCP<
const Teuchos::Comm<int>>& newComm) {
259 global_size_t INVALID = Teuchos::OrdinalTraits<global_size_t>::invalid();
261 size_t Nlocal = oldmap->getLocalNumElements();
265 TEUCHOS_TEST_FOR_EXCEPTION(Nlocal && newComm.is_null(),
266 std::logic_error,
"MapFactory::copyMapWithNewComm needs the comm to match the map.");
269 RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> newMap;
270 if (!newComm.is_null()) {
271 if (oldmap->isContiguous()) {
272 newMap = XMF::Build(oldmap->lib(), INVALID, Nlocal, oldmap->getIndexBase(), newComm);
274 newMap = XMF::Build(oldmap->lib(), Nglobal, oldmap->getLocalElementList(), oldmap->getIndexBase(), newComm);
284 #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.