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 /* this file is automatically generated - do not edit (see script/epetra.py) */
50 
52 
53 #include "Xpetra_Map.hpp"
54 
55 #include <Epetra_Map.h>
56 #include <Epetra_BlockMap.h>
57 
58 #include "Xpetra_Utils.hpp"
59 #include "Xpetra_EpetraUtils.hpp"
61 
62 #include "Xpetra_ConfigDefs.hpp"
63 
64 namespace Xpetra {
65 
66  // TODO: move that elsewhere
67  template<class GlobalOrdinal, class Node>
68  const Epetra_Map & toEpetra(const Map<int,GlobalOrdinal, Node> &);
69  template<class GlobalOrdinal, class Node>
70  const Epetra_Map & toEpetra(const RCP< const Map<int, GlobalOrdinal, Node> > &);
71  //template<class GlobalOrdinal>
72  //const RCP< const Map<int, GlobalOrdinal> > toXpetra(const RCP< const Epetra_Map > &);
73  template<class GlobalOrdinal, class Node>
74  const RCP< const Map<int, GlobalOrdinal, Node> > toXpetra(const Epetra_BlockMap &);
75  //
76 
77  // stub implementation for EpetraMapT
78  template<class GlobalOrdinal, class Node>
79  class EpetraMapT
80  : public virtual Map<int, GlobalOrdinal, Node>
81  {
82  typedef int LocalOrdinal;
83 
84  public:
85  typedef int local_ordinal_type;
86  typedef GlobalOrdinal global_ordinal_type;
87  typedef Node node_type;
88 
90  // Workaround function for a deferred visual studio bug
91  // http://connect.microsoft.com/VisualStudio/feedback/details/719847/erroneous-error-c2783-could-not-deduce-template-argument
92  // Use this function for default arguments rather than calling
93  // what is the return value below. Also helps in reducing
94  // duplication in various constructors.
95  return KokkosClassic::Details::getNode<Node>(); // TODO fix this
96  }
97 
99 
100 
102  EpetraMapT(global_size_t numGlobalElements,
103  GlobalOrdinal indexBase,
104  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
106  const Teuchos::RCP< Node > &node = defaultArgNode()) {
108  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
109  }
110 
112  EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode()) {
114  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
115  }
116 
118  EpetraMapT(global_size_t numGlobalElements,
120  GlobalOrdinal indexBase,
121  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
122  const Teuchos::RCP< Node > &node = defaultArgNode()) {
124  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
125  }
126 
128 
130 
131 
133  global_size_t getGlobalNumElements() const { return 0; }
134 
136  size_t getNodeNumElements() const { return 0; }
137 
139  GlobalOrdinal getIndexBase() const { return 0; }
140 
142  LocalOrdinal getMinLocalIndex() const { return 0; }
143 
145  LocalOrdinal getMaxLocalIndex() const { return 0; }
146 
148  GlobalOrdinal getMinGlobalIndex() const { return 0; }
149 
151  GlobalOrdinal getMaxGlobalIndex() const { return 0; }
152 
154  GlobalOrdinal getMinAllGlobalIndex() const { return 0; }
155 
157  GlobalOrdinal getMaxAllGlobalIndex() const { return 0; }
158 
160  LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { return 0; }
161 
164 
167 
169  //Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const;
170 
173 
175 
176 
178  bool isNodeLocalElement(LocalOrdinal localIndex) const { return false; }
179 
181  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { return false; }
182 
184  bool isContiguous() const { return false; }
185 
187  bool isDistributed() const { return false; }
188 
190  bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { return false; }
191 
193  bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { return false; }
194 
196 
198 
199 
201  Teuchos::RCP< const Teuchos::Comm< int > > getComm() const { return Teuchos::null; }
202 
205  XPETRA_MONITOR("EpetraMapT<GlobalOrdinal>::getNode");
206  return KokkosClassic::Details::getNode<Node>(); // TODO fix this (just returns Teuchos::null)
207  }
208 
210 
212 
213 
215  std::string description() const { return std::string(""); }
216 
219 
221 
223 
224 
227 
229  RCP<const Map<int,GlobalOrdinal,Node> > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const { return Teuchos::null; }
230 
232 
234  GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const { return -1; }
235 
237 
238 
240  virtual ~EpetraMapT() {}
241 
244  : map_(map) {
246  "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
247  }
248 
250  UnderlyingLib lib() const { return Xpetra::UseEpetra; }
251 
253  //const RCP< const Epetra_Map > & getEpetra_Map() const { return map_; }
254  const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
255  const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
256 
258 
259  protected:
260 
262  }; // EpetraMapT class
263 
264  // specialization on GO=int and Node=Serial
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:
275  typedef LocalOrdinal local_ordinal_type;
276  typedef GlobalOrdinal global_ordinal_type;
277  typedef Node node_type;
278 
280  // Workaround function for a deferred visual studio bug
281  // http://connect.microsoft.com/VisualStudio/feedback/details/719847/erroneous-error-c2783-could-not-deduce-template-argument
282  // Use this function for default arguments rather than calling
283  // what is the return value below. Also helps in reducing
284  // duplication in various constructors.
285  return KokkosClassic::Details::getNode<Node>();
286  }
287 
289 
290 
292  EpetraMapT(global_size_t numGlobalElements,
293  GlobalOrdinal indexBase,
294  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
296  const Teuchos::RCP< Node > &node = defaultArgNode()) {
297  // This test come from Tpetra (Epetra doesn't check if numGlobalElements,indexBase are equivalent across images).
298  // 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.
299  std::string errPrefix;
300  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,indexBase,comm,lOrG): ";
301 
302  if (lg == GloballyDistributed) {
303  const int myImageID = comm->getRank();
304 
305  // check that numGlobalElements,indexBase is equivalent across images
306  global_size_t rootNGE = numGlobalElements;
307  GlobalOrdinal rootIB = indexBase;
308  Teuchos::broadcast<int,global_size_t>(*comm,0,&rootNGE);
309  Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB);
310  int localChecks[2], globalChecks[2];
311  localChecks[0] = -1; // fail or pass
312  localChecks[1] = 0; // fail reason
313  if (numGlobalElements != rootNGE) {
314  localChecks[0] = myImageID;
315  localChecks[1] = 1;
316  }
317  else if (indexBase != rootIB) {
318  localChecks[0] = myImageID;
319  localChecks[1] = 2;
320  }
321  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass, as well as the reason
322  // these will be -1 and 0 if all procs passed
323  Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
324  if (globalChecks[0] != -1) {
325  if (globalChecks[1] == 1) {
326  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
327  errPrefix << "numGlobal must be the same on all nodes (examine node " << globalChecks[0] << ").");
328  }
329  else if (globalChecks[1] == 2) {
330  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
331  errPrefix << "indexBase must be the same on all nodes (examine node " << globalChecks[0] << ").");
332  }
333  else {
334  // logic error on our part
335  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
336  errPrefix << "logic error. Please contact the Tpetra team.");
337  }
338  }
339  }
340 
341  // Note: validity of numGlobalElements checked by Epetra.
342 
343  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), 1, indexBase, *toEpetra(comm))))));
344  }
345 
347  EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode()) {
348  // This test come from Tpetra
349  using Teuchos::outArg;
350 
351  const size_t L0 = Teuchos::OrdinalTraits<size_t>::zero();
352  const size_t L1 = Teuchos::OrdinalTraits<size_t>::one();
356 
357  std::string errPrefix;
358  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,numLocal,indexBase,platform): ";
359 
360  // get a internodal communicator from the Platform
361  const int myImageID = comm->getRank();
362 
363  global_size_t global_sum;
364  { // begin scoping block
365  // for communicating failures
366  int localChecks[2], globalChecks[2];
367  /* compute the global size
368  we are computing the number of global elements because exactly ONE of the following is true:
369  - the user didn't specify it, and we need it
370  - the user did specify it, but we need to
371  + validate it against the sum of the local sizes, and
372  + ensure that it is the same on all nodes
373  */
374  Teuchos::reduceAll<int,global_size_t>(*comm,Teuchos::REDUCE_SUM,
375  Teuchos::as<global_size_t>(numLocalElements),outArg(global_sum));
376  /* there are three errors we should be detecting:
377  - numGlobalElements != invalid() and it is incorrect/invalid
378  - numLocalElements invalid (<0)
379  */
380  localChecks[0] = -1;
381  localChecks[1] = 0;
382  if (numLocalElements < L1 && numLocalElements != L0) {
383  // invalid
384  localChecks[0] = myImageID;
385  localChecks[1] = 1;
386  }
387  else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
388  // invalid
389  localChecks[0] = myImageID;
390  localChecks[1] = 2;
391  }
392  else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
393  // incorrect
394  localChecks[0] = myImageID;
395  localChecks[1] = 3;
396  }
397  // now check that indexBase is equivalent across images
398  GlobalOrdinal rootIB = indexBase;
399  Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB); // broadcast one ordinal from node 0
400  if (indexBase != rootIB) {
401  localChecks[0] = myImageID;
402  localChecks[1] = 4;
403  }
404  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass
405  // this will be -1 if all procs passed
406  Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
407  if (globalChecks[0] != -1) {
408  if (globalChecks[1] == 1) {
409  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
410  errPrefix << "numLocal is not valid on at least one node (possibly node "
411  << globalChecks[0] << ").");
412  }
413  else if (globalChecks[1] == 2) {
414  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
415  errPrefix << "numGlobal is not valid on at least one node (possibly node "
416  << globalChecks[0] << ").");
417  }
418  else if (globalChecks[1] == 3) {
419  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
420  errPrefix << "numGlobal doesn't match sum of numLocal (== "
421  << global_sum << ") on at least one node (possibly node "
422  << globalChecks[0] << ").");
423  }
424  else if (globalChecks[1] == 4) {
425  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
426  errPrefix << "indexBase is not the same on all nodes (examine node "
427  << globalChecks[0] << ").");
428  }
429  else {
430  // logic error on my part
431  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
432  errPrefix << "logic error. Please contact the Tpetra team.");
433  }
434  }
435 
436  }
437 
438  // set numGlobalElements
439  if (numGlobalElements == GSTI) {
440  numGlobalElements = global_sum;}
441 
442  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), numLocalElements, 1, indexBase, *toEpetra(comm))))));
443  }
444 
446  EpetraMapT(global_size_t numGlobalElements,
448  GlobalOrdinal indexBase,
449  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
450  const Teuchos::RCP< Node > &node = defaultArgNode()) {
451  if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
452  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(-1, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
453  } else {
454  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(numGlobalElements, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
455  }
456  }
457 
459 
461 
462 
464  global_size_t getGlobalNumElements() const { XPETRA_MONITOR("EpetraMapT::getGlobalNumElements"); return map_->NumGlobalElements64(); }
465 
467  size_t getNodeNumElements() const { XPETRA_MONITOR("EpetraMapT::getNodeNumElements"); return map_->NumMyElements(); }
468 
470  GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("EpetraMapT::getIndexBase"); return (GlobalOrdinal) map_->IndexBase64(); }
471 
473  LocalOrdinal getMinLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinLocalIndex"); return map_->MinLID(); }
474 
476  LocalOrdinal getMaxLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxLocalIndex"); return map_->MaxLID(); }
477 
479  GlobalOrdinal getMinGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinGlobalIndex"); return (GlobalOrdinal) map_->MinMyGID64(); }
480 
482  GlobalOrdinal getMaxGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxGlobalIndex"); return (GlobalOrdinal) map_->MaxMyGID64(); }
483 
485  GlobalOrdinal getMinAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinAllGlobalIndex"); return (GlobalOrdinal) map_->MinAllGID64(); }
486 
488  GlobalOrdinal getMaxAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxAllGlobalIndex"); return (GlobalOrdinal) map_->MaxAllGID64(); }
489 
491  LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::getLocalElement"); return map_->LID(globalIndex); }
492 
494  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())); }
495 
497  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)); }
498 
500  Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const { XPETRA_MONITOR("EpetraMapT::getNodeElementList"); return ArrayView< const int >(map_->MyGlobalElements(), map_->NumMyElements()); }
502 
504 
505 
507  bool isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeLocalElement"); return map_->MyLID(localIndex); }
508 
510  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeGlobalElement"); return map_->MyGID(globalIndex); }
511 
513  bool isContiguous() const { XPETRA_MONITOR("EpetraMapT::isContiguous"); return map_->LinearMap(); }
514 
516  bool isDistributed() const { XPETRA_MONITOR("EpetraMapT::isDistributed"); return map_->DistributedGlobal(); }
517 
519  bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isCompatible"); return map_->PointSameAs(toEpetra<GlobalOrdinal,Node>(map)); }
520 
522  bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isSameAs"); return map_->SameAs(toEpetra<GlobalOrdinal,Node>(map)); }
523 
525 
527 
528 
530  Teuchos::RCP< const Teuchos::Comm< int > > getComm() const { XPETRA_MONITOR("EpetraMapT::getComm"); return toXpetra(map_->Comm()); }
531 
534  XPETRA_MONITOR("EpetraMapT<GlobalOrdinal>::getNode");
535  return KokkosClassic::Details::getNode<Node>(); // TODO fix this
536  }
537 
539 
541 
542 
544  std::string description() const {
545  XPETRA_MONITOR("EpetraMapT::description");
546 
547  // This implementation come from Tpetra_Map_def.hpp (without modification)
548  std::ostringstream oss;
550  oss << "{getGlobalNumElements() = " << getGlobalNumElements()
551  << ", getNodeNumElements() = " << getNodeNumElements()
552  << ", isContiguous() = " << isContiguous()
553  << ", isDistributed() = " << isDistributed()
554  << "}";
555  return oss.str();
556  }
557 
560  XPETRA_MONITOR("EpetraMapT::describe");
561 
563 
564  // This implementation come from Tpetra_Map_def.hpp (without modification)
565  using std::endl;
566  using std::setw;
567  using Teuchos::VERB_DEFAULT;
568  using Teuchos::VERB_NONE;
569  using Teuchos::VERB_LOW;
570  using Teuchos::VERB_MEDIUM;
571  using Teuchos::VERB_HIGH;
572  using Teuchos::VERB_EXTREME;
573 
574  const size_t nME = getNodeNumElements();
576  int myImageID = comm_->getRank();
577  int numImages = comm_->getSize();
578 
579  Teuchos::EVerbosityLevel vl = verbLevel;
580  if (vl == VERB_DEFAULT) vl = VERB_LOW;
581 
582  size_t width = 1;
583  for (size_t dec=10; dec<getGlobalNumElements(); dec *= 10) {
584  ++width;
585  }
586  width = ::std::max<size_t>(width, (size_t) 12) + 2; // casting to size_t to avoid ambiguity error when compiling Sacado.
587 
588  Teuchos::OSTab tab(out);
589 
590  if (vl == VERB_NONE) {
591  // do nothing
592  }
593  else if (vl == VERB_LOW) {
594  out << this->description() << endl;
595  }
596  else { // MEDIUM, HIGH or EXTREME
597  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
598  if (myImageID == imageCtr) {
599  if (myImageID == 0) { // this is the root node (only output this info once)
600  out << endl
601  << "Number of Global Entries = " << getGlobalNumElements() << endl
602  << "Maximum of all GIDs = " << getMaxAllGlobalIndex() << endl
603  << "Minimum of all GIDs = " << getMinAllGlobalIndex() << endl
604  << "Index Base = " << getIndexBase() << endl;
605  }
606  out << endl;
607  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
608  out << "Number of Local Elements = " << nME << endl
609  << "Maximum of my GIDs = " << getMaxGlobalIndex() << endl
610  << "Minimum of my GIDs = " << getMinGlobalIndex() << endl;
611  out << endl;
612  }
613  if (vl == VERB_EXTREME) {
614  out << std::setw(width) << "Node ID"
615  << std::setw(width) << "Local Index"
616  << std::setw(width) << "Global Index"
617  << endl;
618  for (size_t i=0; i < nME; i++) {
619  out << std::setw(width) << myImageID
620  << std::setw(width) << i
621  << std::setw(width) << myEntries[i]
622  << endl;
623  }
624  out << std::flush;
625  }
626  }
627  // Do a few global ops to give I/O a chance to complete
628  comm_->barrier();
629  comm_->barrier();
630  comm_->barrier();
631  }
632  }
633  }
634 
636 
638 
639 
642  const Epetra_BlockMap * NewMap = map_->RemoveEmptyProcesses();
643  if (!NewMap) {
644  return Teuchos::null;
645  } else {
646  const RCP< const Map<int, GlobalOrdinal, Node> > NewMapX = toXpetra<GlobalOrdinal, Node>(*NewMap);
647  delete NewMap; // NOTE: toXpetra *copys* the epetra map rather than wrapping it, so we have to delete NewMap to avoid a memory leak.
648  return NewMapX;
649  }
650  }
651 
654  throw std::runtime_error("Xpetra::EpetraMapT::replaceCommWithSubset has not yet been implemented.");
655  return Teuchos::null;
656  }
657 
659 
661  GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const {
662  XPETRA_MONITOR("EpetraMapT::getGlobalElement");
663 
664  GlobalOrdinal gid = (GlobalOrdinal) map_->GID64(localIndex);
665  if (gid == map_->IndexBase64()-1) return (-1);
666  else return (gid);
667  }
668 
670 
671 
673  virtual ~EpetraMapT() {}
674 
677  : map_(map) {
678  TEUCHOS_TEST_FOR_EXCEPTION(!map->GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraMapT: GlobalOrdinal mismatch.");
679  }
680 
682  UnderlyingLib lib() const { return Xpetra::UseEpetra; }
683 
685  //const RCP< const Epetra_Map > & getEpetra_Map() const { return map_; }
686  const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
687  const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
688 
690 
691  protected:
692 
694 }; // EpetraMapT class
695 #endif // #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
696 
697 // specialization on GO=long long and Node=Serial
698 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
699  template<>
700  class EpetraMapT<long long, EpetraNode>
701  : public virtual Map<int, long long, EpetraNode>
702  {
703  typedef int LocalOrdinal;
704  typedef long long GlobalOrdinal;
705  typedef EpetraNode Node;
706 
707  public:
708  typedef LocalOrdinal local_ordinal_type;
709  typedef GlobalOrdinal global_ordinal_type;
710  typedef Node node_type;
711 
713  // Workaround function for a deferred visual studio bug
714  // http://connect.microsoft.com/VisualStudio/feedback/details/719847/erroneous-error-c2783-could-not-deduce-template-argument
715  // Use this function for default arguments rather than calling
716  // what is the return value below. Also helps in reducing
717  // duplication in various constructors.
718  return KokkosClassic::Details::getNode<Node>();
719  }
720 
722 
723 
725  EpetraMapT(global_size_t numGlobalElements,
726  GlobalOrdinal indexBase,
727  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
729  const Teuchos::RCP< Node > &node = defaultArgNode()) {
730  // This test come from Tpetra (Epetra doesn't check if numGlobalElements,indexBase are equivalent across images).
731  // 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.
732  std::string errPrefix;
733  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,indexBase,comm,lOrG): ";
734 
735  if (lg == GloballyDistributed) {
736  const int myImageID = comm->getRank();
737 
738  // check that numGlobalElements,indexBase is equivalent across images
739  global_size_t rootNGE = numGlobalElements;
740  GlobalOrdinal rootIB = indexBase;
741  Teuchos::broadcast<int,global_size_t>(*comm,0,&rootNGE);
742  Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB);
743  int localChecks[2], globalChecks[2];
744  localChecks[0] = -1; // fail or pass
745  localChecks[1] = 0; // fail reason
746  if (numGlobalElements != rootNGE) {
747  localChecks[0] = myImageID;
748  localChecks[1] = 1;
749  }
750  else if (indexBase != rootIB) {
751  localChecks[0] = myImageID;
752  localChecks[1] = 2;
753  }
754  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass, as well as the reason
755  // these will be -1 and 0 if all procs passed
756  Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
757  if (globalChecks[0] != -1) {
758  if (globalChecks[1] == 1) {
759  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
760  errPrefix << "numGlobal must be the same on all nodes (examine node " << globalChecks[0] << ").");
761  }
762  else if (globalChecks[1] == 2) {
763  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
764  errPrefix << "indexBase must be the same on all nodes (examine node " << globalChecks[0] << ").");
765  }
766  else {
767  // logic error on our part
768  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
769  errPrefix << "logic error. Please contact the Tpetra team.");
770  }
771  }
772  }
773 
774  // Note: validity of numGlobalElements checked by Epetra.
775 
776  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), 1, indexBase, *toEpetra(comm))))));
777  }
778 
780  EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode()) {
781  // This test come from Tpetra
782  using Teuchos::outArg;
783 
784  const size_t L0 = Teuchos::OrdinalTraits<size_t>::zero();
785  const size_t L1 = Teuchos::OrdinalTraits<size_t>::one();
789 
790  std::string errPrefix;
791  errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,numLocal,indexBase,platform): ";
792 
793  // get a internodal communicator from the Platform
794  const int myImageID = comm->getRank();
795 
796  global_size_t global_sum;
797  { // begin scoping block
798  // for communicating failures
799  int localChecks[2], globalChecks[2];
800  /* compute the global size
801  we are computing the number of global elements because exactly ONE of the following is true:
802  - the user didn't specify it, and we need it
803  - the user did specify it, but we need to
804  + validate it against the sum of the local sizes, and
805  + ensure that it is the same on all nodes
806  */
807  Teuchos::reduceAll<int,global_size_t>(*comm,Teuchos::REDUCE_SUM,
808  Teuchos::as<global_size_t>(numLocalElements),outArg(global_sum));
809  /* there are three errors we should be detecting:
810  - numGlobalElements != invalid() and it is incorrect/invalid
811  - numLocalElements invalid (<0)
812  */
813  localChecks[0] = -1;
814  localChecks[1] = 0;
815  if (numLocalElements < L1 && numLocalElements != L0) {
816  // invalid
817  localChecks[0] = myImageID;
818  localChecks[1] = 1;
819  }
820  else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
821  // invalid
822  localChecks[0] = myImageID;
823  localChecks[1] = 2;
824  }
825  else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
826  // incorrect
827  localChecks[0] = myImageID;
828  localChecks[1] = 3;
829  }
830  // now check that indexBase is equivalent across images
831  GlobalOrdinal rootIB = indexBase;
832  Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB); // broadcast one ordinal from node 0
833  if (indexBase != rootIB) {
834  localChecks[0] = myImageID;
835  localChecks[1] = 4;
836  }
837  // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass
838  // this will be -1 if all procs passed
839  Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
840  if (globalChecks[0] != -1) {
841  if (globalChecks[1] == 1) {
842  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
843  errPrefix << "numLocal is not valid on at least one node (possibly node "
844  << globalChecks[0] << ").");
845  }
846  else if (globalChecks[1] == 2) {
847  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
848  errPrefix << "numGlobal is not valid on at least one node (possibly node "
849  << globalChecks[0] << ").");
850  }
851  else if (globalChecks[1] == 3) {
852  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
853  errPrefix << "numGlobal doesn't match sum of numLocal (== "
854  << global_sum << ") on at least one node (possibly node "
855  << globalChecks[0] << ").");
856  }
857  else if (globalChecks[1] == 4) {
858  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
859  errPrefix << "indexBase is not the same on all nodes (examine node "
860  << globalChecks[0] << ").");
861  }
862  else {
863  // logic error on my part
864  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
865  errPrefix << "logic error. Please contact the Tpetra team.");
866  }
867  }
868 
869  }
870 
871  // set numGlobalElements
872  if (numGlobalElements == GSTI) {
873  numGlobalElements = global_sum;}
874 
875  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), numLocalElements, 1, indexBase, *toEpetra(comm))))));
876  }
877 
879  EpetraMapT(global_size_t numGlobalElements,
881  GlobalOrdinal indexBase,
882  const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
883  const Teuchos::RCP< Node > &node = defaultArgNode()) {
884  if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
885  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(-1, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
886  } else {
887  IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(numGlobalElements, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
888  }
889  }
890 
892 
894 
895 
897  global_size_t getGlobalNumElements() const { XPETRA_MONITOR("EpetraMapT::getGlobalNumElements"); return map_->NumGlobalElements64(); }
898 
900  size_t getNodeNumElements() const { XPETRA_MONITOR("EpetraMapT::getNodeNumElements"); return map_->NumMyElements(); }
901 
903  GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("EpetraMapT::getIndexBase"); return (GlobalOrdinal) map_->IndexBase64(); }
904 
906  LocalOrdinal getMinLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinLocalIndex"); return map_->MinLID(); }
907 
909  LocalOrdinal getMaxLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxLocalIndex"); return map_->MaxLID(); }
910 
912  GlobalOrdinal getMinGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinGlobalIndex"); return (GlobalOrdinal) map_->MinMyGID64(); }
913 
915  GlobalOrdinal getMaxGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxGlobalIndex"); return (GlobalOrdinal) map_->MaxMyGID64(); }
916 
918  GlobalOrdinal getMinAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinAllGlobalIndex"); return (GlobalOrdinal) map_->MinAllGID64(); }
919 
921  GlobalOrdinal getMaxAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxAllGlobalIndex"); return (GlobalOrdinal) map_->MaxAllGID64(); }
922 
924  LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::getLocalElement"); return map_->LID(globalIndex); }
925 
927  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())); }
928 
930  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)); }
931 
933  Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const { XPETRA_MONITOR("EpetraMapT::getNodeElementList"); return ArrayView< const long long >(map_->MyGlobalElements64(), map_->NumMyElements()); }
935 
937 
938 
940  bool isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeLocalElement"); return map_->MyLID(localIndex); }
941 
943  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeGlobalElement"); return map_->MyGID(globalIndex); }
944 
946  bool isContiguous() const { XPETRA_MONITOR("EpetraMapT::isContiguous"); return map_->LinearMap(); }
947 
949  bool isDistributed() const { XPETRA_MONITOR("EpetraMapT::isDistributed"); return map_->DistributedGlobal(); }
950 
952  bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isCompatible"); return map_->PointSameAs(toEpetra<GlobalOrdinal,Node>(map)); }
953 
955  bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isSameAs"); return map_->SameAs(toEpetra<GlobalOrdinal,Node>(map)); }
956 
958 
960 
961 
963  Teuchos::RCP< const Teuchos::Comm< int > > getComm() const { XPETRA_MONITOR("EpetraMapT::getComm"); return toXpetra(map_->Comm()); }
964 
967  XPETRA_MONITOR("EpetraMapT<GlobalOrdinal>::getNode");
968  return KokkosClassic::Details::getNode<Node>();
969  }
970 
972 
974 
975 
977  std::string description() const {
978  XPETRA_MONITOR("EpetraMapT::description");
979 
980  // This implementation come from Tpetra_Map_def.hpp (without modification)
981  std::ostringstream oss;
983  oss << "{getGlobalNumElements() = " << getGlobalNumElements()
984  << ", getNodeNumElements() = " << getNodeNumElements()
985  << ", isContiguous() = " << isContiguous()
986  << ", isDistributed() = " << isDistributed()
987  << "}";
988  return oss.str();
989  }
990 
993  XPETRA_MONITOR("EpetraMapT::describe");
994 
996 
997  // This implementation come from Tpetra_Map_def.hpp (without modification)
998  using std::endl;
999  using std::setw;
1000  using Teuchos::VERB_DEFAULT;
1001  using Teuchos::VERB_NONE;
1002  using Teuchos::VERB_LOW;
1003  using Teuchos::VERB_MEDIUM;
1004  using Teuchos::VERB_HIGH;
1005  using Teuchos::VERB_EXTREME;
1006 
1007  const size_t nME = getNodeNumElements();
1009  int myImageID = comm_->getRank();
1010  int numImages = comm_->getSize();
1011 
1012  Teuchos::EVerbosityLevel vl = verbLevel;
1013  if (vl == VERB_DEFAULT) vl = VERB_LOW;
1014 
1015  size_t width = 1;
1016  for (size_t dec=10; dec<getGlobalNumElements(); dec *= 10) {
1017  ++width;
1018  }
1019  width = ::std::max<size_t>(width, (size_t) 12) + 2; // casting to size_t to avoid ambiguity error when compiling Sacado.
1020 
1021  Teuchos::OSTab tab(out);
1022 
1023  if (vl == VERB_NONE) {
1024  // do nothing
1025  }
1026  else if (vl == VERB_LOW) {
1027  out << this->description() << endl;
1028  }
1029  else { // MEDIUM, HIGH or EXTREME
1030  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1031  if (myImageID == imageCtr) {
1032  if (myImageID == 0) { // this is the root node (only output this info once)
1033  out << endl
1034  << "Number of Global Entries = " << getGlobalNumElements() << endl
1035  << "Maximum of all GIDs = " << getMaxAllGlobalIndex() << endl
1036  << "Minimum of all GIDs = " << getMinAllGlobalIndex() << endl
1037  << "Index Base = " << getIndexBase() << endl;
1038  }
1039  out << endl;
1040  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1041  out << "Number of Local Elements = " << nME << endl
1042  << "Maximum of my GIDs = " << getMaxGlobalIndex() << endl
1043  << "Minimum of my GIDs = " << getMinGlobalIndex() << endl;
1044  out << endl;
1045  }
1046  if (vl == VERB_EXTREME) {
1047  out << std::setw(width) << "Node ID"
1048  << std::setw(width) << "Local Index"
1049  << std::setw(width) << "Global Index"
1050  << endl;
1051  for (size_t i=0; i < nME; i++) {
1052  out << std::setw(width) << myImageID
1053  << std::setw(width) << i
1054  << std::setw(width) << myEntries[i]
1055  << endl;
1056  }
1057  out << std::flush;
1058  }
1059  }
1060  // Do a few global ops to give I/O a chance to complete
1061  comm_->barrier();
1062  comm_->barrier();
1063  comm_->barrier();
1064  }
1065  }
1066  }
1067 
1069 
1071 
1072 
1075  const Epetra_BlockMap * NewMap = map_->RemoveEmptyProcesses();
1076  if (!NewMap) {
1077  return Teuchos::null;
1078  } else {
1079  const RCP< const Map<int, GlobalOrdinal, Node> > NewMapX = toXpetra<GlobalOrdinal, Node>(*NewMap);
1080  delete NewMap; // NOTE: toXpetra *copys* the epetra map rather than wrapping it, so we have to delete NewMap to avoid a memory leak.
1081  return NewMapX;
1082  }
1083  }
1084 
1087  throw std::runtime_error("Xpetra::EpetraMapT::replaceCommWithSubset has not yet been implemented.");
1088  return Teuchos::null;
1089  }
1090 
1092 
1094  GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const {
1095  XPETRA_MONITOR("EpetraMapT::getGlobalElement");
1096 
1097  GlobalOrdinal gid = (GlobalOrdinal) map_->GID64(localIndex);
1098  if (gid == map_->IndexBase64()-1) return (-1);
1099  else return (gid);
1100  }
1101 
1103 
1104 
1106  virtual ~EpetraMapT() {}
1107 
1110  : map_(map) {
1111  TEUCHOS_TEST_FOR_EXCEPTION(!map->GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraMapT: GlobalOrdinal mismatch.");
1112  }
1113 
1116 
1118  //const RCP< const Epetra_Map > & getEpetra_Map() const { return map_; }
1119  const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
1120  const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
1121 
1123 
1124  protected:
1125 
1127 }; // EpetraMapT class
1128 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1129 //#endif // HAVE_XPETRA_SERIAL
1130 
1131 } // Xpetra namespace
1132 
1133 #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.
EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode())
Constructor with a user-defined contiguous distribution.
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
EpetraMapT(global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode())
Constructor with user-defined arbitrary (possibly noncontiguous) distribution.
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.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) 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.
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
bool isContiguous() const
True if this Map is distributed contiguously, else false.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
Xpetra namespace
EpetraMapT(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=defaultArgNode())
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, const Teuchos::RCP< Node > &node=defaultArgNode())
Constructor with user-defined arbitrary (possibly noncontiguous) distribution.
const Epetra_BlockMap & getEpetra_BlockMap() const
Get the underlying Epetra map.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
size_type size() const
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.
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.
EpetraMapT(const Teuchos::RCP< const Epetra_BlockMap > &map)
EpetraMapT constructor to wrap a Epetra_Map object.
bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on this process.
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.
Teuchos::RCP< Node > getNode() const
Get this Map&#39;s Node object.
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.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this process.
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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)
virtual std::string description() const
RCP< const Map< int, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map&#39;s communicator with a subset communicator.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
const Epetra_BlockMap & getEpetra_BlockMap() const
Get the underlying Epetra map.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this 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...
Teuchos::RCP< Node > getNode() const
Get this Map&#39;s Node object.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
static Teuchos::RCP< Node > defaultArgNode()
T * getRawPtr() const
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.
RCP< const Epetra_BlockMap > map_
size_t global_size_t
Global size_t object.
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.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
static const EVerbosityLevel verbLevel_default
static Teuchos::RCP< Node > defaultArgNode()
EpetraMapT(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=defaultArgNode())
Constructor with Tpetra-defined contiguous uniform distribution.
Teuchos::RCP< Node > getNode() const
Get this Map&#39;s Node object.
global_size_t getGlobalNumElements() const
The number of elements in this 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...
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?)
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const
Return the process ranks for the given global indices.
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.
EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode())
Constructor with a user-defined contiguous distribution.
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.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
static Teuchos::RCP< Node > defaultArgNode()
#define XPETRA_MONITOR(funcName)
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
RCP< const Map< int, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map&#39;s communicator with a subset communicator.
RCP< const Map< int, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map&#39;s communicator with a subset communicator.
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.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode())
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, const Teuchos::RCP< Node > &node=defaultArgNode())
Constructor with Tpetra-defined contiguous uniform distribution.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
std::string typeName(const T &t)
std::string description() const
Return a simple one-line description of this object.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
EpetraMapT(global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode())
Constructor with user-defined arbitrary (possibly noncontiguous) distribution.