49 #ifndef XPETRA_STRIDEDMAPFACTORY_HPP
50 #define XPETRA_STRIDEDMAPFACTORY_HPP
63 template <class LocalOrdinal = StridedMap<>::local_ordinal_type,
65 typename StridedMap<LocalOrdinal>::global_ordinal_type,
67 typename StridedMap<LocalOrdinal, GlobalOrdinal>::node_type>
68 class StridedMapFactory {
69 #undef XPETRA_STRIDEDMAPFACTORY_SHORT
79 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
83 LocalOrdinal stridedBlockId, GlobalOrdinal offset,
LocalGlobal lg,
86 return Build(lib, numGlobalElements, indexBase, stridingInfo, comm,
87 stridedBlockId, offset, lg);
89 #endif // TPETRA_ENABLE_DEPRECATED_CODE
94 return rcp(
new StridedMap(lib, numGlobalElements, indexBase, stridingInfo, comm, stridedBlockId, offset, lg));
98 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
102 LocalOrdinal stridedBlockId, GlobalOrdinal offset,
105 return Build(lib, numGlobalElements, numLocalElements, indexBase,
106 stridingInfo, comm, stridedBlockId, offset);
108 #endif // TPETRA_ENABLE_DEPRECATED_CODE
111 LocalOrdinal stridedBlockId = -1, GlobalOrdinal offset = 0)
113 return rcp(
new StridedMap(lib, numGlobalElements, numLocalElements, indexBase, stridingInfo, comm, stridedBlockId, offset));
117 return rcp(
new StridedMap(map, stridingInfo, map->getIndexBase(), stridedBlockId, offset));
123 "Xpetra::StridedMapFactory::Build: constructor expects stridedBlockId > -1.");
125 "Xpetra::StridedMapFactory::Build: constructor expects a full map (stridedBlockId == -1).");
127 std::vector<size_t> stridingInfo = map->getStridingData();
133 size_t nStridedOffset = 0;
134 for (
int j = 0; j < map->getStridedBlockId(); j++)
135 nStridedOffset += stridingInfo[j];
137 size_t numMyBlockDofs = (stridingInfo[stridedBlockId] * map->getNodeNumElements()) / map->getFixedBlockSize();
138 std::vector<GlobalOrdinal> subBlockDofGids(numMyBlockDofs);
141 LocalOrdinal ind = 0;
143 if (map->GID2StridingBlockId(*it) == Teuchos::as<size_t>(stridedBlockId))
144 subBlockDofGids[ind++] = *it;
158 for (LocalOrdinal i = 0; i < N; i++)
159 newElements[i] = oldElements[i];
168 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
174 GlobalOrdinal indexBase,
175 std::vector<size_t>& stridingInfo,
177 LocalOrdinal stridedBlockId,
178 GlobalOrdinal offset,
181 return Build(lib, numGlobalElements, elementList, indexBase, stridingInfo,
182 comm, stridedBlockId, offset);
184 #endif // TPETRA_ENABLE_DEPRECATED_CODE
185 static RCP<StridedMap>
189 GlobalOrdinal indexBase,
190 std::vector<size_t>& stridingInfo,
192 LocalOrdinal stridedBlockId = -1,
195 return rcp (
new StridedMap (lib, numGlobalElements, elementList,
196 indexBase, stridingInfo, comm,
202 #define XPETRA_STRIDEDMAPFACTORY_SHORT
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)
Map constructor with Xpetra-defined contiguous uniform distribution.
static RCP< StridedMap > Build(const RCP< const Map > &map, std::vector< size_t > &stridingInfo, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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.
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)
Map constructor with a user-defined contiguous distribution.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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...
std::vector< size_t > getStridingData() const
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.
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=0)
Map constructor with a user-defined contiguous distribution. (for experts only. There is no special c...
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< StridedMap > Build(const RCP< const StridedMap > &map, LocalOrdinal stridedBlockId)
Class that stores a strided map.