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 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_EPETRAMAP_HPP
47 #define XPETRA_EPETRAMAP_HPP
48 
49 
51 
52 #include "Xpetra_Map.hpp"
53 
54 #include <Epetra_Map.h>
55 #include <Epetra_BlockMap.h>
56 
57 #include "Xpetra_Utils.hpp"
58 #include "Xpetra_EpetraUtils.hpp"
60 
61 #include "Xpetra_ConfigDefs.hpp"
62 
63 namespace Xpetra {
64 
65  // TODO: move that elsewhere
66  template<class GlobalOrdinal, class Node>
67  const Epetra_Map & toEpetra(const Map<int,GlobalOrdinal, Node> &);
68 
69  template<class GlobalOrdinal, class Node>
70  const Epetra_Map & toEpetra(const RCP< const Map<int, GlobalOrdinal, Node> > &);
71 
72  //template<class GlobalOrdinal>
73  //const RCP< const Map<int, GlobalOrdinal> > toXpetra(const RCP< const Epetra_Map > &);
74 
75  template<class GlobalOrdinal, class Node>
76  const RCP< const Map<int, GlobalOrdinal, Node> > toXpetra(const Epetra_BlockMap &);
77 
78  // stub implementation for EpetraMapT
79  template<class GlobalOrdinal, class Node>
80  class EpetraMapT
81  : public virtual Map<int, GlobalOrdinal, Node>
82  {
83  typedef int LocalOrdinal;
84 
85  public:
86  typedef int local_ordinal_type;
87  typedef GlobalOrdinal global_ordinal_type;
88  typedef Node node_type;
89 
91 
92 
94  EpetraMapT(global_size_t numGlobalElements,
95  GlobalOrdinal indexBase,
96  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
98  {
99  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
100  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
101  }
102 
104  EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm) {
105  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
106  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
107  }
108 
110  EpetraMapT(global_size_t numGlobalElements,
111  const Teuchos::ArrayView< const GlobalOrdinal > &elementList,
112  GlobalOrdinal indexBase,
113  const Teuchos::RCP< const Teuchos::Comm< int > > &comm) {
114  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
115  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
116  }
117 
119 
121 
122 
124  global_size_t getGlobalNumElements() const { return 0; }
125 
127  size_t getNodeNumElements() const { return 0; }
128 
130  GlobalOrdinal getIndexBase() const { return 0; }
131 
133  LocalOrdinal getMinLocalIndex() const { return 0; }
134 
136  LocalOrdinal getMaxLocalIndex() const { return 0; }
137 
139  GlobalOrdinal getMinGlobalIndex() const { return 0; }
140 
142  GlobalOrdinal getMaxGlobalIndex() const { return 0; }
143 
145  GlobalOrdinal getMinAllGlobalIndex() const { return 0; }
146 
148  GlobalOrdinal getMaxAllGlobalIndex() const { return 0; }
149 
151  LocalOrdinal getLocalElement(GlobalOrdinal /* globalIndex */) const { return 0; }
152 
154  LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &/* GIDList */, const Teuchos::ArrayView< int > &/* nodeIDList */, const Teuchos::ArrayView< LocalOrdinal > &/* LIDList */) const { return Xpetra::IDNotPresent; }
155 
157  LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &/* GIDList */, const Teuchos::ArrayView< int > &/* nodeIDList */) const { return Xpetra::IDNotPresent; }
158 
160  //Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const;
161 
162  Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const { return ArrayView< const GlobalOrdinal >(); }
164 
166 
167 
169  bool isNodeLocalElement(LocalOrdinal /* localIndex */) const { return false; }
170 
172  bool isNodeGlobalElement(GlobalOrdinal /* globalIndex */) const { return false; }
173 
175  bool isContiguous() const { return false; }
176 
178  bool isDistributed() const { return false; }
179 
181  bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &/* map */) const { return false; }
182 
184  bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &/* map */) const { return false; }
185 
187 
189 
190 
192  Teuchos::RCP< const Teuchos::Comm< int > > getComm() const { return Teuchos::null; }
193 
194 
196 
198 
199 
201  std::string description() const { return std::string(""); }
202 
204  void describe(Teuchos::FancyOStream &/* out */, const Teuchos::EVerbosityLevel /* verbLevel */=Teuchos::Describable::verbLevel_default) const { }
205 
207 
209 
210 
212  RCP<const Map<int,GlobalOrdinal,Node> > removeEmptyProcesses() const { return Teuchos::null; }
213 
215  RCP<const Map<int,GlobalOrdinal,Node> > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &/* newComm */) const { return Teuchos::null; }
216 
218 
220  GlobalOrdinal getGlobalElement(LocalOrdinal /* localIndex */) const { return -1; }
221 
223 
224 
226  virtual ~EpetraMapT() {}
227 
229  EpetraMapT(const Teuchos::RCP<const Epetra_BlockMap> &map)
230  : map_(map) {
231  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
232  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
233  }
234 
236  UnderlyingLib lib() const { return Xpetra::UseEpetra; }
237 
239  //const RCP< const Epetra_Map > & getEpetra_Map() const { return map_; }
240  const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
241  const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
242 
243 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
244 #ifdef HAVE_XPETRA_TPETRA
245  using local_map_type = typename Map<LocalOrdinal, GlobalOrdinal, Node>::local_map_type;
247  local_map_type getLocalMap () const {
248  throw std::runtime_error("Xpetra::EpetraMap::getLocalMap is not implemented.");
249  }
250 #else
251 #ifdef __GNUC__
252 #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."
253 #endif
254 #endif
255 #endif
256 
258 
259  protected:
260 
261  RCP<const Epetra_BlockMap> map_;
262  }; // EpetraMapT class
263 
264  // specialization on GO=int and EpetraNode
265 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
266  template<>
267  class EpetraMapT<int, EpetraNode>
268  : public virtual Map<int, int, EpetraNode>
269  {
270  typedef int LocalOrdinal;
271  typedef int GlobalOrdinal;
272  typedef EpetraNode Node;
273 
274  public:
277  typedef Node node_type;
278 
280 
281 
283  EpetraMapT(global_size_t numGlobalElements,
284  GlobalOrdinal indexBase,
285  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
287  {
288  // This test come from Tpetra (Epetra doesn't check if numGlobalElements,indexBase are equivalent across images).
289  // 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.
290  std::string errPrefix;
291  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,indexBase,comm,lOrG): ";
292 
293  if (lg == GloballyDistributed) {
294  const int myImageID = comm->getRank();
295 
296  // check that numGlobalElements,indexBase is equivalent across images
297  global_size_t rootNGE = numGlobalElements;
298  GlobalOrdinal rootIB = indexBase;
299  Teuchos::broadcast<int,global_size_t>(*comm,0,&rootNGE);
300  Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB);
301  int localChecks[2], globalChecks[2];
302  localChecks[0] = -1; // fail or pass
303  localChecks[1] = 0; // fail reason
304  if (numGlobalElements != rootNGE) {
305  localChecks[0] = myImageID;
306  localChecks[1] = 1;
307  }
308  else if (indexBase != rootIB) {
309  localChecks[0] = myImageID;
310  localChecks[1] = 2;
311  }
312  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass, as well as the reason
313  // these will be -1 and 0 if all procs passed
314  Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
315  if (globalChecks[0] != -1) {
316  if (globalChecks[1] == 1) {
317  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
318  errPrefix << "numGlobal must be the same on all nodes (examine node " << globalChecks[0] << ").");
319  }
320  else if (globalChecks[1] == 2) {
321  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
322  errPrefix << "indexBase must be the same on all nodes (examine node " << globalChecks[0] << ").");
323  }
324  else {
325  // logic error on our part
326  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
327  errPrefix << "logic error. Please contact the Tpetra team.");
328  }
329  }
330  }
331 
332  // Note: validity of numGlobalElements checked by Epetra.
333 
334  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), 1, indexBase, *toEpetra(comm))))));
335  }
336 
338  EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
339  {
340  // This test come from Tpetra
341  using Teuchos::outArg;
342 
343  const size_t L0 = Teuchos::OrdinalTraits<size_t>::zero();
344  const size_t L1 = Teuchos::OrdinalTraits<size_t>::one();
345  const global_size_t GST0 = Teuchos::OrdinalTraits<global_size_t>::zero();
346  const global_size_t GST1 = Teuchos::OrdinalTraits<global_size_t>::one();
347  const global_size_t GSTI = Teuchos::OrdinalTraits<global_size_t>::invalid();
348 
349  std::string errPrefix;
350  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,numLocal,indexBase,platform): ";
351 
352  // get a internodal communicator from the Platform
353  const int myImageID = comm->getRank();
354 
355  global_size_t global_sum;
356  { // begin scoping block
357  // for communicating failures
358  int localChecks[2], globalChecks[2];
359  /* compute the global size
360  we are computing the number of global elements because exactly ONE of the following is true:
361  - the user didn't specify it, and we need it
362  - the user did specify it, but we need to
363  + validate it against the sum of the local sizes, and
364  + ensure that it is the same on all nodes
365  */
366  Teuchos::reduceAll<int,global_size_t>(*comm,Teuchos::REDUCE_SUM,
367  Teuchos::as<global_size_t>(numLocalElements),outArg(global_sum));
368  /* there are three errors we should be detecting:
369  - numGlobalElements != invalid() and it is incorrect/invalid
370  - numLocalElements invalid (<0)
371  */
372  localChecks[0] = -1;
373  localChecks[1] = 0;
374  if (numLocalElements < L1 && numLocalElements != L0) {
375  // invalid
376  localChecks[0] = myImageID;
377  localChecks[1] = 1;
378  }
379  else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
380  // invalid
381  localChecks[0] = myImageID;
382  localChecks[1] = 2;
383  }
384  else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
385  // incorrect
386  localChecks[0] = myImageID;
387  localChecks[1] = 3;
388  }
389  // now check that indexBase is equivalent across images
390  GlobalOrdinal rootIB = indexBase;
391  Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB); // broadcast one ordinal from node 0
392  if (indexBase != rootIB) {
393  localChecks[0] = myImageID;
394  localChecks[1] = 4;
395  }
396  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass
397  // this will be -1 if all procs passed
398  Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
399  if (globalChecks[0] != -1) {
400  if (globalChecks[1] == 1) {
401  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
402  errPrefix << "numLocal is not valid on at least one node (possibly node "
403  << globalChecks[0] << ").");
404  }
405  else if (globalChecks[1] == 2) {
406  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
407  errPrefix << "numGlobal is not valid on at least one node (possibly node "
408  << globalChecks[0] << ").");
409  }
410  else if (globalChecks[1] == 3) {
411  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
412  errPrefix << "numGlobal doesn't match sum of numLocal (== "
413  << global_sum << ") on at least one node (possibly node "
414  << globalChecks[0] << ").");
415  }
416  else if (globalChecks[1] == 4) {
417  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
418  errPrefix << "indexBase is not the same on all nodes (examine node "
419  << globalChecks[0] << ").");
420  }
421  else {
422  // logic error on my part
423  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
424  errPrefix << "logic error. Please contact the Tpetra team.");
425  }
426  }
427 
428  }
429 
430  // set numGlobalElements
431  if (numGlobalElements == GSTI) {
432  numGlobalElements = global_sum;}
433 
434  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))))));
435  }
436 
438  EpetraMapT(global_size_t numGlobalElements,
439  const Teuchos::ArrayView< const GlobalOrdinal > &elementList,
440  GlobalOrdinal indexBase,
441  const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
442  {
443  if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
444  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))))));
445  } else {
446  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))))));
447  }
448  }
449 
451 
453 
454 
456  global_size_t getGlobalNumElements() const { XPETRA_MONITOR("EpetraMapT::getGlobalNumElements"); return map_->NumGlobalElements64(); }
457 
459  size_t getNodeNumElements() const { XPETRA_MONITOR("EpetraMapT::getNodeNumElements"); return map_->NumMyElements(); }
460 
462  GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("EpetraMapT::getIndexBase"); return (GlobalOrdinal) map_->IndexBase64(); }
463 
465  LocalOrdinal getMinLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinLocalIndex"); return map_->MinLID(); }
466 
468  LocalOrdinal getMaxLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxLocalIndex"); return map_->MaxLID(); }
469 
471  GlobalOrdinal getMinGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinGlobalIndex"); return (GlobalOrdinal) map_->MinMyGID64(); }
472 
474  GlobalOrdinal getMaxGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxGlobalIndex"); return (GlobalOrdinal) map_->MaxMyGID64(); }
475 
477  GlobalOrdinal getMinAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinAllGlobalIndex"); return (GlobalOrdinal) map_->MinAllGID64(); }
478 
480  GlobalOrdinal getMaxAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxAllGlobalIndex"); return (GlobalOrdinal) map_->MaxAllGID64(); }
481 
483  LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::getLocalElement"); return map_->LID(globalIndex); }
484 
485 
487  LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList,
488  const Teuchos::ArrayView< int > &nodeIDList,
489  const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
490  {
491  XPETRA_MONITOR("EpetraMapT::getRemoteIndexList");
492  return toXpetra(map_->RemoteIDList(static_cast<int>(GIDList.size()), GIDList.getRawPtr(), nodeIDList.getRawPtr(), LIDList.getRawPtr()));
493  }
494 
495 
497  LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList,
498  const Teuchos::ArrayView< int > &nodeIDList) const
499  {
500  XPETRA_MONITOR("EpetraMapT::getRemoteIndexList");
501  return toXpetra(map_->RemoteIDList(static_cast<int>(GIDList.size()), GIDList.getRawPtr(), nodeIDList.getRawPtr(), 0));
502  }
503 
504 
506  Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const { XPETRA_MONITOR("EpetraMapT::getNodeElementList"); return ArrayView< const int >(map_->MyGlobalElements(), map_->NumMyElements()); }
508 
510 
511 
513  bool isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeLocalElement"); return map_->MyLID(localIndex); }
514 
516  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeGlobalElement"); return map_->MyGID(globalIndex); }
517 
519  bool isContiguous() const { XPETRA_MONITOR("EpetraMapT::isContiguous"); return map_->LinearMap(); }
520 
522  bool isDistributed() const { XPETRA_MONITOR("EpetraMapT::isDistributed"); return map_->DistributedGlobal(); }
523 
525  bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isCompatible"); return map_->PointSameAs(toEpetra<GlobalOrdinal,Node>(map)); }
526 
528  bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isSameAs"); return map_->SameAs(toEpetra<GlobalOrdinal,Node>(map)); }
529 
531 
533 
534 
536  Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
537  {
538  XPETRA_MONITOR("EpetraMapT::getComm");
539  return toXpetra(map_->Comm());
540  }
541 
542 
544 
546 
547 
549  std::string description() const {
550  XPETRA_MONITOR("EpetraMapT::description");
551 
552  // This implementation come from Tpetra_Map_def.hpp (without modification)
553  std::ostringstream oss;
554  oss << Teuchos::Describable::description();
555  oss << "{getGlobalNumElements() = " << getGlobalNumElements()
556  << ", getNodeNumElements() = " << getNodeNumElements()
557  << ", isContiguous() = " << isContiguous()
558  << ", isDistributed() = " << isDistributed()
559  << "}";
560  return oss.str();
561  }
562 
564  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const {
565  XPETRA_MONITOR("EpetraMapT::describe");
566 
567  const Teuchos::RCP<const Teuchos::Comm<int> > comm_ = getComm();
568 
569  // This implementation come from Tpetra_Map_def.hpp (without modification)
570  using std::endl;
571  using std::setw;
572  using Teuchos::VERB_DEFAULT;
573  using Teuchos::VERB_NONE;
574  using Teuchos::VERB_LOW;
575  using Teuchos::VERB_MEDIUM;
576  using Teuchos::VERB_HIGH;
577  using Teuchos::VERB_EXTREME;
578 
579  const size_t nME = getNodeNumElements();
580  Teuchos::ArrayView<const GlobalOrdinal> myEntries = getNodeElementList();
581  int myImageID = comm_->getRank();
582  int numImages = comm_->getSize();
583 
584  Teuchos::EVerbosityLevel vl = verbLevel;
585  if (vl == VERB_DEFAULT) vl = VERB_LOW;
586 
587  size_t width = 1;
588  for (size_t dec=10; dec<getGlobalNumElements(); dec *= 10) {
589  ++width;
590  }
591  width = ::std::max<size_t>(width, (size_t) 12) + 2; // casting to size_t to avoid ambiguity error when compiling Sacado.
592 
593  Teuchos::OSTab tab(out);
594 
595  if (vl == VERB_NONE) {
596  // do nothing
597  }
598  else if (vl == VERB_LOW) {
599  out << this->description() << endl;
600  }
601  else { // MEDIUM, HIGH or EXTREME
602  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
603  if (myImageID == imageCtr) {
604  if (myImageID == 0) { // this is the root node (only output this info once)
605  out << endl
606  << "Number of Global Entries = " << getGlobalNumElements() << endl
607  << "Maximum of all GIDs = " << getMaxAllGlobalIndex() << endl
608  << "Minimum of all GIDs = " << getMinAllGlobalIndex() << endl
609  << "Index Base = " << getIndexBase() << endl;
610  }
611  out << endl;
612  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
613  out << "Number of Local Elements = " << nME << endl
614  << "Maximum of my GIDs = " << getMaxGlobalIndex() << endl
615  << "Minimum of my GIDs = " << getMinGlobalIndex() << endl;
616  out << endl;
617  }
618  if (vl == VERB_EXTREME) {
619  out << std::setw(width) << "Node ID"
620  << std::setw(width) << "Local Index"
621  << std::setw(width) << "Global Index"
622  << endl;
623  for (size_t i=0; i < nME; i++) {
624  out << std::setw(width) << myImageID
625  << std::setw(width) << i
626  << std::setw(width) << myEntries[i]
627  << endl;
628  }
629  out << std::flush;
630  }
631  }
632  // Do a few global ops to give I/O a chance to complete
633  comm_->barrier();
634  comm_->barrier();
635  comm_->barrier();
636  }
637  }
638  }
639 
641 
643 
644 
646  RCP<const Map<int,GlobalOrdinal,Node> > removeEmptyProcesses() const {
647  const Epetra_BlockMap * NewMap = map_->RemoveEmptyProcesses();
648  if (!NewMap) {
649  return Teuchos::null;
650  } else {
651  const RCP< const Map<int, GlobalOrdinal, Node> > NewMapX = toXpetra<GlobalOrdinal, Node>(*NewMap);
652  delete NewMap; // NOTE: toXpetra *copys* the epetra map rather than wrapping it, so we have to delete NewMap to avoid a memory leak.
653  return NewMapX;
654  }
655  }
656 
658  RCP<const Map<int,GlobalOrdinal,Node> > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &/* newComm */) const {
659  throw std::runtime_error("Xpetra::EpetraMapT::replaceCommWithSubset has not yet been implemented.");
660  TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
661  }
662 
664 
667  XPETRA_MONITOR("EpetraMapT::getGlobalElement");
668 
669  GlobalOrdinal gid = (GlobalOrdinal) map_->GID64(localIndex);
670  if (gid == map_->IndexBase64()-1) return (-1);
671  else return (gid);
672  }
673 
675 
676 
678  virtual ~EpetraMapT() {}
679 
681  EpetraMapT(const Teuchos::RCP<const Epetra_BlockMap> &map)
682  : map_(map) {
683  TEUCHOS_TEST_FOR_EXCEPTION(!map->GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraMapT: GlobalOrdinal mismatch.");
684  }
685 
687  UnderlyingLib lib() const { return Xpetra::UseEpetra; }
688 
690  //const RCP< const Epetra_Map > & getEpetra_Map() const { return map_; }
691  const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
692  const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
693 
695 
696 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
697 #ifdef HAVE_XPETRA_TPETRA
698  using local_map_type = typename Map<LocalOrdinal, GlobalOrdinal, Node>::local_map_type;
700  local_map_type getLocalMap () const {
701  throw std::runtime_error("Xpetra::EpetraMap::getLocalMap is not implemented.");
702  }
703 
704  private:
705  mutable local_map_type localMap_;
706 #else
707 #ifdef __GNUC__
708 #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."
709 #endif
710 #endif
711 #endif
712 
713  protected:
714 
715  RCP<const Epetra_BlockMap> map_;
716 }; // EpetraMapT class
717 #endif // #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
718 
719 // specialization on GO=long long and EpetraNode
720 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
721  template<>
722  class EpetraMapT<long long, EpetraNode>
723  : public virtual Map<int, long long, EpetraNode>
724  {
725  typedef int LocalOrdinal;
726  typedef long long GlobalOrdinal;
727  typedef EpetraNode Node;
728 
729  public:
732  typedef Node node_type;
733 
735 
736 
738  EpetraMapT(global_size_t numGlobalElements,
739  GlobalOrdinal indexBase,
740  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
742  {
743  // This test come from Tpetra (Epetra doesn't check if numGlobalElements,indexBase are equivalent across images).
744  // 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.
745  std::string errPrefix;
746  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,indexBase,comm,lOrG): ";
747 
748  if (lg == GloballyDistributed) {
749  const int myImageID = comm->getRank();
750 
751  // check that numGlobalElements,indexBase is equivalent across images
752  global_size_t rootNGE = numGlobalElements;
753  GlobalOrdinal rootIB = indexBase;
754  Teuchos::broadcast<int,global_size_t>(*comm,0,&rootNGE);
755  Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB);
756  int localChecks[2], globalChecks[2];
757  localChecks[0] = -1; // fail or pass
758  localChecks[1] = 0; // fail reason
759  if (numGlobalElements != rootNGE) {
760  localChecks[0] = myImageID;
761  localChecks[1] = 1;
762  }
763  else if (indexBase != rootIB) {
764  localChecks[0] = myImageID;
765  localChecks[1] = 2;
766  }
767  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass, as well as the reason
768  // these will be -1 and 0 if all procs passed
769  Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
770  if (globalChecks[0] != -1) {
771  if (globalChecks[1] == 1) {
772  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
773  errPrefix << "numGlobal must be the same on all nodes (examine node " << globalChecks[0] << ").");
774  }
775  else if (globalChecks[1] == 2) {
776  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
777  errPrefix << "indexBase must be the same on all nodes (examine node " << globalChecks[0] << ").");
778  }
779  else {
780  // logic error on our part
781  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
782  errPrefix << "logic error. Please contact the Tpetra team.");
783  }
784  }
785  }
786 
787  // Note: validity of numGlobalElements checked by Epetra.
788 
789  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), 1, indexBase, *toEpetra(comm))))));
790  }
791 
793  EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm) {
794  // This test come from Tpetra
795  using Teuchos::outArg;
796 
797  const size_t L0 = Teuchos::OrdinalTraits<size_t>::zero();
798  const size_t L1 = Teuchos::OrdinalTraits<size_t>::one();
799  const global_size_t GST0 = Teuchos::OrdinalTraits<global_size_t>::zero();
800  const global_size_t GST1 = Teuchos::OrdinalTraits<global_size_t>::one();
801  const global_size_t GSTI = Teuchos::OrdinalTraits<global_size_t>::invalid();
802 
803  std::string errPrefix;
804  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,numLocal,indexBase,platform): ";
805 
806  // get a internodal communicator from the Platform
807  const int myImageID = comm->getRank();
808 
809  global_size_t global_sum;
810  { // begin scoping block
811  // for communicating failures
812  int localChecks[2], globalChecks[2];
813  /* compute the global size
814  we are computing the number of global elements because exactly ONE of the following is true:
815  - the user didn't specify it, and we need it
816  - the user did specify it, but we need to
817  + validate it against the sum of the local sizes, and
818  + ensure that it is the same on all nodes
819  */
820  Teuchos::reduceAll<int,global_size_t>(*comm,Teuchos::REDUCE_SUM,
821  Teuchos::as<global_size_t>(numLocalElements),outArg(global_sum));
822  /* there are three errors we should be detecting:
823  - numGlobalElements != invalid() and it is incorrect/invalid
824  - numLocalElements invalid (<0)
825  */
826  localChecks[0] = -1;
827  localChecks[1] = 0;
828  if (numLocalElements < L1 && numLocalElements != L0) {
829  // invalid
830  localChecks[0] = myImageID;
831  localChecks[1] = 1;
832  }
833  else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
834  // invalid
835  localChecks[0] = myImageID;
836  localChecks[1] = 2;
837  }
838  else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
839  // incorrect
840  localChecks[0] = myImageID;
841  localChecks[1] = 3;
842  }
843  // now check that indexBase is equivalent across images
844  GlobalOrdinal rootIB = indexBase;
845  Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB); // broadcast one ordinal from node 0
846  if (indexBase != rootIB) {
847  localChecks[0] = myImageID;
848  localChecks[1] = 4;
849  }
850  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass
851  // this will be -1 if all procs passed
852  Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
853  if (globalChecks[0] != -1) {
854  if (globalChecks[1] == 1) {
855  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
856  errPrefix << "numLocal is not valid on at least one node (possibly node "
857  << globalChecks[0] << ").");
858  }
859  else if (globalChecks[1] == 2) {
860  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
861  errPrefix << "numGlobal is not valid on at least one node (possibly node "
862  << globalChecks[0] << ").");
863  }
864  else if (globalChecks[1] == 3) {
865  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
866  errPrefix << "numGlobal doesn't match sum of numLocal (== "
867  << global_sum << ") on at least one node (possibly node "
868  << globalChecks[0] << ").");
869  }
870  else if (globalChecks[1] == 4) {
871  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
872  errPrefix << "indexBase is not the same on all nodes (examine node "
873  << globalChecks[0] << ").");
874  }
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 
884  // set numGlobalElements
885  if (numGlobalElements == GSTI) {
886  numGlobalElements = global_sum;}
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  {
897  if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
898  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(-1, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
899  } else {
900  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(numGlobalElements, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
901  }
902  }
903 
905 
907 
908 
910  global_size_t getGlobalNumElements() const { XPETRA_MONITOR("EpetraMapT::getGlobalNumElements"); return map_->NumGlobalElements64(); }
911 
913  size_t getNodeNumElements() const { XPETRA_MONITOR("EpetraMapT::getNodeNumElements"); return map_->NumMyElements(); }
914 
916  GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("EpetraMapT::getIndexBase"); return (GlobalOrdinal) map_->IndexBase64(); }
917 
919  LocalOrdinal getMinLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinLocalIndex"); return map_->MinLID(); }
920 
922  LocalOrdinal getMaxLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxLocalIndex"); return map_->MaxLID(); }
923 
925  GlobalOrdinal getMinGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinGlobalIndex"); return (GlobalOrdinal) map_->MinMyGID64(); }
926 
928  GlobalOrdinal getMaxGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxGlobalIndex"); return (GlobalOrdinal) map_->MaxMyGID64(); }
929 
931  GlobalOrdinal getMinAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinAllGlobalIndex"); return (GlobalOrdinal) map_->MinAllGID64(); }
932 
934  GlobalOrdinal getMaxAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxAllGlobalIndex"); return (GlobalOrdinal) map_->MaxAllGID64(); }
935 
937  LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::getLocalElement"); return map_->LID(globalIndex); }
938 
940  LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const { XPETRA_MONITOR("EpetraMapT::getRemoteIndexList"); return toXpetra(map_->RemoteIDList(GIDList.size(), GIDList.getRawPtr(), nodeIDList.getRawPtr(), LIDList.getRawPtr())); }
941 
943  LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const { XPETRA_MONITOR("EpetraMapT::getRemoteIndexList"); return toXpetra(map_->RemoteIDList(GIDList.size(), GIDList.getRawPtr(), nodeIDList.getRawPtr(), 0)); }
944 
946  Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const { XPETRA_MONITOR("EpetraMapT::getNodeElementList"); return ArrayView< const long long >(map_->MyGlobalElements64(), map_->NumMyElements()); }
948 
950 
951 
953  bool isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeLocalElement"); return map_->MyLID(localIndex); }
954 
956  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeGlobalElement"); return map_->MyGID(globalIndex); }
957 
959  bool isContiguous() const { XPETRA_MONITOR("EpetraMapT::isContiguous"); return map_->LinearMap(); }
960 
962  bool isDistributed() const { XPETRA_MONITOR("EpetraMapT::isDistributed"); return map_->DistributedGlobal(); }
963 
965  bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isCompatible"); return map_->PointSameAs(toEpetra<GlobalOrdinal,Node>(map)); }
966 
968  bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isSameAs"); return map_->SameAs(toEpetra<GlobalOrdinal,Node>(map)); }
969 
971 
973 
974 
976  Teuchos::RCP< const Teuchos::Comm< int > > getComm() const { XPETRA_MONITOR("EpetraMapT::getComm"); return toXpetra(map_->Comm()); }
977 
978 
980 
982 
983 
985  std::string description() const {
986  XPETRA_MONITOR("EpetraMapT::description");
987 
988  // This implementation come from Tpetra_Map_def.hpp (without modification)
989  std::ostringstream oss;
990  oss << Teuchos::Describable::description();
991  oss << "{getGlobalNumElements() = " << getGlobalNumElements()
992  << ", getNodeNumElements() = " << getNodeNumElements()
993  << ", isContiguous() = " << isContiguous()
994  << ", isDistributed() = " << isDistributed()
995  << "}";
996  return oss.str();
997  }
998 
1000  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const {
1001  XPETRA_MONITOR("EpetraMapT::describe");
1002 
1003  const Teuchos::RCP<const Teuchos::Comm<int> > comm_ = getComm();
1004 
1005  // This implementation come from Tpetra_Map_def.hpp (without modification)
1006  using std::endl;
1007  using std::setw;
1008  using Teuchos::VERB_DEFAULT;
1009  using Teuchos::VERB_NONE;
1010  using Teuchos::VERB_LOW;
1011  using Teuchos::VERB_MEDIUM;
1012  using Teuchos::VERB_HIGH;
1013  using Teuchos::VERB_EXTREME;
1014 
1015  const size_t nME = getNodeNumElements();
1016  Teuchos::ArrayView<const GlobalOrdinal> myEntries = getNodeElementList();
1017  int myImageID = comm_->getRank();
1018  int numImages = comm_->getSize();
1019 
1020  Teuchos::EVerbosityLevel vl = verbLevel;
1021  if (vl == VERB_DEFAULT) vl = VERB_LOW;
1022 
1023  size_t width = 1;
1024  for (size_t dec=10; dec<getGlobalNumElements(); dec *= 10) {
1025  ++width;
1026  }
1027  width = ::std::max<size_t>(width, (size_t) 12) + 2; // casting to size_t to avoid ambiguity error when compiling Sacado.
1028 
1029  Teuchos::OSTab tab(out);
1030 
1031  if (vl == VERB_NONE) {
1032  // do nothing
1033  }
1034  else if (vl == VERB_LOW) {
1035  out << this->description() << endl;
1036  }
1037  else { // MEDIUM, HIGH or EXTREME
1038  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1039  if (myImageID == imageCtr) {
1040  if (myImageID == 0) { // this is the root node (only output this info once)
1041  out << endl
1042  << "Number of Global Entries = " << getGlobalNumElements() << endl
1043  << "Maximum of all GIDs = " << getMaxAllGlobalIndex() << endl
1044  << "Minimum of all GIDs = " << getMinAllGlobalIndex() << endl
1045  << "Index Base = " << getIndexBase() << endl;
1046  }
1047  out << endl;
1048  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1049  out << "Number of Local Elements = " << nME << endl
1050  << "Maximum of my GIDs = " << getMaxGlobalIndex() << endl
1051  << "Minimum of my GIDs = " << getMinGlobalIndex() << endl;
1052  out << endl;
1053  }
1054  if (vl == VERB_EXTREME) {
1055  out << std::setw(width) << "Node ID"
1056  << std::setw(width) << "Local Index"
1057  << std::setw(width) << "Global Index"
1058  << endl;
1059  for (size_t i=0; i < nME; i++) {
1060  out << std::setw(width) << myImageID
1061  << std::setw(width) << i
1062  << std::setw(width) << myEntries[i]
1063  << endl;
1064  }
1065  out << std::flush;
1066  }
1067  }
1068  // Do a few global ops to give I/O a chance to complete
1069  comm_->barrier();
1070  comm_->barrier();
1071  comm_->barrier();
1072  }
1073  }
1074  }
1075 
1077 
1079 
1080 
1082  RCP<const Map<int,GlobalOrdinal,Node> > removeEmptyProcesses() const {
1083  const Epetra_BlockMap * NewMap = map_->RemoveEmptyProcesses();
1084  if (!NewMap) {
1085  return Teuchos::null;
1086  } else {
1087  const RCP< const Map<int, GlobalOrdinal, Node> > NewMapX = toXpetra<GlobalOrdinal, Node>(*NewMap);
1088  delete NewMap; // NOTE: toXpetra *copys* the epetra map rather than wrapping it, so we have to delete NewMap to avoid a memory leak.
1089  return NewMapX;
1090  }
1091  }
1092 
1094  RCP<const Map<int,GlobalOrdinal,Node> > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &/* newComm */) const {
1095  throw std::runtime_error("Xpetra::EpetraMapT::replaceCommWithSubset has not yet been implemented.");
1096  // return Teuchos::null; // unreachable
1097  }
1098 
1100 
1103  XPETRA_MONITOR("EpetraMapT::getGlobalElement");
1104 
1105  GlobalOrdinal gid = (GlobalOrdinal) map_->GID64(localIndex);
1106  if (gid == map_->IndexBase64()-1) return (-1);
1107  else return (gid);
1108  }
1109 
1111 
1112 
1114  virtual ~EpetraMapT() {}
1115 
1117  EpetraMapT(const Teuchos::RCP<const Epetra_BlockMap> &map)
1118  : map_(map) {
1119  TEUCHOS_TEST_FOR_EXCEPTION(!map->GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraMapT: GlobalOrdinal mismatch.");
1120  }
1121 
1124 
1126  //const RCP< const Epetra_Map > & getEpetra_Map() const { return map_; }
1127  const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
1128  const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
1129 
1130 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1131 #ifdef HAVE_XPETRA_TPETRA
1132  using local_map_type = typename Map<LocalOrdinal, GlobalOrdinal, Node>::local_map_type;
1134  local_map_type getLocalMap () const {
1135  throw std::runtime_error("Xpetra::EpetraMap::getLocalMap is not implemented.");
1136  }
1137 
1138  private:
1139  mutable local_map_type localMap_;
1140 #else
1141 #ifdef __GNUC__
1142 #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."
1143 #endif
1144 #endif
1145 #endif
1146 
1148 
1149  protected:
1150 
1151  RCP<const Epetra_BlockMap> map_;
1152 }; // EpetraMapT class
1153 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1154 
1155 } // Xpetra namespace
1156 
1157 #endif // XPETRA_EPETRAMAP_HPP
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
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this process.
GlobalOrdinal getIndexBase() const
The index base for this Map.
size_t getNodeNumElements() const
The number of elements belonging to the calling process.
size_t getNodeNumElements() const
The number of elements belonging to the calling process.
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.
size_t getNodeNumElements() const
The number of elements belonging to the calling 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.
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
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.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
const Epetra_BlockMap & getEpetra_BlockMap() const
Get the underlying Epetra map.
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.
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
Get the underlying Epetra map.
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.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to 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.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
UnderlyingLib lib() const
Get the library used by this object (Epetra or Epetra?)
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
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.
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.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this process.
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.
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.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &) const
True if and only if map is identical to this Map.
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.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
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.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
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.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this process.
const Epetra_Map & getEpetra_Map() const
RCP< const Epetra_BlockMap > map_
#define IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG(sourceCode)
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
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
Get the underlying Epetra map.
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 Epetra_BlockMap > map_
size_t global_size_t
Global size_t object.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
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_size_t getGlobalNumElements() const
The number of elements in this Map.
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?)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
const Epetra_Map & getEpetra_Map() const
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
virtual ~EpetraMapT()
Destructor.
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.
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
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.
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.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &, const Teuchos::ArrayView< int > &) const
Return the process ranks for the given global indices.
std::string description() const
Return a simple one-line description of this object.