49 #ifndef XPETRA_STRIDEDMAPFACTORY_HPP 50 #define XPETRA_STRIDEDMAPFACTORY_HPP 63 template <class LocalOrdinal = StridedMap<>::local_ordinal_type,
68 class StridedMapFactory {
69 #undef XPETRA_STRIDEDMAPFACTORY_SHORT 84 return KokkosClassic::Details::getNode<Node>();
89 std::vector<size_t>& stridingInfo,
const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
93 return rcp(
new StridedMap(lib, numGlobalElements, indexBase, stridingInfo, comm, stridedBlockId, offset, lg, node));
98 std::vector<size_t>& stridingInfo,
const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
99 LocalOrdinal stridedBlockId = -1, GlobalOrdinal offset = 0,
102 return rcp(
new StridedMap(lib, numGlobalElements, numLocalElements, indexBase, stridingInfo, comm, stridedBlockId, offset, node));
105 static RCP<StridedMap>
Build(
const RCP<const Map>& map, std::vector<size_t>& stridingInfo, LocalOrdinal stridedBlockId = -1, GlobalOrdinal offset = 0) {
106 return rcp(
new StridedMap(map, stridingInfo, map->getIndexBase(), stridedBlockId, offset));
110 static RCP<StridedMap>
Build(
const RCP<const StridedMap>& map, LocalOrdinal stridedBlockId) {
112 "Xpetra::StridedMapFactory::Build: constructor expects stridedBlockId > -1.");
114 "Xpetra::StridedMapFactory::Build: constructor expects a full map (stridedBlockId == -1).");
116 std::vector<size_t> stridingInfo = map->getStridingData();
118 Teuchos::ArrayView<const GlobalOrdinal> dofGids = map->getNodeElementList();
122 size_t nStridedOffset = 0;
123 for (
int j = 0; j < map->getStridedBlockId(); j++)
124 nStridedOffset += stridingInfo[j];
126 size_t numMyBlockDofs = (stridingInfo[stridedBlockId] * map->getNodeNumElements()) / map->getFixedBlockSize();
127 std::vector<GlobalOrdinal> subBlockDofGids(numMyBlockDofs);
130 LocalOrdinal ind = 0;
131 for (
typename Teuchos::ArrayView< const GlobalOrdinal >::iterator it = dofGids.begin(); it!=dofGids.end(); ++it)
132 if (map->GID2StridingBlockId(*it) == Teuchos::as<size_t>(stridedBlockId))
133 subBlockDofGids[ind++] = *it;
135 const Teuchos::ArrayView<const GlobalOrdinal> subBlockDofGids_view(&subBlockDofGids[0],subBlockDofGids.size());
137 return rcp(
new StridedMap(map->lib(), Teuchos::OrdinalTraits<global_size_t>::invalid(), subBlockDofGids_view, map->getIndexBase(), stridingInfo, map->getComm(), stridedBlockId, map->getNode()));
147 for (LocalOrdinal i = 0; i < N; i++)
148 newElements[i] = oldElements[i];
157 static RCP<StridedMap>
160 const Teuchos::ArrayView<const GlobalOrdinal> &elementList,
161 GlobalOrdinal indexBase,
162 std::vector<size_t>& stridingInfo,
163 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
164 LocalOrdinal stridedBlockId = -1,
165 GlobalOrdinal offset = 0,
168 return rcp (
new StridedMap (lib, numGlobalElements, elementList,
169 indexBase, stridingInfo, comm,
170 stridedBlockId, node));
175 #define XPETRA_STRIDEDMAPFACTORY_SHORT
std::vector< size_t > getStridingData() const
GlobalOrdinal global_ordinal_type
static RCP< StridedMap > Build(const RCP< const Map > &map, std::vector< size_t > &stridingInfo, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0)
GlobalOrdinal getIndexBase() const
Returns the index base for this Map.
static RCP< StridedMap > Build(UnderlyingLib lib, global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, std::vector< size_t > &stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with a user-defined contiguous distribution.
Exception throws to report errors in the internal logical of the program.
Teuchos::RCP< Node > getNode() const
Get the Node object for this Map.
global_size_t getGlobalNumElements() const
Returns the number of elements in this Map.
static RCP< StridedMap > Build(UnderlyingLib lib, global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, std::vector< size_t > &stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with a user-defined contiguous distribution. (for experts only. There is no special c...
static RCP< StridedMap > Build(const StridedMap &map)
Create copy of existing map (this just creates a copy of your map, it's not a clone in the sense of T...
LocalOrdinal getStridedBlockId() const
static RCP< StridedMap > 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, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with Xpetra-defined contiguous uniform distribution.
UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
size_t global_size_t
Global size_t object.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get the Comm object for this Map.
StridedMapFactory()
Private constructor. This is a static class.
#define XPETRA_MONITOR(funcName)
static Teuchos::RCP< Node > defaultArgNode()
static RCP< StridedMap > Build(const RCP< const StridedMap > &map, LocalOrdinal stridedBlockId)
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a list of the global indices owned by this node.
Class that stores a strided map.
size_t getNodeNumElements() const
Returns the number of elements belonging to the calling node.