49 #ifndef XPETRA_STRIDEDTPETRAMAP_HPP
50 #define XPETRA_STRIDEDTPETRAMAP_HPP
54 #include <Tpetra_Map_decl.hpp>
63 template <
class LocalOrdinal,
class GlobalOrdinal = LocalOrdinal,
class Node = Kokkos::DefaultNode::DefaultNodeType>
64 class StridedTpetraMap
65 :
public virtual TpetraMap<LocalOrdinal,GlobalOrdinal,Node>,
public virtual StridedMap<LocalOrdinal,GlobalOrdinal,Node> {
92 : Xpetra::
TpetraMap<LocalOrdinal,
GlobalOrdinal,
Node>(numGlobalElements, indexBase, comm, lg, node), Xpetra::
StridedMap<LocalOrdinal,
GlobalOrdinal,
Node>(numGlobalElements, indexBase, stridingInfo, comm, stridedBlockId, offset)
99 numGlobalNodes = numGlobalElements / StridedMapClass::getFixedBlockSize();
105 size_t nStridedOffset = 0;
106 size_t nDofsPerNode = StridedMapClass::getFixedBlockSize();
107 if(stridedBlockId > -1) {
109 for(
int j=0; j<stridedBlockId; j++) {
110 nStridedOffset += stridingInfo[j];
112 nDofsPerNode = stridingInfo[stridedBlockId];
114 numGlobalElements = nodeMap->getGlobalNumElements()*Teuchos::as<global_size_t>(nDofsPerNode);
116 std::vector<GlobalOrdinal> dofgids;
117 for(LocalOrdinal i = 0; i<Teuchos::as<LocalOrdinal>(nodeMap->getNodeNumElements()); i++) {
119 for(
size_t dof = 0; dof < nDofsPerNode; ++dof) {
122 dofgids.push_back(indexBase + StridedMapClass::offset_ + (gid-indexBase)*Teuchos::as<GlobalOrdinal>(StridedMapClass::getFixedBlockSize()) + Teuchos::as<GlobalOrdinal>(nStridedOffset + dof));
130 if(stridedBlockId == -1) {
135 int nDofsInStridedBlock = stridingInfo[stridedBlockId];
165 : Xpetra::
TpetraMap<LocalOrdinal,
GlobalOrdinal,
Node>(numGlobalElements, numLocalElements, indexBase, comm, node), Xpetra::
StridedMap<LocalOrdinal,
GlobalOrdinal,
Node>(numGlobalElements, numLocalElements, indexBase, stridingInfo, comm, stridedBlockId, offset)
172 numGlobalNodes = numGlobalElements / StridedMapClass::getFixedBlockSize();
173 global_size_t numLocalNodes = numLocalElements / StridedMapClass::getFixedBlockSize();
179 size_t nStridedOffset = 0;
180 size_t nDofsPerNode = StridedMapClass::getFixedBlockSize();
181 if(stridedBlockId > -1) {
183 for(
int j=0; j<stridedBlockId; j++) {
184 nStridedOffset += stridingInfo[j];
186 nDofsPerNode = stridingInfo[stridedBlockId];
188 numGlobalElements = nodeMap->getGlobalNumElements()*Teuchos::as<global_size_t>(nDofsPerNode);
190 std::vector<GlobalOrdinal> dofgids;
191 for(LocalOrdinal i = 0; i<Teuchos::as<LocalOrdinal>(nodeMap->getNodeNumElements()); i++) {
193 for(
size_t dof = 0; dof < nDofsPerNode; ++dof) {
196 dofgids.push_back(indexBase + StridedMapClass::offset_ + (gid-indexBase)*Teuchos::as<GlobalOrdinal>(StridedMapClass::getFixedBlockSize()) + Teuchos::as<GlobalOrdinal>(nStridedOffset + dof));
204 if(stridedBlockId == -1) {
209 int nDofsInStridedBlock = stridingInfo[stridedBlockId];
229 : Xpetra::
TpetraMap<LocalOrdinal,
GlobalOrdinal,
Node>(numGlobalElements, elementList, indexBase, comm, node), Xpetra::
StridedMap<LocalOrdinal,
GlobalOrdinal,
Node>(numGlobalElements, elementList, indexBase, stridingInfo, comm, stridedBlockId)
231 if(stridedBlockId != -1) {
363 if(StridedMapClass::getStridedBlockId() == -1) {
373 size_t nStridedOffset = 0;
374 for(
int j=0; j<StridedMapClass::stridedBlockId_; j++) {
375 nStridedOffset += StridedMapClass::stridingInfo_[j];
379 const GlobalOrdinal goStridedOffset = Teuchos::as<GlobalOrdinal>(nStridedOffset);
380 const GlobalOrdinal goZeroOffset = (dofGids[0] - nStridedOffset - StridedMapClass::offset_) / Teuchos::as<GlobalOrdinal>(StridedMapClass::getFixedBlockSize());
383 for(
size_t i = 0; i<Teuchos::as<size_t>(dofGids.
size())/StridedMapClass::stridingInfo_[StridedMapClass::stridedBlockId_]; i+=StridedMapClass::stridingInfo_[StridedMapClass::stridedBlockId_]) {
385 for(
size_t j=0; j<StridedMapClass::stridingInfo_[StridedMapClass::stridedBlockId_]; j++) {
387 if((gid - Teuchos::as<GlobalOrdinal>(j) - goStridedOffset - StridedMapClass::offset_) / Teuchos::as<GlobalOrdinal>(StridedMapClass::getFixedBlockSize()) - goZeroOffset - cnt != 0) {
404 #define XPETRA_STRIDEDTPETRAMAP_SHORT
405 #endif // XPETRA_STRIDEDTPETRAMAP_HPP
GlobalOrdinal getMaxGlobalIndex() const
Returns maximum global index owned by this node.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this node.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
Returns the node IDs and corresponding local indices for a given list of global indices.
std::string description() const
Return a simple one-line description of this object.
GlobalOrdinal getIndexBase() const
Returns the index base for this Map.
global_size_t getGlobalNumElements() const
Returns the number of elements in this Map.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to a FancyOStream object.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
Return the local index for a given global index.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
Returns true if map is identical to this Map.
GlobalOrdinal getMaxAllGlobalIndex() const
Return the maximum global index over all nodes.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
bool isDistributed() const
Returns true if this Map is distributed across more than one node; returns false otherwise.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
bool isNodeLocalElement(LocalOrdinal localIndex) const
True if the local index is valid for this Map on this node, else false.
static Teuchos::RCP< DefaultNodeType > getDefaultNode()
Exception throws to report errors in the internal logical of the program.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print this object with the given verbosity level to the given FancyOStream.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
Return the process IDs and corresponding local IDs for the given global IDs.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
Return the global index for a given local index.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
const Teuchos::RCP< Node > getNode() const
Get the Node object for this Map.
const Teuchos::RCP< Node > getNode() const
Get this Map's Node object.
UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
global_size_t getGlobalNumElements() const
The number of elements in this Map.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
StridedTpetraMap(const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map, std::vector< size_t > &stridingInfo, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0)
TpetraMap constructor to wrap a Tpetra::Map object.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
Node(numGlobalElements, indexBase, comm, lg, node)
~StridedTpetraMap()
Map destructor.
const Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
LocalOrdinal getMaxLocalIndex() const
Returns maximum local index.
std::string description() const
Return a simple one-line description of this object.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
size_t global_size_t
Global size_t object.
static const EVerbosityLevel verbLevel_default
GlobalOrdinal getIndexBase() const
The index base for this Map.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Returns true if the global index is found in this Map on this node; returns false if it isn't...
GlobalOrdinal getMinAllGlobalIndex() const
Return the minimum global index over all nodes.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
size_t getNodeNumElements() const
The number of elements belonging to the calling node.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
Returns true if map is compatible with this Map.
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
bool isContiguous() const
Returns true if this Map is distributed contiguously; returns false otherwise.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
True if the global index is found in this Map on this node, else false.
LocalOrdinal getMinLocalIndex() const
Returns minimum local index.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
size_t getNodeNumElements() const
Returns the number of elements belonging to the calling node.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a list of the global indices owned by this node.
GlobalOrdinal getMinGlobalIndex() const
Returns minimum global index owned by this node.
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > > &graph)
const Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get the Comm object for this Map.
Class that stores a strided map.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
bool isNodeLocalElement(LocalOrdinal localIndex) const
Returns true if the local index is valid for this Map on this node; returns false if it isn't...
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const
Returns the node IDs for a given list of global indices.