12#ifndef XPETRA_STRIDEDMAPFACTORY_DEF_HPP
13#define XPETRA_STRIDEDMAPFACTORY_DEF_HPP
21template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
22RCP<Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node>>
26 GlobalOrdinal indexBase,
27 std::vector<size_t>& stridingInfo,
29 LocalOrdinal stridedBlockId,
35template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
40 size_t numLocalElements,
41 GlobalOrdinal indexBase,
42 std::vector<size_t>& stridingInfo,
44 LocalOrdinal stridedBlockId,
45 GlobalOrdinal offset) {
46 return rcp(
new StridedMap(lib, numGlobalElements, numLocalElements, indexBase, stridingInfo, comm, stridedBlockId, offset));
49template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
53 std::vector<size_t>& stridingInfo,
54 LocalOrdinal stridedBlockId,
55 GlobalOrdinal offset) {
56 return rcp(
new StridedMap(map, stridingInfo, map->getIndexBase(), stridedBlockId, offset));
59template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 "Xpetra::StridedMapFactory::Build: constructor expects stridedBlockId > -1.");
67 "Xpetra::StridedMapFactory::Build: constructor expects a full map (stridedBlockId == -1).");
69 std::vector<size_t> stridingInfo = map->getStridingData();
74 size_t nStridedOffset = 0;
75 for (
int j = 0; j < map->getStridedBlockId(); j++) {
76 nStridedOffset += stridingInfo[j];
79 const size_t numMyBlockDofs = (stridingInfo[stridedBlockId] * map->getLocalNumElements()) / map->getFixedBlockSize();
81 std::vector<GlobalOrdinal> subBlockDofGids(numMyBlockDofs);
86 if (map->GID2StridingBlockId(*it) == Teuchos::as<size_t>(stridedBlockId)) {
87 subBlockDofGids[ind++] = *it;
102template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
112 for (LocalOrdinal i = 0; i < N; i++)
113 newElements[i] = oldElements[i];
119template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
125 GlobalOrdinal indexBase,
126 std::vector<size_t>& stridingInfo,
128 LocalOrdinal stridedBlockId,
130 return rcp(
new StridedMap(lib, numGlobalElements, elementList, indexBase, stridingInfo, comm, stridedBlockId));
#define XPETRA_MONITOR(funcName)
Exception throws to report errors in the internal logical of the program.
static RCP< Xpetra::StridedMap< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, std::vector< size_t > &stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0, LocalGlobal lg=Xpetra::GloballyDistributed)
Map constructor with Xpetra-defined contiguous uniform distribution.
Class that stores a strided map.
UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
global_size_t getGlobalNumElements() const
Returns the number of elements in this Map.
LocalOrdinal getStridedBlockId() const
size_t getLocalNumElements() const
Returns the number of elements belonging to the calling node.
std::vector< size_t > getStridingData() const
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get the Comm object for this Map.
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a list of the global indices owned by this node.
GlobalOrdinal getIndexBase() const
Returns the index base for this Map.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
size_t global_size_t
Global size_t object.