12 #ifndef XPETRA_STRIDEDMAPFACTORY_DEF_HPP
13 #define XPETRA_STRIDEDMAPFACTORY_DEF_HPP
21 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
22 RCP<Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node>>
26 GlobalOrdinal indexBase,
27 std::vector<size_t>& stridingInfo,
28 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm,
29 LocalOrdinal stridedBlockId,
35 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
36 RCP<Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node>>
40 size_t numLocalElements,
41 GlobalOrdinal indexBase,
42 std::vector<size_t>& stridingInfo,
43 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm,
44 LocalOrdinal stridedBlockId,
45 GlobalOrdinal offset) {
46 return rcp(
new StridedMap(lib, numGlobalElements, numLocalElements, indexBase, stridingInfo, comm, stridedBlockId, offset));
49 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
50 RCP<Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node>>
52 Build(
const RCP<const Map>& map,
53 std::vector<size_t>& stridingInfo,
54 LocalOrdinal stridedBlockId,
55 GlobalOrdinal offset) {
56 return rcp(
new StridedMap(map, stridingInfo, map->getIndexBase(), stridedBlockId, offset));
59 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
60 RCP<Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node>>
62 Build(
const RCP<const StridedMap>& map, LocalOrdinal stridedBlockId) {
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();
71 Teuchos::ArrayView<const GlobalOrdinal> dofGids = map->getLocalElementList();
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);
85 for (
typename Teuchos::ArrayView<const GlobalOrdinal>::iterator it = dofGids.begin(); it != dofGids.end(); ++it) {
86 if (map->GID2StridingBlockId(*it) == Teuchos::as<size_t>(stridedBlockId)) {
87 subBlockDofGids[ind++] = *it;
91 const Teuchos::ArrayView<const GlobalOrdinal> subBlockDofGids_view(&subBlockDofGids[0], subBlockDofGids.size());
94 Teuchos::OrdinalTraits<global_size_t>::invalid(),
102 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 RCP<Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node>>
112 for (LocalOrdinal i = 0; i < N; i++)
113 newElements[i] = oldElements[i];
119 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 RCP<Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node>>
124 const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
125 GlobalOrdinal indexBase,
126 std::vector<size_t>& stridingInfo,
127 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm,
128 LocalOrdinal stridedBlockId,
130 return rcp(
new StridedMap(lib, numGlobalElements, elementList, indexBase, stridingInfo, comm, stridedBlockId));
135 #endif // XPETRA_STRIDEDMAPFACTORY_DEF_HPP
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a list of the global indices owned by this node.
LocalOrdinal getStridedBlockId() const
size_t getLocalNumElements() const
Returns the number of elements belonging to the calling node.
Exception throws to report errors in the internal logical of the program.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get the Comm object for this Map.
size_t global_size_t
Global size_t object.
GlobalOrdinal getIndexBase() const
Returns the index base for this Map.
global_size_t getGlobalNumElements() const
Returns the number of elements in this Map.
std::vector< size_t > getStridingData() const
UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
#define XPETRA_MONITOR(funcName)
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.