Xpetra Version of the Day
Loading...
Searching...
No Matches
Xpetra_StridedMap_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Xpetra: A linear algebra interface package
4//
5// Copyright 2012 NTESS and the Xpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10// WARNING: This code is experimental. Backwards compatibility should not be expected.
11
12#ifndef XPETRA_STRIDEDMAP_DECL_HPP
13#define XPETRA_STRIDEDMAP_DECL_HPP
14
15#include <Tpetra_KokkosCompat_DefaultNode.hpp>
16#include <Teuchos_Describable.hpp>
17
18#include "Xpetra_ConfigDefs.hpp"
19#include "Xpetra_Map_decl.hpp"
20
21namespace Xpetra {
22
61template <class LocalOrdinal,
62 class GlobalOrdinal,
63 class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
64class StridedMap : public virtual Map<LocalOrdinal, GlobalOrdinal, Node> {
65 public:
66 typedef LocalOrdinal local_ordinal_type;
67 typedef GlobalOrdinal global_ordinal_type;
68 typedef Node node_type;
70
71 private:
72#undef XPETRA_STRIDEDMAP_SHORT
74
75 public:
77
78
100 global_size_t numGlobalElements,
101 GlobalOrdinal indexBase,
102 std::vector<size_t>& stridingInfo,
103 const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
104 LocalOrdinal stridedBlockId = -1, // FIXME (mfh 03 Sep 2014) This breaks for unsigned LocalOrdinal
105 GlobalOrdinal offset = 0,
107
109
131 global_size_t numGlobalElements,
132 size_t numLocalElements,
133 GlobalOrdinal indexBase,
134 std::vector<size_t>& stridingInfo,
135 const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
136 LocalOrdinal stridedBlockId = -1,
137 GlobalOrdinal offset = 0);
138
151 global_size_t numGlobalElements,
153 GlobalOrdinal indexBase,
154 std::vector<size_t>& stridingInfo,
155 const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
156 LocalOrdinal stridedBlockId = -1);
157
158 StridedMap(const RCP<const Map>& map,
159 std::vector<size_t>& stridingInfo,
160 GlobalOrdinal /* indexBase */,
161 LocalOrdinal stridedBlockId = -1,
162 GlobalOrdinal offset = 0);
163
165 virtual ~StridedMap();
166
168
170
171
172 std::vector<size_t> getStridingData() const;
173
174 void setStridingData(std::vector<size_t> stridingInfo);
175
176 size_t getFixedBlockSize() const;
177
180 LocalOrdinal getStridedBlockId() const;
181
183 bool isStrided() const;
184
187 bool isBlocked() const;
188
189 GlobalOrdinal getOffset() const;
190
191 void setOffset(GlobalOrdinal offset);
192
193 // returns number of strided block id which gid belongs to.
194 size_t GID2StridingBlockId(GlobalOrdinal gid) const;
195
197
198
200
202
205 return map_->getLocalMap();
206 }
207
209
210 /* // function currently not needed but maybe useful
211 std::vector<GlobalOrdinal> NodeId2GlobalDofIds(GlobalOrdinal nodeId) const {
212 TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo_.size() == 0, Exceptions::RuntimeError, "StridedMap::NodeId2GlobalDofIds:
213 stridingInfo not valid: stridingInfo.size() = 0?"); std::vector<GlobalOrdinal> dofs; if(stridedBlockId_ > -1) {
214 TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo_[stridedBlockId_] == 0, Exceptions::RuntimeError,
215 "StridedMap::NodeId2GlobalDofIds: stridingInfo not valid: stridingInfo[stridedBlockId] = 0?");
216
217 // determine nStridedOffset
218 size_t nStridedOffset = 0;
219 for(int j=0; j<stridedBlockId_; j++) {
220 nStridedOffset += stridingInfo_[j];
221 }
222
223 for(size_t i = 0; i<stridingInfo_[stridedBlockId_]; i++) {
224 GlobalOrdinal gid =
225 nodeId * Teuchos::as<GlobalOrdinal>(getFixedBlockSize()) +
226 offset_ +
227 Teuchos::as<GlobalOrdinal>(nStridedOffset) +
228 Teuchos::as<GlobalOrdinal>(i);
229 dofs.push_back(gid);
230 }
231 } else {
232 for(size_t i = 0; i<getFixedBlockSize(); i++) {
233 GlobalOrdinal gid =
234 nodeId * Teuchos::as<GlobalOrdinal>(getFixedBlockSize()) +
235 offset_ +
236 Teuchos::as<GlobalOrdinal>(i);
237 dofs.push_back(gid);
238 }
239 }
240 return dofs;
241 }*/
243
244 private:
245 virtual bool CheckConsistency();
246
247 private:
249
251 std::vector<size_t> stridingInfo_;
252
258 LocalOrdinal stridedBlockId_;
259
261 GlobalOrdinal offset_;
262
264 GlobalOrdinal indexBase_;
265
266 public:
268
269
272
274 size_t getLocalNumElements() const;
275
277 GlobalOrdinal getIndexBase() const;
278
280 LocalOrdinal getMinLocalIndex() const;
281
283 LocalOrdinal getMaxLocalIndex() const;
284
286 GlobalOrdinal getMinGlobalIndex() const;
287
289 GlobalOrdinal getMaxGlobalIndex() const;
290
292 GlobalOrdinal getMinAllGlobalIndex() const;
293
295 GlobalOrdinal getMaxAllGlobalIndex() const;
296
298 LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const;
299
301 GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const;
302
305 const Teuchos::ArrayView<int>& nodeIDList,
306 const Teuchos::ArrayView<LocalOrdinal>& LIDList) const;
307
310 const Teuchos::ArrayView<int>& nodeIDList) const;
311
314
317
319 bool isNodeLocalElement(LocalOrdinal localIndex) const;
320
322 bool isNodeGlobalElement(GlobalOrdinal globalIndex) const;
323
325 bool isContiguous() const;
326
328 bool isDistributed() const;
329
331
333 bool isCompatible(const Map& map) const;
334
336 bool isSameAs(const Map& map) const;
337
340
342
344
346 std::string description() const;
347
351
353 UnderlyingLib lib() const;
354
355}; // StridedMap class
356
357} // namespace Xpetra
358
359#define XPETRA_STRIDEDMAP_SHORT
360#endif // XPETRA_STRIDEDMAP_DECL_HPP
static const EVerbosityLevel verbLevel_default
Kokkos::View< const global_ordinal_type *, typename Node::device_type > global_indices_array_device_type
Class that stores a strided map.
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
LocalOrdinal getMaxLocalIndex() const
Returns maximum local index.
std::vector< size_t > stridingInfo_
Vector with size of strided blocks (dofs)
GlobalOrdinal getMinAllGlobalIndex() const
Return the minimum global index over all nodes.
virtual ~StridedMap()
Destructor.
global_indices_array_device_type getMyGlobalIndicesDevice() const
Return a view of the global indices owned by this process on the Map's device.
bool isSameAs(const Map &map) const
Returns true if map is identical to 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.
size_t GID2StridingBlockId(GlobalOrdinal gid) const
GlobalOrdinal indexBase_
Index base for the strided map (default = 0)
Map< LocalOrdinal, GlobalOrdinal, Node >::global_indices_array_device_type global_indices_array_device_type
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.
LocalOrdinal stridedBlockId_
Member variable denoting which dofs are stored in map.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
Return the global index for a given local index.
UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
global_size_t getGlobalNumElements() const
Returns the number of elements in this Map.
bool isDistributed() const
Returns true if this Map is distributed across more than one node; returns false otherwise.
LocalOrdinal getStridedBlockId() const
void setStridingData(std::vector< size_t > stridingInfo)
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.
size_t getLocalNumElements() const
Returns the number of elements belonging to the calling node.
GlobalOrdinal getOffset() const
bool isContiguous() const
Returns true if this Map is distributed contiguously; returns false otherwise.
typename Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
GlobalOrdinal getMaxAllGlobalIndex() const
Return the maximum global index over all nodes.
RCP< const Map > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map's communicator with a subset communicator.
void setOffset(GlobalOrdinal offset)
GlobalOrdinal offset_
Offset for gids in map (default = 0)
GlobalOrdinal getMinGlobalIndex() const
Returns minimum global index owned by this node.
std::vector< size_t > getStridingData() const
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get the Comm object for this Map.
bool isCompatible(const Map &map) const
Returns true if map is compatible with this Map.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
Return the local index for a given global index.
bool isStrided() const
returns true, if this is a strided map (i.e. more than 1 strided blocks)
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a list of the global indices owned by this node.
std::string description() const
Return a simple one-line description of this object.
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.
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > map_
LocalOrdinal getMinLocalIndex() const
Returns minimum local index.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
GlobalOrdinal getMaxGlobalIndex() const
Returns maximum global index owned by this node.
RCP< const Map > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
GlobalOrdinal getIndexBase() const
Returns the index base for this Map.
size_t global_size_t
Global size_t object.