49 #ifndef XPETRA_STRIDEDMAPFACTORY_DEF_HPP
50 #define XPETRA_STRIDEDMAPFACTORY_DEF_HPP
65 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
74 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
75 RCP<Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node>>
79 GlobalOrdinal indexBase,
80 std::vector<size_t>& stridingInfo,
81 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm,
82 LocalOrdinal stridedBlockId,
92 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
93 RCP<Xpetra::StridedMap<LocalOrdinal,GlobalOrdinal,Node>>
97 size_t numLocalElements,
98 GlobalOrdinal indexBase,
99 std::vector<size_t>& stridingInfo,
100 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm,
101 LocalOrdinal stridedBlockId,
102 GlobalOrdinal offset)
104 return rcp(
new StridedMap(lib, numGlobalElements, numLocalElements, indexBase, stridingInfo, comm, stridedBlockId, offset));
108 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
109 RCP<Xpetra::StridedMap<LocalOrdinal,GlobalOrdinal,Node>>
112 std::vector<size_t>& stridingInfo,
113 LocalOrdinal stridedBlockId,
114 GlobalOrdinal offset)
116 return rcp(
new StridedMap(map, stridingInfo, map->getIndexBase(), stridedBlockId, offset));
120 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
121 RCP<Xpetra::StridedMap<LocalOrdinal,GlobalOrdinal,Node>>
123 Build(
const RCP<const StridedMap>& map, LocalOrdinal stridedBlockId)
125 TEUCHOS_TEST_FOR_EXCEPTION(stridedBlockId < 0,
127 "Xpetra::StridedMapFactory::Build: constructor expects stridedBlockId > -1.");
129 TEUCHOS_TEST_FOR_EXCEPTION(map->getStridedBlockId() != -1,
131 "Xpetra::StridedMapFactory::Build: constructor expects a full map (stridedBlockId == -1).");
133 std::vector<size_t> stridingInfo = map->getStridingData();
135 Teuchos::ArrayView<const GlobalOrdinal> dofGids = map->getNodeElementList();
139 size_t nStridedOffset = 0;
140 for(
int j = 0; j < map->getStridedBlockId(); j++)
142 nStridedOffset += stridingInfo[ j ];
145 size_t numMyBlockDofs = (stridingInfo[ stridedBlockId ] * map->getNodeNumElements()) / map->getFixedBlockSize();
147 std::vector<GlobalOrdinal> subBlockDofGids(numMyBlockDofs);
150 LocalOrdinal ind = 0;
151 for(
typename Teuchos::ArrayView<const GlobalOrdinal>::iterator it = dofGids.begin(); it != dofGids.end(); ++it)
153 if(map->GID2StridingBlockId(*it) == Teuchos::as<size_t>(stridedBlockId))
155 subBlockDofGids[ ind++ ] = *it;
159 const Teuchos::ArrayView<const GlobalOrdinal> subBlockDofGids_view(&subBlockDofGids[ 0 ], subBlockDofGids.size());
162 Teuchos::OrdinalTraits<global_size_t>::invalid(),
163 subBlockDofGids_view,
171 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
172 RCP<Xpetra::StridedMap<LocalOrdinal,GlobalOrdinal,Node>>
182 for(LocalOrdinal i = 0; i < N; i++)
184 newElements[ i ] = oldElements[ i ];
196 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
197 RCP<Xpetra::StridedMap<LocalOrdinal,GlobalOrdinal,Node>>
201 const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
202 GlobalOrdinal indexBase,
203 std::vector<size_t>& stridingInfo,
204 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm,
205 LocalOrdinal stridedBlockId,
208 return rcp(
new StridedMap(lib, numGlobalElements, elementList, indexBase, stridingInfo, comm, stridedBlockId));
217 #endif // __XPETRA_STRIDEDMAPFACTORY_DEF_HPP__
LocalOrdinal getStridedBlockId() const
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a list of the global indices owned by this 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 getNodeNumElements() const
Returns the number of elements belonging to the calling node.
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?)
StridedMapFactory()
Private constructor. This is a static class.
#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.