Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_EpetraMap.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 #ifndef XPETRA_EPETRAMAP_HPP
11 #define XPETRA_EPETRAMAP_HPP
12 
14 
15 #include "Xpetra_Map.hpp"
16 
17 #include <Epetra_Map.h>
18 #include <Epetra_BlockMap.h>
19 
20 #include "Xpetra_Utils.hpp"
21 #include "Xpetra_EpetraUtils.hpp"
23 
24 #include "Xpetra_ConfigDefs.hpp"
25 
26 #if defined(XPETRA_ENABLE_DEPRECATED_CODE)
27 #ifdef __GNUC__
28 #if defined(Xpetra_SHOW_DEPRECATED_WARNINGS)
29 #warning "The header file Trilinos/packages/xpetra/src/Map/Xpetra_EpetraMap.hpp is deprecated."
30 #endif
31 #endif
32 #else
33 #error "The header file Trilinos/packages/xpetra/src/Map/Xpetra_EpetraMap.hpp is deprecated."
34 #endif
35 
36 namespace Xpetra {
37 
38 // TODO: move that elsewhere
39 template <class GlobalOrdinal, class Node>
40 XPETRA_DEPRECATED const Epetra_Map &toEpetra(const Map<int, GlobalOrdinal, Node> &);
41 
42 template <class GlobalOrdinal, class Node>
43 XPETRA_DEPRECATED const Epetra_Map &toEpetra(const RCP<const Map<int, GlobalOrdinal, Node> > &);
44 
45 // template<class GlobalOrdinal>
46 // const RCP< const Map<int, GlobalOrdinal> > toXpetra(const RCP< const Epetra_Map > &);
47 
48 template <class GlobalOrdinal, class Node>
49 XPETRA_DEPRECATED const RCP<const Map<int, GlobalOrdinal, Node> > toXpetra(const Epetra_BlockMap &);
50 
51 // stub implementation for EpetraMapT
52 template <class GlobalOrdinal, class Node>
53 class XPETRA_DEPRECATED EpetraMapT
54  : public virtual Map<int, GlobalOrdinal, Node> {
55  typedef int LocalOrdinal;
56 
57  public:
58  typedef int local_ordinal_type;
59  typedef GlobalOrdinal global_ordinal_type;
60  typedef Node node_type;
62 
64 
65 
67  EpetraMapT(global_size_t numGlobalElements,
68  GlobalOrdinal indexBase,
69  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
71  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
72  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
73  }
74 
76  EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
77  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
78  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
79  }
80 
82  EpetraMapT(global_size_t numGlobalElements,
83  const Teuchos::ArrayView<const GlobalOrdinal> &elementList,
84  GlobalOrdinal indexBase,
85  const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
86  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
87  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
88  }
89 
91 
93 
94 
96  global_size_t getGlobalNumElements() const { return 0; }
97 
99  size_t getLocalNumElements() const { return 0; }
100 
102  GlobalOrdinal getIndexBase() const { return 0; }
103 
105  LocalOrdinal getMinLocalIndex() const { return 0; }
106 
108  LocalOrdinal getMaxLocalIndex() const { return 0; }
109 
111  GlobalOrdinal getMinGlobalIndex() const { return 0; }
112 
114  GlobalOrdinal getMaxGlobalIndex() const { return 0; }
115 
117  GlobalOrdinal getMinAllGlobalIndex() const { return 0; }
118 
120  GlobalOrdinal getMaxAllGlobalIndex() const { return 0; }
121 
123  LocalOrdinal getLocalElement(GlobalOrdinal /* globalIndex */) const { return 0; }
124 
126  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & /* GIDList */, const Teuchos::ArrayView<int> & /* nodeIDList */, const Teuchos::ArrayView<LocalOrdinal> & /* LIDList */) const { return Xpetra::IDNotPresent; }
127 
129  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & /* GIDList */, const Teuchos::ArrayView<int> & /* nodeIDList */) const { return Xpetra::IDNotPresent; }
130 
132  Teuchos::ArrayView<const GlobalOrdinal> getLocalElementList() const { return ArrayView<const GlobalOrdinal>(); }
133 
136 
138 
140 
141 
143  bool isNodeLocalElement(LocalOrdinal /* localIndex */) const { return false; }
144 
146  bool isNodeGlobalElement(GlobalOrdinal /* globalIndex */) const { return false; }
147 
149  bool isContiguous() const { return false; }
150 
152  bool isDistributed() const { return false; }
153 
155  bool isCompatible(const Map<LocalOrdinal, GlobalOrdinal, Node> & /* map */) const { return false; }
156 
158  bool isSameAs(const Map<LocalOrdinal, GlobalOrdinal, Node> & /* map */) const { return false; }
159 
161 
163 
164 
166  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const { return Teuchos::null; }
167 
169 
171 
172 
174  std::string description() const { return std::string(""); }
175 
177  void describe(Teuchos::FancyOStream & /* out */, const Teuchos::EVerbosityLevel /* verbLevel */ = Teuchos::Describable::verbLevel_default) const {}
178 
180 
182 
183 
185  RCP<const Map<int, GlobalOrdinal, Node> > removeEmptyProcesses() const { return Teuchos::null; }
186 
188  RCP<const Map<int, GlobalOrdinal, Node> > replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int> > & /* newComm */) const { return Teuchos::null; }
189 
191 
193  GlobalOrdinal getGlobalElement(LocalOrdinal /* localIndex */) const { return -1; }
194 
196 
197 
199  virtual ~EpetraMapT() {}
200 
202  EpetraMapT(const Teuchos::RCP<const Epetra_BlockMap> &map)
203  : map_(map) {
204  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
205  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
206  }
207 
209  UnderlyingLib lib() const { return Xpetra::UseEpetra; }
210 
212  const RCP<const Epetra_Map> &getEpetra_MapRCP() const { return Teuchos::rcp_static_cast<const Epetra_Map>(map_); }
213  const Epetra_BlockMap &getEpetra_BlockMap() const { return *map_; }
214  const Epetra_Map &getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
215 
216 #ifdef HAVE_XPETRA_TPETRA
220  throw std::runtime_error("Xpetra::EpetraMap::getLocalMap is not implemented in " + std::string(__FILE__) + ":" + std::to_string(__LINE__));
221  }
222 #else
223 #ifdef __GNUC__
224 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
225 #endif
226 #endif
227 
229 
230  protected:
231  RCP<const Epetra_BlockMap> map_;
232 }; // EpetraMapT class
233 
234 // specialization on GO=int and EpetraNode
235 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
236 template <>
238  : public virtual Map<int, int, EpetraNode> {
239  typedef int LocalOrdinal;
240  typedef int GlobalOrdinal;
241  typedef EpetraNode Node;
242 
243  public:
246  typedef Node node_type;
248 
250 
251 
253  EpetraMapT(global_size_t numGlobalElements,
254  GlobalOrdinal indexBase,
255  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
257  // This test come from Tpetra (Epetra doesn't check if numGlobalElements,indexBase are equivalent across images).
258  // In addition, for the test TEST_THROW(M map((myImageID == 0 ? GSTI : 0),0,comm), std::invalid_argument), only one node throw an exception and there is a dead lock.
259  std::string errPrefix;
260  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,indexBase,comm,lOrG): ";
261 
262  if (lg == GloballyDistributed) {
263  const int myImageID = comm->getRank();
264 
265  // check that numGlobalElements,indexBase is equivalent across images
266  global_size_t rootNGE = numGlobalElements;
267  GlobalOrdinal rootIB = indexBase;
268  Teuchos::broadcast<int, global_size_t>(*comm, 0, &rootNGE);
269  Teuchos::broadcast<int, GlobalOrdinal>(*comm, 0, &rootIB);
270  int localChecks[2], globalChecks[2];
271  localChecks[0] = -1; // fail or pass
272  localChecks[1] = 0; // fail reason
273  if (numGlobalElements != rootNGE) {
274  localChecks[0] = myImageID;
275  localChecks[1] = 1;
276  } else if (indexBase != rootIB) {
277  localChecks[0] = myImageID;
278  localChecks[1] = 2;
279  }
280  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass, as well as the reason
281  // these will be -1 and 0 if all procs passed
282  Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 2, localChecks, globalChecks);
283  if (globalChecks[0] != -1) {
284  if (globalChecks[1] == 1) {
285  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
286  errPrefix << "numGlobal must be the same on all nodes (examine node " << globalChecks[0] << ").");
287  } else if (globalChecks[1] == 2) {
288  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
289  errPrefix << "indexBase must be the same on all nodes (examine node " << globalChecks[0] << ").");
290  } else {
291  // logic error on our part
292  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
293  errPrefix << "logic error. Please contact the Tpetra team.");
294  }
295  }
296  }
297 
298  // Note: validity of numGlobalElements checked by Epetra.
299 
300  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), 1, indexBase, *toEpetra(comm))))));
301  }
302 
304  EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
305  // This test come from Tpetra
306  using Teuchos::outArg;
307 
308  const size_t L0 = Teuchos::OrdinalTraits<size_t>::zero();
309  const size_t L1 = Teuchos::OrdinalTraits<size_t>::one();
310  const global_size_t GST0 = Teuchos::OrdinalTraits<global_size_t>::zero();
311  const global_size_t GST1 = Teuchos::OrdinalTraits<global_size_t>::one();
312  const global_size_t GSTI = Teuchos::OrdinalTraits<global_size_t>::invalid();
313 
314  std::string errPrefix;
315  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,numLocal,indexBase,platform): ";
316 
317  // get a internodal communicator from the Platform
318  const int myImageID = comm->getRank();
319 
320  global_size_t global_sum;
321  { // begin scoping block
322  // for communicating failures
323  int localChecks[2], globalChecks[2];
324  /* compute the global size
325  we are computing the number of global elements because exactly ONE of the following is true:
326  - the user didn't specify it, and we need it
327  - the user did specify it, but we need to
328  + validate it against the sum of the local sizes, and
329  + ensure that it is the same on all nodes
330  */
331  Teuchos::reduceAll<int, global_size_t>(*comm, Teuchos::REDUCE_SUM,
332  Teuchos::as<global_size_t>(numLocalElements), outArg(global_sum));
333  /* there are three errors we should be detecting:
334  - numGlobalElements != invalid() and it is incorrect/invalid
335  - numLocalElements invalid (<0)
336  */
337  localChecks[0] = -1;
338  localChecks[1] = 0;
339  if (numLocalElements < L1 && numLocalElements != L0) {
340  // invalid
341  localChecks[0] = myImageID;
342  localChecks[1] = 1;
343  } else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
344  // invalid
345  localChecks[0] = myImageID;
346  localChecks[1] = 2;
347  } else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
348  // incorrect
349  localChecks[0] = myImageID;
350  localChecks[1] = 3;
351  }
352  // now check that indexBase is equivalent across images
353  GlobalOrdinal rootIB = indexBase;
354  Teuchos::broadcast<int, GlobalOrdinal>(*comm, 0, &rootIB); // broadcast one ordinal from node 0
355  if (indexBase != rootIB) {
356  localChecks[0] = myImageID;
357  localChecks[1] = 4;
358  }
359  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass
360  // this will be -1 if all procs passed
361  Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 2, localChecks, globalChecks);
362  if (globalChecks[0] != -1) {
363  if (globalChecks[1] == 1) {
364  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
365  errPrefix << "numLocal is not valid on at least one node (possibly node "
366  << globalChecks[0] << ").");
367  } else if (globalChecks[1] == 2) {
368  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
369  errPrefix << "numGlobal is not valid on at least one node (possibly node "
370  << globalChecks[0] << ").");
371  } else if (globalChecks[1] == 3) {
372  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
373  errPrefix << "numGlobal doesn't match sum of numLocal (== "
374  << global_sum << ") on at least one node (possibly node "
375  << globalChecks[0] << ").");
376  } else if (globalChecks[1] == 4) {
377  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
378  errPrefix << "indexBase is not the same on all nodes (examine node "
379  << globalChecks[0] << ").");
380  } else {
381  // logic error on my part
382  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
383  errPrefix << "logic error. Please contact the Tpetra team.");
384  }
385  }
386  }
387 
388  // set numGlobalElements
389  if (numGlobalElements == GSTI) {
390  numGlobalElements = global_sum;
391  }
392 
393  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), static_cast<int>(numLocalElements), 1, indexBase, *toEpetra(comm))))));
394  }
395 
397  EpetraMapT(global_size_t numGlobalElements,
398  const Teuchos::ArrayView<const GlobalOrdinal> &elementList,
399  GlobalOrdinal indexBase,
400  const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
401  if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
402  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(-1, static_cast<int>(elementList.size()), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
403  } else {
404  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<int>(numGlobalElements), static_cast<int>(elementList.size()), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
405  }
406  }
407 
409 
411 
412 
415  XPETRA_MONITOR("EpetraMapT::getGlobalNumElements");
416  return map_->NumGlobalElements64();
417  }
418 
420  size_t getLocalNumElements() const {
421  XPETRA_MONITOR("EpetraMapT::getLocalNumElements");
422  return map_->NumMyElements();
423  }
424 
427  XPETRA_MONITOR("EpetraMapT::getIndexBase");
428  return (GlobalOrdinal)map_->IndexBase64();
429  }
430 
433  XPETRA_MONITOR("EpetraMapT::getMinLocalIndex");
434  return map_->MinLID();
435  }
436 
439  XPETRA_MONITOR("EpetraMapT::getMaxLocalIndex");
440  return map_->MaxLID();
441  }
442 
445  XPETRA_MONITOR("EpetraMapT::getMinGlobalIndex");
446  return (GlobalOrdinal)map_->MinMyGID64();
447  }
448 
451  XPETRA_MONITOR("EpetraMapT::getMaxGlobalIndex");
452  return (GlobalOrdinal)map_->MaxMyGID64();
453  }
454 
457  XPETRA_MONITOR("EpetraMapT::getMinAllGlobalIndex");
458  return (GlobalOrdinal)map_->MinAllGID64();
459  }
460 
463  XPETRA_MONITOR("EpetraMapT::getMaxAllGlobalIndex");
464  return (GlobalOrdinal)map_->MaxAllGID64();
465  }
466 
469  XPETRA_MONITOR("EpetraMapT::getLocalElement");
470  return map_->LID(globalIndex);
471  }
472 
474  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList,
475  const Teuchos::ArrayView<int> &nodeIDList,
476  const Teuchos::ArrayView<LocalOrdinal> &LIDList) const {
477  XPETRA_MONITOR("EpetraMapT::getRemoteIndexList");
478  return toXpetra(map_->RemoteIDList(static_cast<int>(GIDList.size()), GIDList.getRawPtr(), nodeIDList.getRawPtr(), LIDList.getRawPtr()));
479  }
480 
482  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList,
483  const Teuchos::ArrayView<int> &nodeIDList) const {
484  XPETRA_MONITOR("EpetraMapT::getRemoteIndexList");
485  return toXpetra(map_->RemoteIDList(static_cast<int>(GIDList.size()), GIDList.getRawPtr(), nodeIDList.getRawPtr(), 0));
486  }
487 
489  Teuchos::ArrayView<const GlobalOrdinal> getLocalElementList() const {
490  XPETRA_MONITOR("EpetraMapT::getLocalElementList");
491  return ArrayView<const int>(map_->MyGlobalElements(), map_->NumMyElements());
492  }
493 
496  XPETRA_MONITOR("EpetraMapT::getMyGlobalIndicesDevice");
497  Teuchos::ArrayView<const GlobalOrdinal> view = getLocalElementList();
498  if (view.size() == 0)
500  else
501  return Kokkos::View<const global_ordinal_type *, typename Node::device_type, Kokkos::MemoryUnmanaged>(view.data(), view.size());
502  }
503 
505 
507 
508 
510  bool isNodeLocalElement(LocalOrdinal localIndex) const {
511  XPETRA_MONITOR("EpetraMapT::isNodeLocalElement");
512  return map_->MyLID(localIndex);
513  }
514 
516  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const {
517  XPETRA_MONITOR("EpetraMapT::isNodeGlobalElement");
518  return map_->MyGID(globalIndex);
519  }
520 
522  bool isContiguous() const {
523  XPETRA_MONITOR("EpetraMapT::isContiguous");
524  return map_->LinearMap();
525  }
526 
528  bool isDistributed() const {
529  XPETRA_MONITOR("EpetraMapT::isDistributed");
530  return map_->DistributedGlobal();
531  }
532 
535  XPETRA_MONITOR("EpetraMapT::isCompatible");
536  return map_->PointSameAs(toEpetra<GlobalOrdinal, Node>(map));
537  }
538 
541  XPETRA_MONITOR("EpetraMapT::isSameAs");
542  return map_->SameAs(toEpetra<GlobalOrdinal, Node>(map));
543  }
544 
546 
548 
549 
551  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const {
552  XPETRA_MONITOR("EpetraMapT::getComm");
553  return toXpetra(map_->Comm());
554  }
555 
557 
559 
560 
562  std::string description() const {
563  XPETRA_MONITOR("EpetraMapT::description");
564 
565  // This implementation come from Tpetra_Map_def.hpp (without modification)
566  std::ostringstream oss;
567  oss << Teuchos::Describable::description();
568  oss << "{getGlobalNumElements() = " << getGlobalNumElements()
569  << ", getLocalNumElements() = " << getLocalNumElements()
570  << ", isContiguous() = " << isContiguous()
571  << ", isDistributed() = " << isDistributed()
572  << "}";
573  return oss.str();
574  }
575 
577  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {
578  XPETRA_MONITOR("EpetraMapT::describe");
579 
580  const Teuchos::RCP<const Teuchos::Comm<int> > comm_ = getComm();
581 
582  // This implementation come from Tpetra_Map_def.hpp (without modification)
583  using std::endl;
584  using std::setw;
585  using Teuchos::VERB_DEFAULT;
586  using Teuchos::VERB_EXTREME;
587  using Teuchos::VERB_HIGH;
588  using Teuchos::VERB_LOW;
589  using Teuchos::VERB_MEDIUM;
590  using Teuchos::VERB_NONE;
591 
592  const size_t nME = getLocalNumElements();
593  Teuchos::ArrayView<const GlobalOrdinal> myEntries = getLocalElementList();
594  int myImageID = comm_->getRank();
595  int numImages = comm_->getSize();
596 
597  Teuchos::EVerbosityLevel vl = verbLevel;
598  if (vl == VERB_DEFAULT) vl = VERB_LOW;
599 
600  size_t width = 1;
601  for (size_t dec = 10; dec < getGlobalNumElements(); dec *= 10) {
602  ++width;
603  }
604  width = ::std::max<size_t>(width, (size_t)12) + 2; // casting to size_t to avoid ambiguity error when compiling Sacado.
605 
606  Teuchos::OSTab tab(out);
607 
608  if (vl == VERB_NONE) {
609  // do nothing
610  } else if (vl == VERB_LOW) {
611  out << this->description() << endl;
612  } else { // MEDIUM, HIGH or EXTREME
613  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
614  if (myImageID == imageCtr) {
615  if (myImageID == 0) { // this is the root node (only output this info once)
616  out << endl
617  << "Number of Global Entries = " << getGlobalNumElements() << endl
618  << "Maximum of all GIDs = " << getMaxAllGlobalIndex() << endl
619  << "Minimum of all GIDs = " << getMinAllGlobalIndex() << endl
620  << "Index Base = " << getIndexBase() << endl;
621  }
622  out << endl;
623  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
624  out << "Number of Local Elements = " << nME << endl
625  << "Maximum of my GIDs = " << getMaxGlobalIndex() << endl
626  << "Minimum of my GIDs = " << getMinGlobalIndex() << endl;
627  out << endl;
628  }
629  if (vl == VERB_EXTREME) {
630  out << std::setw(width) << "Node ID"
631  << std::setw(width) << "Local Index"
632  << std::setw(width) << "Global Index"
633  << endl;
634  for (size_t i = 0; i < nME; i++) {
635  out << std::setw(width) << myImageID
636  << std::setw(width) << i
637  << std::setw(width) << myEntries[i]
638  << endl;
639  }
640  out << std::flush;
641  }
642  }
643  // Do a few global ops to give I/O a chance to complete
644  comm_->barrier();
645  comm_->barrier();
646  comm_->barrier();
647  }
648  }
649  }
650 
652 
654 
655 
657  RCP<const Map<int, GlobalOrdinal, Node> > removeEmptyProcesses() const {
658  const Epetra_BlockMap *NewMap = map_->RemoveEmptyProcesses();
659  if (!NewMap) {
660  return Teuchos::null;
661  } else {
662  const RCP<const Map<int, GlobalOrdinal, Node> > NewMapX = toXpetra<GlobalOrdinal, Node>(*NewMap);
663  delete NewMap; // NOTE: toXpetra *copys* the epetra map rather than wrapping it, so we have to delete NewMap to avoid a memory leak.
664  return NewMapX;
665  }
666  }
667 
669  RCP<const Map<int, GlobalOrdinal, Node> > replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int> > & /* newComm */) const {
670  throw std::runtime_error("Xpetra::EpetraMapT::replaceCommWithSubset has not yet been implemented in " + std::string(__FILE__) + ":" + std::to_string(__LINE__));
671  TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
672  }
673 
675 
678  XPETRA_MONITOR("EpetraMapT::getGlobalElement");
679 
680  GlobalOrdinal gid = (GlobalOrdinal)map_->GID64(localIndex);
681  if (gid == map_->IndexBase64() - 1)
682  return (-1);
683  else
684  return (gid);
685  }
686 
688 
689 
691  virtual ~EpetraMapT() {}
692 
694  EpetraMapT(const Teuchos::RCP<const Epetra_BlockMap> &map)
695  : map_(map) {
696  TEUCHOS_TEST_FOR_EXCEPTION(!map->GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraMapT: GlobalOrdinal mismatch.");
697  }
698 
700  UnderlyingLib lib() const { return Xpetra::UseEpetra; }
701 
703  const RCP<const Epetra_Map> getEpetra_MapRCP() const { return Teuchos::rcp_static_cast<const Epetra_Map>(map_); }
704  const Epetra_BlockMap &getEpetra_BlockMap() const { return *map_; }
705  const Epetra_Map &getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
706 
708 
709 #ifdef HAVE_XPETRA_TPETRA
713  throw std::runtime_error("Xpetra::EpetraMap::getLocalMap is not implemented in " + std::string(__FILE__) + ":" + std::to_string(__LINE__));
714  }
715 
716  private:
718 #else
719 #ifdef __GNUC__
720 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
721 #endif
722 #endif
723 
724  protected:
725  RCP<const Epetra_BlockMap> map_;
726 }; // EpetraMapT class
727 #endif // #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
728 
729 // specialization on GO=long long and EpetraNode
730 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
731 template <>
732 class EpetraMapT<long long, EpetraNode>
733  : public virtual Map<int, long long, EpetraNode> {
734  typedef int LocalOrdinal;
735  typedef long long GlobalOrdinal;
736  typedef EpetraNode Node;
737 
738  public:
741  typedef Node node_type;
743 
745 
746 
748  EpetraMapT(global_size_t numGlobalElements,
749  GlobalOrdinal indexBase,
750  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
752  // This test come from Tpetra (Epetra doesn't check if numGlobalElements,indexBase are equivalent across images).
753  // In addition, for the test TEST_THROW(M map((myImageID == 0 ? GSTI : 0),0,comm), std::invalid_argument), only one node throw an exception and there is a dead lock.
754  std::string errPrefix;
755  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,indexBase,comm,lOrG): ";
756 
757  if (lg == GloballyDistributed) {
758  const int myImageID = comm->getRank();
759 
760  // check that numGlobalElements,indexBase is equivalent across images
761  global_size_t rootNGE = numGlobalElements;
762  GlobalOrdinal rootIB = indexBase;
763  Teuchos::broadcast<int, global_size_t>(*comm, 0, &rootNGE);
764  Teuchos::broadcast<int, GlobalOrdinal>(*comm, 0, &rootIB);
765  int localChecks[2], globalChecks[2];
766  localChecks[0] = -1; // fail or pass
767  localChecks[1] = 0; // fail reason
768  if (numGlobalElements != rootNGE) {
769  localChecks[0] = myImageID;
770  localChecks[1] = 1;
771  } else if (indexBase != rootIB) {
772  localChecks[0] = myImageID;
773  localChecks[1] = 2;
774  }
775  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass, as well as the reason
776  // these will be -1 and 0 if all procs passed
777  Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 2, localChecks, globalChecks);
778  if (globalChecks[0] != -1) {
779  if (globalChecks[1] == 1) {
780  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
781  errPrefix << "numGlobal must be the same on all nodes (examine node " << globalChecks[0] << ").");
782  } else if (globalChecks[1] == 2) {
783  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
784  errPrefix << "indexBase must be the same on all nodes (examine node " << globalChecks[0] << ").");
785  } else {
786  // logic error on our part
787  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
788  errPrefix << "logic error. Please contact the Tpetra team.");
789  }
790  }
791  }
792 
793  // Note: validity of numGlobalElements checked by Epetra.
794 
795  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), 1, indexBase, *toEpetra(comm))))));
796  }
797 
799  EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
800  // This test come from Tpetra
801  using Teuchos::outArg;
802 
803  const size_t L0 = Teuchos::OrdinalTraits<size_t>::zero();
804  const size_t L1 = Teuchos::OrdinalTraits<size_t>::one();
805  const global_size_t GST0 = Teuchos::OrdinalTraits<global_size_t>::zero();
806  const global_size_t GST1 = Teuchos::OrdinalTraits<global_size_t>::one();
807  const global_size_t GSTI = Teuchos::OrdinalTraits<global_size_t>::invalid();
808 
809  std::string errPrefix;
810  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,numLocal,indexBase,platform): ";
811 
812  // get a internodal communicator from the Platform
813  const int myImageID = comm->getRank();
814 
815  global_size_t global_sum;
816  { // begin scoping block
817  // for communicating failures
818  int localChecks[2], globalChecks[2];
819  /* compute the global size
820  we are computing the number of global elements because exactly ONE of the following is true:
821  - the user didn't specify it, and we need it
822  - the user did specify it, but we need to
823  + validate it against the sum of the local sizes, and
824  + ensure that it is the same on all nodes
825  */
826  Teuchos::reduceAll<int, global_size_t>(*comm, Teuchos::REDUCE_SUM,
827  Teuchos::as<global_size_t>(numLocalElements), outArg(global_sum));
828  /* there are three errors we should be detecting:
829  - numGlobalElements != invalid() and it is incorrect/invalid
830  - numLocalElements invalid (<0)
831  */
832  localChecks[0] = -1;
833  localChecks[1] = 0;
834  if (numLocalElements < L1 && numLocalElements != L0) {
835  // invalid
836  localChecks[0] = myImageID;
837  localChecks[1] = 1;
838  } else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
839  // invalid
840  localChecks[0] = myImageID;
841  localChecks[1] = 2;
842  } else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
843  // incorrect
844  localChecks[0] = myImageID;
845  localChecks[1] = 3;
846  }
847  // now check that indexBase is equivalent across images
848  GlobalOrdinal rootIB = indexBase;
849  Teuchos::broadcast<int, GlobalOrdinal>(*comm, 0, &rootIB); // broadcast one ordinal from node 0
850  if (indexBase != rootIB) {
851  localChecks[0] = myImageID;
852  localChecks[1] = 4;
853  }
854  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass
855  // this will be -1 if all procs passed
856  Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 2, localChecks, globalChecks);
857  if (globalChecks[0] != -1) {
858  if (globalChecks[1] == 1) {
859  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
860  errPrefix << "numLocal is not valid on at least one node (possibly node "
861  << globalChecks[0] << ").");
862  } else if (globalChecks[1] == 2) {
863  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
864  errPrefix << "numGlobal is not valid on at least one node (possibly node "
865  << globalChecks[0] << ").");
866  } else if (globalChecks[1] == 3) {
867  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
868  errPrefix << "numGlobal doesn't match sum of numLocal (== "
869  << global_sum << ") on at least one node (possibly node "
870  << globalChecks[0] << ").");
871  } else if (globalChecks[1] == 4) {
872  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
873  errPrefix << "indexBase is not the same on all nodes (examine node "
874  << globalChecks[0] << ").");
875  } else {
876  // logic error on my part
877  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
878  errPrefix << "logic error. Please contact the Tpetra team.");
879  }
880  }
881  }
882 
883  // set numGlobalElements
884  if (numGlobalElements == GSTI) {
885  numGlobalElements = global_sum;
886  }
887 
888  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), numLocalElements, 1, indexBase, *toEpetra(comm))))));
889  }
890 
892  EpetraMapT(global_size_t numGlobalElements,
893  const Teuchos::ArrayView<const GlobalOrdinal> &elementList,
894  GlobalOrdinal indexBase,
895  const Teuchos::RCP<const Teuchos::Comm<int> > &comm) {
896  if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
897  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(-1, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
898  } else {
899  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(numGlobalElements, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
900  }
901  }
902 
904 
906 
907 
910  XPETRA_MONITOR("EpetraMapT::getGlobalNumElements");
911  return map_->NumGlobalElements64();
912  }
913 
915  size_t getLocalNumElements() const {
916  XPETRA_MONITOR("EpetraMapT::getLocalNumElements");
917  return map_->NumMyElements();
918  }
919 
922  XPETRA_MONITOR("EpetraMapT::getIndexBase");
923  return (GlobalOrdinal)map_->IndexBase64();
924  }
925 
928  XPETRA_MONITOR("EpetraMapT::getMinLocalIndex");
929  return map_->MinLID();
930  }
931 
934  XPETRA_MONITOR("EpetraMapT::getMaxLocalIndex");
935  return map_->MaxLID();
936  }
937 
940  XPETRA_MONITOR("EpetraMapT::getMinGlobalIndex");
941  return (GlobalOrdinal)map_->MinMyGID64();
942  }
943 
946  XPETRA_MONITOR("EpetraMapT::getMaxGlobalIndex");
947  return (GlobalOrdinal)map_->MaxMyGID64();
948  }
949 
952  XPETRA_MONITOR("EpetraMapT::getMinAllGlobalIndex");
953  return (GlobalOrdinal)map_->MinAllGID64();
954  }
955 
958  XPETRA_MONITOR("EpetraMapT::getMaxAllGlobalIndex");
959  return (GlobalOrdinal)map_->MaxAllGID64();
960  }
961 
964  XPETRA_MONITOR("EpetraMapT::getLocalElement");
965  return map_->LID(globalIndex);
966  }
967 
969  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList, const Teuchos::ArrayView<int> &nodeIDList, const Teuchos::ArrayView<LocalOrdinal> &LIDList) const {
970  XPETRA_MONITOR("EpetraMapT::getRemoteIndexList");
971  return toXpetra(map_->RemoteIDList(GIDList.size(), GIDList.getRawPtr(), nodeIDList.getRawPtr(), LIDList.getRawPtr()));
972  }
973 
975  LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList, const Teuchos::ArrayView<int> &nodeIDList) const {
976  XPETRA_MONITOR("EpetraMapT::getRemoteIndexList");
977  return toXpetra(map_->RemoteIDList(GIDList.size(), GIDList.getRawPtr(), nodeIDList.getRawPtr(), 0));
978  }
979 
981  Teuchos::ArrayView<const GlobalOrdinal> getLocalElementList() const {
982  XPETRA_MONITOR("EpetraMapT::getLocalElementList");
983  return ArrayView<const long long>(map_->MyGlobalElements64(), map_->NumMyElements());
984  }
985 
988  XPETRA_MONITOR("EpetraMapT::getMyGlobalIndicesDevice");
989  Teuchos::ArrayView<const GlobalOrdinal> view = getLocalElementList();
990  if (view.size() == 0)
992  else
993  return Kokkos::View<const global_ordinal_type *, typename Node::device_type, Kokkos::MemoryUnmanaged>(view.data(), view.size());
994  }
995 
997 
999 
1000 
1002  bool isNodeLocalElement(LocalOrdinal localIndex) const {
1003  XPETRA_MONITOR("EpetraMapT::isNodeLocalElement");
1004  return map_->MyLID(localIndex);
1005  }
1006 
1008  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const {
1009  XPETRA_MONITOR("EpetraMapT::isNodeGlobalElement");
1010  return map_->MyGID(globalIndex);
1011  }
1012 
1014  bool isContiguous() const {
1015  XPETRA_MONITOR("EpetraMapT::isContiguous");
1016  return map_->LinearMap();
1017  }
1018 
1020  bool isDistributed() const {
1021  XPETRA_MONITOR("EpetraMapT::isDistributed");
1022  return map_->DistributedGlobal();
1023  }
1024 
1027  XPETRA_MONITOR("EpetraMapT::isCompatible");
1028  return map_->PointSameAs(toEpetra<GlobalOrdinal, Node>(map));
1029  }
1030 
1033  XPETRA_MONITOR("EpetraMapT::isSameAs");
1034  return map_->SameAs(toEpetra<GlobalOrdinal, Node>(map));
1035  }
1036 
1038 
1040 
1041 
1043  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const {
1044  XPETRA_MONITOR("EpetraMapT::getComm");
1045  return toXpetra(map_->Comm());
1046  }
1047 
1049 
1051 
1052 
1054  std::string description() const {
1055  XPETRA_MONITOR("EpetraMapT::description");
1056 
1057  // This implementation come from Tpetra_Map_def.hpp (without modification)
1058  std::ostringstream oss;
1059  oss << Teuchos::Describable::description();
1060  oss << "{getGlobalNumElements() = " << getGlobalNumElements()
1061  << ", getLocalNumElements() = " << getLocalNumElements()
1062  << ", isContiguous() = " << isContiguous()
1063  << ", isDistributed() = " << isDistributed()
1064  << "}";
1065  return oss.str();
1066  }
1067 
1069  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {
1070  XPETRA_MONITOR("EpetraMapT::describe");
1071 
1072  const Teuchos::RCP<const Teuchos::Comm<int> > comm_ = getComm();
1073 
1074  // This implementation come from Tpetra_Map_def.hpp (without modification)
1075  using std::endl;
1076  using std::setw;
1077  using Teuchos::VERB_DEFAULT;
1078  using Teuchos::VERB_EXTREME;
1079  using Teuchos::VERB_HIGH;
1080  using Teuchos::VERB_LOW;
1081  using Teuchos::VERB_MEDIUM;
1082  using Teuchos::VERB_NONE;
1083 
1084  const size_t nME = getLocalNumElements();
1085  Teuchos::ArrayView<const GlobalOrdinal> myEntries = getLocalElementList();
1086  int myImageID = comm_->getRank();
1087  int numImages = comm_->getSize();
1088 
1089  Teuchos::EVerbosityLevel vl = verbLevel;
1090  if (vl == VERB_DEFAULT) vl = VERB_LOW;
1091 
1092  size_t width = 1;
1093  for (size_t dec = 10; dec < getGlobalNumElements(); dec *= 10) {
1094  ++width;
1095  }
1096  width = ::std::max<size_t>(width, (size_t)12) + 2; // casting to size_t to avoid ambiguity error when compiling Sacado.
1097 
1098  Teuchos::OSTab tab(out);
1099 
1100  if (vl == VERB_NONE) {
1101  // do nothing
1102  } else if (vl == VERB_LOW) {
1103  out << this->description() << endl;
1104  } else { // MEDIUM, HIGH or EXTREME
1105  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1106  if (myImageID == imageCtr) {
1107  if (myImageID == 0) { // this is the root node (only output this info once)
1108  out << endl
1109  << "Number of Global Entries = " << getGlobalNumElements() << endl
1110  << "Maximum of all GIDs = " << getMaxAllGlobalIndex() << endl
1111  << "Minimum of all GIDs = " << getMinAllGlobalIndex() << endl
1112  << "Index Base = " << getIndexBase() << endl;
1113  }
1114  out << endl;
1115  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1116  out << "Number of Local Elements = " << nME << endl
1117  << "Maximum of my GIDs = " << getMaxGlobalIndex() << endl
1118  << "Minimum of my GIDs = " << getMinGlobalIndex() << endl;
1119  out << endl;
1120  }
1121  if (vl == VERB_EXTREME) {
1122  out << std::setw(width) << "Node ID"
1123  << std::setw(width) << "Local Index"
1124  << std::setw(width) << "Global Index"
1125  << endl;
1126  for (size_t i = 0; i < nME; i++) {
1127  out << std::setw(width) << myImageID
1128  << std::setw(width) << i
1129  << std::setw(width) << myEntries[i]
1130  << endl;
1131  }
1132  out << std::flush;
1133  }
1134  }
1135  // Do a few global ops to give I/O a chance to complete
1136  comm_->barrier();
1137  comm_->barrier();
1138  comm_->barrier();
1139  }
1140  }
1141  }
1142 
1144 
1146 
1147 
1149  RCP<const Map<int, GlobalOrdinal, Node> > removeEmptyProcesses() const {
1150  const Epetra_BlockMap *NewMap = map_->RemoveEmptyProcesses();
1151  if (!NewMap) {
1152  return Teuchos::null;
1153  } else {
1154  const RCP<const Map<int, GlobalOrdinal, Node> > NewMapX = toXpetra<GlobalOrdinal, Node>(*NewMap);
1155  delete NewMap; // NOTE: toXpetra *copys* the epetra map rather than wrapping it, so we have to delete NewMap to avoid a memory leak.
1156  return NewMapX;
1157  }
1158  }
1159 
1161  RCP<const Map<int, GlobalOrdinal, Node> > replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int> > & /* newComm */) const {
1162  throw std::runtime_error("Xpetra::EpetraMapT::replaceCommWithSubset has not yet been implemented in " + std::string(__FILE__) + ":" + std::to_string(__LINE__));
1163  // return Teuchos::null; // unreachable
1164  }
1165 
1167 
1170  XPETRA_MONITOR("EpetraMapT::getGlobalElement");
1171 
1172  GlobalOrdinal gid = (GlobalOrdinal)map_->GID64(localIndex);
1173  if (gid == map_->IndexBase64() - 1)
1174  return (-1);
1175  else
1176  return (gid);
1177  }
1178 
1180 
1181 
1183  virtual ~EpetraMapT() {}
1184 
1186  EpetraMapT(const Teuchos::RCP<const Epetra_BlockMap> &map)
1187  : map_(map) {
1188  TEUCHOS_TEST_FOR_EXCEPTION(!map->GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraMapT: GlobalOrdinal mismatch.");
1189  }
1190 
1193 
1195  const RCP<const Epetra_Map> &getEpetra_MapRCP() const { return Teuchos::rcp_static_cast<const Epetra_Map>(map_); }
1196  const Epetra_BlockMap &getEpetra_BlockMap() const { return *map_; }
1197  const Epetra_Map &getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
1198 
1199 #ifdef HAVE_XPETRA_TPETRA
1203  throw std::runtime_error("Xpetra::EpetraMap::getLocalMap is not implemented in " + std::string(__FILE__) + ":" + std::to_string(__LINE__));
1204  }
1205 
1206  private:
1208 #else
1209 #ifdef __GNUC__
1210 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
1211 #endif
1212 #endif
1213 
1215 
1216  protected:
1217  RCP<const Epetra_BlockMap> map_;
1218 }; // EpetraMapT class
1219 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1220 
1221 } // namespace Xpetra
1222 
1223 #endif // XPETRA_EPETRAMAP_HPP
Map< LocalOrdinal, GlobalOrdinal, Node >::global_indices_array_device_type global_indices_array_device_type
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const
Return the process ranks for the given global indices.
GlobalOrdinal global_ordinal_type
GlobalOrdinal getIndexBase() const
The index base for this Map.
GlobalOrdinal getIndexBase() const
The index base for this Map.
std::string description() const
Return a simple one-line description of this object.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
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 Teuchos::FancyOStream.
typename Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
const RCP< const Epetra_Map > & getEpetra_MapRCP() const
Get the underlying Epetra map.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
const Epetra_BlockMap & getEpetra_BlockMap() const
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a view of the global indices owned by this process.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
EpetraMapT(const Teuchos::RCP< const Epetra_BlockMap > &map)
EpetraMapT constructor to wrap a Epetra_Map object.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
std::string description() const
Return a simple one-line description of this object.
UnderlyingLib lib() const
Get the library used by this object (Epetra or Epetra?)
GlobalOrdinal getIndexBase() const
The index base for this Map.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
const Epetra_BlockMap & getEpetra_BlockMap() const
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
Exception throws to report errors in the internal logical of the program.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
UnderlyingLib lib() const
Get the library used by this object (Epetra or Epetra?)
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
bool isNodeGlobalElement(GlobalOrdinal) const
Whether the given global index is valid for this Map on this process.
EpetraMapT(const Teuchos::RCP< const Epetra_BlockMap > &map)
EpetraMapT constructor to wrap a Epetra_Map object.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const
Return the process ranks for the given global indices.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a view of the global indices owned by this process.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
Return the process ranks and corresponding local indices for the given global indices.
void describe(Teuchos::FancyOStream &, const Teuchos::EVerbosityLevel=Teuchos::Describable::verbLevel_default) const
Print this object with the given verbosity level to the given Teuchos::FancyOStream.
EpetraMapT(global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Constructor with user-defined arbitrary (possibly noncontiguous) distribution.
Map< LocalOrdinal, GlobalOrdinal, Node >::global_indices_array_type global_indices_array_type
LocalOrdinal getMinLocalIndex() const
The minimum local index.
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on this process.
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 Teuchos::FancyOStream.
EpetraMapT(global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Constructor with user-defined arbitrary (possibly noncontiguous) distribution.
typename Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &) const
True if and only if map is identical to this Map.
typename Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Constructor with a user-defined contiguous distribution.
size_t getLocalNumElements() const
The number of elements belonging to the calling process.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on this process.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
Return the process ranks and corresponding local indices for the given global indices.
const Epetra_Map & getEpetra_Map() const
RCP< const Epetra_BlockMap > map_
#define IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG(sourceCode)
EpetraMapT(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed)
Constructor with Tpetra-defined contiguous uniform distribution.
const Epetra_BlockMap & getEpetra_BlockMap() const
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
Return the global index for a given local index. Note that this returns -1 if not found on this proce...
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &, const Teuchos::ArrayView< int > &, const Teuchos::ArrayView< LocalOrdinal > &) const
Return the process ranks and corresponding local indices for the given global indices.
RCP< const Map< int, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &) const
Replace this Map&#39;s communicator with a subset communicator.
RCP< const Epetra_BlockMap > map_
size_t global_size_t
Global size_t object.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
size_t getLocalNumElements() const
The number of elements belonging to the calling process.
EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Constructor with a user-defined contiguous distribution.
Kokkos::View< const global_ordinal_type *, typename Node::device_type > global_indices_array_device_type
Map< LocalOrdinal, GlobalOrdinal, Node >::global_indices_array_device_type global_indices_array_device_type
global_size_t getGlobalNumElements() const
The number of elements in this Map.
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
EpetraMapT(const Teuchos::RCP< const Epetra_BlockMap > &map)
EpetraMapT constructor to wrap a Epetra_Map object.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
Return the global index for a given local index. Note that this returns -1 if not found on this proce...
UnderlyingLib lib() const
Get the library used by this object (Epetra or Epetra?)
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
const Epetra_Map & getEpetra_Map() const
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
virtual ~EpetraMapT()
Destructor.
const RCP< const Epetra_Map > & getEpetra_MapRCP() const
Get the underlying Epetra map.
size_t getLocalNumElements() const
The number of elements belonging to the calling process.
bool isNodeLocalElement(LocalOrdinal) const
Whether the given local index is valid for this Map on this process.
LocalOrdinal getLocalElement(GlobalOrdinal) const
The local index corresponding to the given global index.
#define XPETRA_MONITOR(funcName)
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
const RCP< const Epetra_Map > getEpetra_MapRCP() const
Get the underlying Epetra map.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
global_indices_array_device_type getMyGlobalIndicesDevice() const
Return a view of the global indices owned by this process.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
RCP< const Map< int, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &) const
Replace this Map&#39;s communicator with a subset communicator.
EpetraMapT(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed)
Constructor with Tpetra-defined contiguous uniform distribution.
EpetraMapT(global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Constructor with user-defined arbitrary (possibly noncontiguous) distribution.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
GlobalOrdinal getGlobalElement(LocalOrdinal) const
Return the global index for a given local index. Note that this returns -1 if not found on this proce...
EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Constructor with a user-defined contiguous distribution.
global_indices_array_device_type getMyGlobalIndicesDevice() const
Return a view of the global indices owned by this process.
EpetraMapT(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed)
Constructor with Tpetra-defined contiguous uniform distribution.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &) const
True if and only if map is compatible with this Map.
RCP< const Map< int, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &) const
Replace this Map&#39;s communicator with a subset communicator.
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a view of the global indices owned by this process.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &, const Teuchos::ArrayView< int > &) const
Return the process ranks for the given global indices.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
std::string description() const
Return a simple one-line description of this object.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
global_indices_array_device_type getMyGlobalIndicesDevice() const
Return a view of the global indices owned by this process.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)