Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_StridedMap_def.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_DEF_HPP
13 #define XPETRA_STRIDEDMAP_DEF_HPP
14 
15 #include "Xpetra_StridedMap.hpp"
16 
17 #include <Teuchos_OrdinalTraits.hpp>
18 
19 #include "Xpetra_Exceptions.hpp"
20 #include "Xpetra_MapFactory.hpp"
21 
22 namespace Xpetra {
23 
24 template <class LocalOrdinal, class GlobalOrdinal, class Node>
27  global_size_t numGlobalElements,
28  GlobalOrdinal indexBase,
29  std::vector<size_t>& stridingInfo,
30  const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
31  LocalOrdinal stridedBlockId, // FIXME (mfh 03 Sep 2014) This breaks for unsigned LocalOrdinal
32  GlobalOrdinal offset,
33  LocalGlobal lg)
34  : stridingInfo_(stridingInfo)
35  , stridedBlockId_(stridedBlockId)
36  , offset_(offset)
37  , indexBase_(indexBase) {
39 
40  size_t blkSize = getFixedBlockSize();
41 
42  TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo.size() == 0,
44  "StridedMap::StridedMap: stridingInfo not valid: stridingInfo.size() = 0?");
45 
46  TEUCHOS_TEST_FOR_EXCEPTION(numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid(),
47  std::invalid_argument,
48  "StridedMap::StridedMap: numGlobalElements is invalid");
49 
50  TEUCHOS_TEST_FOR_EXCEPTION(numGlobalElements % blkSize != 0,
52  "StridedMap::StridedMap: stridingInfo not valid: getFixedBlockSize "
53  "is not an integer multiple of numGlobalElements.");
54 
55  if (stridedBlockId != -1) {
56  TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo.size() < static_cast<size_t>(stridedBlockId),
58  "StridedTpetraMap::StridedTpetraMap: "
59  "stridedBlockId > stridingInfo.size()");
60  }
61 
62  // Try to create a shortcut
63  if (blkSize != 1 || offset_ != 0) {
64  // check input data and reorganize map
65  global_size_t numGlobalNodes = numGlobalElements / blkSize;
66 
67  // build an equally distributed node map
68  RCP<Map> nodeMap = MapFactory_t::Build(xlib, numGlobalNodes, indexBase, comm, lg);
69  global_size_t numLocalNodes = nodeMap->getLocalNumElements();
70 
71  // translate local node ids to local dofs
72  size_t nStridedOffset = 0;
73  size_t nDofsPerNode = blkSize; // dofs per node for local striding block
74  if (stridedBlockId > -1) {
75  for (int j = 0; j < stridedBlockId; j++) {
76  nStridedOffset += stridingInfo_[j];
77  }
78 
79  nDofsPerNode = stridingInfo_[stridedBlockId];
80  numGlobalElements = numGlobalNodes * Teuchos::as<global_size_t>(nDofsPerNode);
81  }
82  size_t numLocalElements = numLocalNodes * Teuchos::as<size_t>(nDofsPerNode);
83 
84  std::vector<GlobalOrdinal> dofgids(numLocalElements);
85  for (LocalOrdinal i = 0; i < Teuchos::as<LocalOrdinal>(numLocalNodes); i++) {
86  GlobalOrdinal nodeGID = nodeMap->getGlobalElement(i);
87 
88  for (size_t j = 0; j < nDofsPerNode; j++) {
89  dofgids[i * nDofsPerNode + j] = indexBase_ + offset_ + (nodeGID - indexBase_) * Teuchos::as<GlobalOrdinal>(blkSize) + Teuchos::as<GlobalOrdinal>(nStridedOffset + j);
90  }
91  }
92 
93  map_ = MapFactory_t::Build(xlib, numGlobalElements, dofgids, indexBase, comm);
94 
95  if (stridedBlockId == -1) {
96  TEUCHOS_TEST_FOR_EXCEPTION(getLocalNumElements() != Teuchos::as<size_t>(nodeMap->getLocalNumElements() * nDofsPerNode),
98  "StridedTpetraMap::StridedTpetraMap: wrong distribution of dofs among processors.");
99 
100  TEUCHOS_TEST_FOR_EXCEPTION(getGlobalNumElements() != Teuchos::as<size_t>(nodeMap->getGlobalNumElements() * nDofsPerNode),
102  "StridedTpetraMap::StridedTpetraMap: wrong distribution of dofs among processors.");
103  } else {
104  size_t nDofsInStridedBlock = stridingInfo[stridedBlockId];
105  TEUCHOS_TEST_FOR_EXCEPTION(getLocalNumElements() != Teuchos::as<size_t>(nodeMap->getLocalNumElements() * nDofsInStridedBlock),
107  "StridedTpetraMap::StridedTpetraMap: wrong distribution of dofs among processors.");
108 
109  TEUCHOS_TEST_FOR_EXCEPTION(getGlobalNumElements() != Teuchos::as<size_t>(nodeMap->getGlobalNumElements() * nDofsInStridedBlock),
111  "StridedTpetraMap::StridedTpetraMap: wrong distribution of dofs among processors.");
112  }
113  } else {
114  map_ = MapFactory_t::Build(xlib, numGlobalElements, indexBase, comm, lg);
115  }
116 
117  TEUCHOS_TEST_FOR_EXCEPTION(CheckConsistency() == false, Exceptions::RuntimeError, "StridedTpetraMap::StridedTpetraMap: CheckConsistency() == false");
118 }
119 
120 template <class LocalOrdinal, class GlobalOrdinal, class Node>
123  global_size_t numGlobalElements,
124  size_t numLocalElements,
125  GlobalOrdinal indexBase,
126  std::vector<size_t>& stridingInfo,
127  const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
128  LocalOrdinal stridedBlockId,
129  GlobalOrdinal offset)
130  : stridingInfo_(stridingInfo)
131  , stridedBlockId_(stridedBlockId)
132  , offset_(offset)
133  , indexBase_(indexBase) {
135 
136  size_t blkSize = getFixedBlockSize();
137  TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo.size() == 0,
139  "StridedMap::StridedMap: stridingInfo not valid: stridingInfo.size() = 0?");
140  if (numGlobalElements != Teuchos::OrdinalTraits<global_size_t>::invalid()) {
141  TEUCHOS_TEST_FOR_EXCEPTION(numGlobalElements % blkSize != 0,
143  "StridedMap::StridedMap: stridingInfo not valid: getFixedBlockSize is not an integer "
144  "multiple of numGlobalElements.");
145 #ifdef HAVE_XPETRA_DEBUG
146  // We have to do this check ourselves, as we don't necessarily construct the full Tpetra map
147  global_size_t sumLocalElements;
148  Teuchos::reduceAll(*comm, Teuchos::REDUCE_SUM, Teuchos::as<global_size_t>(numLocalElements), Teuchos::outArg(sumLocalElements));
149 
150  TEUCHOS_TEST_FOR_EXCEPTION(sumLocalElements != numGlobalElements,
151  std::invalid_argument,
152  "StridedMap::StridedMap: sum of numbers of local elements is different from the provided "
153  "number of global elements.");
154 #endif
155  }
156 
157  TEUCHOS_TEST_FOR_EXCEPTION(
158  numLocalElements % blkSize != 0,
160  "StridedMap::StridedMap: stridingInfo not valid: getFixedBlockSize is not an integer multiple of numLocalElements.");
161 
162  if (stridedBlockId != -1) {
163  TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo.size() < Teuchos::as<size_t>(stridedBlockId),
165  "StridedTpetraMap::StridedTpetraMap: stridedBlockId > stridingInfo.size()");
166  }
167 
168  // Try to create a shortcut
169  if (blkSize != 1 || offset_ != 0) {
170  // check input data and reorganize map
171  global_size_t numGlobalNodes = Teuchos::OrdinalTraits<global_size_t>::invalid();
172  if (numGlobalElements != Teuchos::OrdinalTraits<global_size_t>::invalid()) {
173  numGlobalNodes = numGlobalElements / blkSize;
174  }
175  global_size_t numLocalNodes = numLocalElements / blkSize;
176 
177  // build an equally distributed node map
178  RCP<Map> nodeMap = MapFactory_t::Build(xlib, numGlobalNodes, numLocalNodes, indexBase, comm);
179 
180  // translate local node ids to local dofs
181  size_t nStridedOffset = 0;
182  size_t nDofsPerNode = blkSize; // dofs per node for local striding block
183  if (stridedBlockId > -1) {
184  for (int j = 0; j < stridedBlockId; j++) {
185  nStridedOffset += stridingInfo_[j];
186  }
187 
188  nDofsPerNode = stridingInfo_[stridedBlockId];
189  numGlobalElements = nodeMap->getGlobalNumElements() * Teuchos::as<global_size_t>(nDofsPerNode);
190  }
191  numLocalElements = numLocalNodes * Teuchos::as<size_t>(nDofsPerNode);
192 
193  std::vector<GlobalOrdinal> dofgids(numLocalElements);
194  for (LocalOrdinal i = 0; i < Teuchos::as<LocalOrdinal>(numLocalNodes); i++) {
195  GlobalOrdinal nodeGID = nodeMap->getGlobalElement(i);
196 
197  for (size_t j = 0; j < nDofsPerNode; j++) {
198  dofgids[i * nDofsPerNode + j] = indexBase_ + offset_ + (nodeGID - indexBase_) * Teuchos::as<GlobalOrdinal>(blkSize) + Teuchos::as<GlobalOrdinal>(nStridedOffset + j);
199  }
200  }
201 
202  map_ = MapFactory_t::Build(xlib, numGlobalElements, dofgids, indexBase, comm);
203 
204  if (stridedBlockId == -1) {
205  TEUCHOS_TEST_FOR_EXCEPTION(getLocalNumElements() != Teuchos::as<size_t>(nodeMap->getLocalNumElements() * nDofsPerNode),
207  "StridedTpetraMap::StridedTpetraMap: wrong distribution of dofs among processors.");
208 
209  TEUCHOS_TEST_FOR_EXCEPTION(getGlobalNumElements() != Teuchos::as<size_t>(nodeMap->getGlobalNumElements() * nDofsPerNode),
211  "StridedTpetraMap::StridedTpetraMap: wrong distribution of dofs among processors.");
212  } else {
213  int nDofsInStridedBlock = stridingInfo[stridedBlockId];
214 
215  TEUCHOS_TEST_FOR_EXCEPTION(getLocalNumElements() != Teuchos::as<size_t>(nodeMap->getLocalNumElements() * nDofsInStridedBlock),
217  "StridedTpetraMap::StridedTpetraMap: wrong distribution of dofs among processors.");
218 
219  TEUCHOS_TEST_FOR_EXCEPTION(getGlobalNumElements() != Teuchos::as<size_t>(nodeMap->getGlobalNumElements() * nDofsInStridedBlock),
221  "StridedTpetraMap::StridedTpetraMap: wrong distribution of dofs among processors.");
222  }
223  } else {
224  map_ = MapFactory_t::Build(xlib, numGlobalElements, numLocalElements, indexBase, comm);
225  }
226 
227  TEUCHOS_TEST_FOR_EXCEPTION(CheckConsistency() == false, Exceptions::RuntimeError, "StridedTpetraMap::StridedTpetraMap: CheckConsistency() == false");
228 }
229 
230 template <class LocalOrdinal, class GlobalOrdinal, class Node>
233  global_size_t numGlobalElements,
234  const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
235  GlobalOrdinal indexBase,
236  std::vector<size_t>& stridingInfo,
237  const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
238  LocalOrdinal stridedBlockId)
239  : stridingInfo_(stridingInfo)
240  , stridedBlockId_(stridedBlockId)
241  , indexBase_(indexBase) {
243 
244  size_t blkSize = getFixedBlockSize();
245 
246  TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo.size() == 0,
248  "StridedMap::StridedMap: stridingInfo not valid: stridingInfo.size() = 0?");
249  if (stridedBlockId != -1)
250  TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo.size() < Teuchos::as<size_t>(stridedBlockId),
252  "StridedTpetraMap::StridedTpetraMap: stridedBlockId > stridingInfo.size()");
253  if (numGlobalElements != Teuchos::OrdinalTraits<global_size_t>::invalid()) {
254  TEUCHOS_TEST_FOR_EXCEPTION(numGlobalElements % blkSize != 0,
256  "StridedMap::StridedMap: stridingInfo not valid: getFixedBlockSize is not an integer "
257  "multiple of numGlobalElements.");
258 #ifdef HAVE_XPETRA_DEBUG
259  // We have to do this check ourselves, as we don't necessarily construct the full Tpetra map
260  global_size_t sumLocalElements, numLocalElements = elementList.size();
261  Teuchos::reduceAll(*comm, Teuchos::REDUCE_SUM, numLocalElements, Teuchos::outArg(sumLocalElements));
262  TEUCHOS_TEST_FOR_EXCEPTION(sumLocalElements != numGlobalElements,
263  std::invalid_argument,
264  "StridedMap::StridedMap: sum of numbers of local elements is different from the provided "
265  "number of global elements.");
266 #endif
267  }
268 
269  if (stridedBlockId == -1) {
270  // numGlobalElements can be -1! FIXME
271  // TEUCHOS_TEST_FOR_EXCEPTION(numGlobalElements % blkSize != 0, Exceptions::RuntimeError,
272  // "StridedMap::StridedMap: stridingInfo not valid: getFixedBlockSize is not an integer multiple of
273  // numGlobalElements.");
274  TEUCHOS_TEST_FOR_EXCEPTION(elementList.size() % blkSize != 0,
276  "StridedMap::StridedMap: stridingInfo not valid: getFixedBlockSize is not an integer "
277  "multiple of elementList.size().");
278  } else {
279  // numGlobalElements can be -1! FIXME
280  // TEUCHOS_TEST_FOR_EXCEPTION(numGlobalElements % stridingInfo[stridedBlockId] != 0, Exceptions::RuntimeError,
281  // "StridedMap::StridedMap: stridingInfo not valid: stridingBlockInfo[stridedBlockId] is not an integer multiple of
282  // numGlobalElements.");
283  TEUCHOS_TEST_FOR_EXCEPTION(elementList.size() % stridingInfo[stridedBlockId] != 0,
285  "StridedMap::StridedMap: stridingInfo not valid: stridingBlockInfo[stridedBlockId] is not "
286  "an integer multiple of elementList.size().");
287  }
288 
289  map_ = MapFactory_t::Build(xlib, numGlobalElements, elementList, indexBase, comm);
290 
291  // calculate offset_
292 
293  // find minimum GID over all procs
294  GlobalOrdinal minGidOnCurProc = Teuchos::OrdinalTraits<GlobalOrdinal>::max();
295  for (Teuchos_Ordinal k = 0; k < elementList.size(); k++) // TODO fix occurence of Teuchos_Ordinal
296  {
297  if (elementList[k] < minGidOnCurProc) {
298  minGidOnCurProc = elementList[k];
299  }
300  }
301 
302  Teuchos::reduceAll(*comm, Teuchos::REDUCE_MIN, minGidOnCurProc, Teuchos::outArg(offset_));
303 
304  // calculate striding index
305  size_t nStridedOffset = 0;
306  for (int j = 0; j < stridedBlockId; j++) {
307  nStridedOffset += stridingInfo[j];
308  }
309  const GlobalOrdinal goStridedOffset = Teuchos::as<GlobalOrdinal>(nStridedOffset);
310 
311  // adapt offset_
312  offset_ -= goStridedOffset + indexBase_;
313 
314  TEUCHOS_TEST_FOR_EXCEPTION(CheckConsistency() == false, Exceptions::RuntimeError, "StridedTpetraMap::StridedTpetraMap: CheckConsistency() == false");
315 }
316 
317 template <class LocalOrdinal, class GlobalOrdinal, class Node>
319  StridedMap(const RCP<const Map>& map,
320  std::vector<size_t>& stridingInfo,
321  GlobalOrdinal /* indexBase */,
322  LocalOrdinal stridedBlockId,
323  GlobalOrdinal offset)
324  : stridingInfo_(stridingInfo)
325  , stridedBlockId_(stridedBlockId)
326  , offset_(offset)
327  , indexBase_(map->getIndexBase()) {
328  // TAW: 11/24/15
329  // A strided map never can be built from a strided map. getMap always returns the underlying
330  // Xpetra::Map object which contains the data (either in a Xpetra::EpetraMapT or Xpetra::TpetraMap
331  // object)
332  if (Teuchos::rcp_dynamic_cast<const StridedMap>(map) == Teuchos::null) {
333  map_ = map; // if map is not a strided map, just store it (standard case)
334  } else {
335  map_ = map->getMap(); // if map is also a strided map, store the underlying plain Epetra/Tpetra Xpetra map object
336  }
337 }
338 
339 template <class LocalOrdinal, class GlobalOrdinal, class Node>
342 }
343 
344 template <class LocalOrdinal, class GlobalOrdinal, class Node>
345 std::vector<size_t>
348  return stridingInfo_;
349 }
350 
351 template <class LocalOrdinal, class GlobalOrdinal, class Node>
353  setStridingData(std::vector<size_t> stridingInfo) {
354  stridingInfo_ = stridingInfo;
355 }
356 
357 template <class LocalOrdinal, class GlobalOrdinal, class Node>
358 size_t
361  size_t blkSize = 0;
362  for (std::vector<size_t>::const_iterator it = stridingInfo_.begin(); it != stridingInfo_.end(); ++it) {
363  blkSize += *it;
364  }
365  return blkSize;
366 }
367 
368 template <class LocalOrdinal, class GlobalOrdinal, class Node>
369 LocalOrdinal
372  return stridedBlockId_;
373 }
374 
375 template <class LocalOrdinal, class GlobalOrdinal, class Node>
377  isStrided() const {
378  return stridingInfo_.size() > 1 ? true : false;
379 }
380 
381 template <class LocalOrdinal, class GlobalOrdinal, class Node>
383  isBlocked() const {
384  return getFixedBlockSize() > 1 ? true : false;
385 }
386 
387 template <class LocalOrdinal, class GlobalOrdinal, class Node>
388 GlobalOrdinal
390  getOffset() const {
391  return offset_;
392 }
393 
394 template <class LocalOrdinal, class GlobalOrdinal, class Node>
396  setOffset(GlobalOrdinal offset) {
397  offset_ = offset;
398 }
399 
400 template <class LocalOrdinal, class GlobalOrdinal, class Node>
401 size_t
403  GID2StridingBlockId(GlobalOrdinal gid) const {
404  GlobalOrdinal tgid = gid - offset_ - indexBase_;
405  tgid = tgid % getFixedBlockSize();
406 
407  size_t nStridedOffset = 0;
408  size_t stridedBlockId = 0;
409  for (size_t j = 0; j < stridingInfo_.size(); j++) {
410  nStridedOffset += stridingInfo_[j];
411  if (Teuchos::as<size_t>(tgid) < nStridedOffset) {
412  stridedBlockId = j;
413  break;
414  }
415  }
416  return stridedBlockId;
417 }
418 
419 template <class LocalOrdinal, class GlobalOrdinal, class Node>
420 RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>
422  getMap() const {
423  return map_;
424 }
425 
426 template <class LocalOrdinal, class GlobalOrdinal, class Node>
429 #ifndef HAVE_XPETRA_DEBUG
430  return true;
431 #else
432  if (getStridedBlockId() == -1) {
433  // Strided map contains the full map
434  if (getLocalNumElements() % getFixedBlockSize() != 0 || // number of local elements is not a multiple of block size
435  getGlobalNumElements() % getFixedBlockSize() != 0) // number of global -//-
436  return false;
437  } else {
438  // Strided map contains only the partial map
439  Teuchos::ArrayView<const GlobalOrdinal> dofGids = getLocalElementList();
440  // std::sort(dofGids.begin(), dofGids.end());
441 
442  if (dofGids.size() == 0) // special treatment for empty processors
443  {
444  return true;
445  }
446 
447  if (dofGids.size() % stridingInfo_[stridedBlockId_] != 0) {
448  return false;
449  }
450 
451  // Calculate nStridedOffset
452  size_t nStridedOffset = 0;
453  for (int j = 0; j < stridedBlockId_; j++) {
454  nStridedOffset += stridingInfo_[j];
455  }
456 
457  const GlobalOrdinal goStridedOffset = Teuchos::as<GlobalOrdinal>(nStridedOffset);
458  const GlobalOrdinal goZeroOffset = (dofGids[0] - nStridedOffset - offset_ - indexBase_) / Teuchos::as<GlobalOrdinal>(getFixedBlockSize());
459 
460  GlobalOrdinal cnt = 0;
461  for (size_t i = 0;
462  i < Teuchos::as<size_t>(dofGids.size()) / stridingInfo_[stridedBlockId_];
463  i += stridingInfo_[stridedBlockId_]) {
464  const GlobalOrdinal first_gid = dofGids[i];
465 
466  // We expect this to be the same for all DOFs of the same node
467  cnt = (first_gid - goStridedOffset - offset_ - indexBase_) / Teuchos::as<GlobalOrdinal>(getFixedBlockSize()) - goZeroOffset;
468 
469  // Loop over all DOFs that belong to current node
470  for (size_t j = 0; j < stridingInfo_[stridedBlockId_]; j++) {
471  const GlobalOrdinal gid = dofGids[i + j];
472  const GlobalOrdinal r = (gid - Teuchos::as<GlobalOrdinal>(j) - goStridedOffset - offset_ - indexBase_) / Teuchos::as<GlobalOrdinal>(getFixedBlockSize()) - goZeroOffset - cnt;
473  // TAW 1/18/2016: We cannot use Teuchos::OrdinalTraits<GlobalOrdinal>::zero() ) here,
474  // If, e.g., GO=long long is disabled, OrdinalTraits<long long> is not available.
475  // But we instantiate stubs on GO=long long which might contain StridedMaps.
476  // These lead to compilation errors, then.
477  if (0 != r) {
478  std::cout << "goZeroOffset : " << goZeroOffset << std::endl
479  << "dofGids[0] : " << dofGids[0] << std::endl
480  << "stridedOffset : " << nStridedOffset << std::endl
481  << "offset_ : " << offset_ << std::endl
482  << "goStridedOffset: " << goStridedOffset << std::endl
483  << "getFixedBlkSize: " << getFixedBlockSize() << std::endl
484  << "gid: " << gid << " GID: " << r << std::endl;
485 
486  return false;
487  }
488  }
489  }
490  }
491 
492  return true;
493 #endif
494 }
495 
496 template <class LocalOrdinal, class GlobalOrdinal, class Node>
500  return map_->getGlobalNumElements();
501 }
502 
503 template <class LocalOrdinal, class GlobalOrdinal, class Node>
504 size_t
507  return map_->getLocalNumElements();
508 }
509 
510 template <class LocalOrdinal, class GlobalOrdinal, class Node>
511 GlobalOrdinal
513  getIndexBase() const {
514  return map_->getIndexBase();
515 }
516 
517 template <class LocalOrdinal, class GlobalOrdinal, class Node>
518 LocalOrdinal
521  return map_->getMinLocalIndex();
522 }
523 
524 template <class LocalOrdinal, class GlobalOrdinal, class Node>
525 LocalOrdinal
528  return map_->getMaxLocalIndex();
529 }
530 
531 template <class LocalOrdinal, class GlobalOrdinal, class Node>
532 GlobalOrdinal
535  return map_->getMinGlobalIndex();
536 }
537 
538 template <class LocalOrdinal, class GlobalOrdinal, class Node>
539 GlobalOrdinal
542  return map_->getMaxGlobalIndex();
543 }
544 
545 template <class LocalOrdinal, class GlobalOrdinal, class Node>
546 GlobalOrdinal
549  return map_->getMinAllGlobalIndex();
550 }
551 
552 template <class LocalOrdinal, class GlobalOrdinal, class Node>
553 GlobalOrdinal
556  return map_->getMaxAllGlobalIndex();
557 }
558 
559 template <class LocalOrdinal, class GlobalOrdinal, class Node>
560 LocalOrdinal
562  getLocalElement(GlobalOrdinal globalIndex) const {
563  return map_->getLocalElement(globalIndex);
564 }
565 
566 template <class LocalOrdinal, class GlobalOrdinal, class Node>
567 GlobalOrdinal
569  getGlobalElement(LocalOrdinal localIndex) const {
570  return map_->getGlobalElement(localIndex);
571 }
572 
573 template <class LocalOrdinal, class GlobalOrdinal, class Node>
576  getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal>& GIDList,
577  const Teuchos::ArrayView<int>& nodeIDList,
578  const Teuchos::ArrayView<LocalOrdinal>& LIDList) const {
579  return map_->getRemoteIndexList(GIDList, nodeIDList, LIDList);
580 }
581 
582 template <class LocalOrdinal, class GlobalOrdinal, class Node>
585  getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal>& GIDList,
586  const Teuchos::ArrayView<int>& nodeIDList) const {
587  return map_->getRemoteIndexList(GIDList, nodeIDList);
588 }
589 
590 template <class LocalOrdinal, class GlobalOrdinal, class Node>
591 Teuchos::ArrayView<const GlobalOrdinal>
594  return map_->getLocalElementList();
595 }
596 
597 template <class LocalOrdinal, class GlobalOrdinal, class Node>
601  return map_->getMyGlobalIndicesDevice();
602 }
603 
604 template <class LocalOrdinal, class GlobalOrdinal, class Node>
606  isNodeLocalElement(LocalOrdinal localIndex) const {
607  return map_->isNodeLocalElement(localIndex);
608 }
609 
610 template <class LocalOrdinal, class GlobalOrdinal, class Node>
612  isNodeGlobalElement(GlobalOrdinal globalIndex) const {
613  return map_->isNodeGlobalElement(globalIndex);
614 }
615 
616 template <class LocalOrdinal, class GlobalOrdinal, class Node>
618  isContiguous() const {
619  return map_->isContiguous();
620 }
621 
622 template <class LocalOrdinal, class GlobalOrdinal, class Node>
624  isDistributed() const {
625  return map_->isDistributed();
626 }
627 
628 template <class LocalOrdinal, class GlobalOrdinal, class Node>
630  isCompatible(const Map& map) const {
631  return map_->isCompatible(map);
632 }
633 
634 template <class LocalOrdinal, class GlobalOrdinal, class Node>
636  isSameAs(const Map& map) const {
637  return map_->isSameAs(map);
638 }
639 
640 template <class LocalOrdinal, class GlobalOrdinal, class Node>
641 Teuchos::RCP<const Teuchos::Comm<int>>
643  getComm() const {
644  return map_->getComm();
645 }
646 
647 template <class LocalOrdinal, class GlobalOrdinal, class Node>
648 RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>
651  return map_->removeEmptyProcesses();
652 }
653 
654 template <class LocalOrdinal, class GlobalOrdinal, class Node>
655 RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>
657  replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int>>& newComm) const {
658  return map_->replaceCommWithSubset(newComm);
659 }
660 
661 template <class LocalOrdinal, class GlobalOrdinal, class Node>
662 std::string
664  description() const {
665  return map_->description();
666 }
667 
668 template <class LocalOrdinal, class GlobalOrdinal, class Node>
670  describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel) const {
671  map_->describe(out, verbLevel);
672 }
673 
674 template <class LocalOrdinal, class GlobalOrdinal, class Node>
677  lib() const {
678  return map_->lib();
679 }
680 
681 } // namespace Xpetra
682 
683 #endif // XPETRA_STRIDEDMAP_DEF_HPP
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a list 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.
LocalOrdinal getStridedBlockId() const
GlobalOrdinal getMaxGlobalIndex() const
Returns maximum global index owned by this node.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
Return the global index for a given local index.
size_t GID2StridingBlockId(GlobalOrdinal gid) const
bool isContiguous() const
Returns true if this Map is distributed contiguously; returns false otherwise.
void setStridingData(std::vector< size_t > stridingInfo)
size_t getLocalNumElements() const
Returns the number of elements belonging to the calling node.
GlobalOrdinal indexBase_
Index base for the strided map (default = 0)
GlobalOrdinal getOffset() const
Exception throws to report errors in the internal logical of the program.
LocalOrdinal getMaxLocalIndex() const
Returns maximum local index.
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.
std::string description() const
Return a simple one-line description of this object.
GlobalOrdinal getMaxAllGlobalIndex() const
Return the maximum global index over all nodes.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Returns true if the global index is found in this Map on this node; returns false if it isn&#39;t...
bool isNodeLocalElement(LocalOrdinal localIndex) const
Returns true if the local index is valid for this Map on this node; returns false if it isn&#39;t...
bool isStrided() const
returns true, if this is a strided map (i.e. more than 1 strided blocks)
bool isSameAs(const Map &map) const
Returns true if map is identical to this Map.
std::vector< size_t > stridingInfo_
Vector with size of strided blocks (dofs)
RCP< const Map > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
RCP< const Map > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int >> &newComm) const
bool isDistributed() const
Returns true if this Map is distributed across more than one node; returns false otherwise.
size_t getFixedBlockSize() const
global_indices_array_device_type getMyGlobalIndicesDevice() const
Return a view of the global indices owned by this process on the Map&#39;s device.
GlobalOrdinal offset_
Offset for gids in map (default = 0)
GlobalOrdinal getMinGlobalIndex() const
Returns minimum global index owned by this node.
size_t global_size_t
Global size_t object.
GlobalOrdinal getIndexBase() const
Returns the index base for this Map.
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
global_size_t getGlobalNumElements() const
Returns the number of elements in this Map.
Kokkos::View< const global_ordinal_type *, typename Node::device_type > global_indices_array_device_type
std::vector< size_t > getStridingData() const
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
Return the local index for a given global index.
StridedMap(UnderlyingLib xlib, 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=GloballyDistributed)
Map constructor with contiguous uniform distribution.
LocalOrdinal getMinLocalIndex() const
Returns minimum local index.
UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
GlobalOrdinal getMinAllGlobalIndex() const
Return the minimum global index over all nodes.
Create an Xpetra::Map instance.
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.
virtual ~StridedMap()
Destructor.
void setOffset(GlobalOrdinal offset)
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > map_