Xpetra Version of the Day
Loading...
Searching...
No Matches
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"
60
61#include "Xpetra_ConfigDefs.hpp"
62
63namespace 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>
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 {
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) {
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,
112 GlobalOrdinal indexBase,
113 const Teuchos::RCP< const Teuchos::Comm< int > > &comm) {
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
125
127 size_t getLocalNumElements() 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
155
158
160 //Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const;
161
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
205
207
209
210
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
230 : map_(map) {
232 "Xpetra::EpetraMap only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
233 }
234
237
239 const RCP< const Epetra_Map > & getEpetra_MapRCP() const { return Teuchos::rcp_static_cast<const Epetra_Map>(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_TPETRA
247 throw std::runtime_error("Xpetra::EpetraMap::getLocalMap is not implemented in "+std::string(__FILE__)+":"+std::to_string(__LINE__));
248 }
249#else
250#ifdef __GNUC__
251#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."
252#endif
253#endif
254
256
257 protected:
258
260 }; // EpetraMapT class
261
262 // specialization on GO=int and EpetraNode
263#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
264 template<>
266 : public virtual Map<int, int, EpetraNode>
267 {
268 typedef int LocalOrdinal;
269 typedef int GlobalOrdinal;
271
272 public:
276
278
279
281 EpetraMapT(global_size_t numGlobalElements,
282 GlobalOrdinal indexBase,
283 const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
285 {
286 // This test come from Tpetra (Epetra doesn't check if numGlobalElements,indexBase are equivalent across images).
287 // 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.
288 std::string errPrefix;
289 errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,indexBase,comm,lOrG): ";
290
291 if (lg == GloballyDistributed) {
292 const int myImageID = comm->getRank();
293
294 // check that numGlobalElements,indexBase is equivalent across images
295 global_size_t rootNGE = numGlobalElements;
296 GlobalOrdinal rootIB = indexBase;
297 Teuchos::broadcast<int,global_size_t>(*comm,0,&rootNGE);
298 Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB);
299 int localChecks[2], globalChecks[2];
300 localChecks[0] = -1; // fail or pass
301 localChecks[1] = 0; // fail reason
302 if (numGlobalElements != rootNGE) {
303 localChecks[0] = myImageID;
304 localChecks[1] = 1;
305 }
306 else if (indexBase != rootIB) {
307 localChecks[0] = myImageID;
308 localChecks[1] = 2;
309 }
310 // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass, as well as the reason
311 // these will be -1 and 0 if all procs passed
312 Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
313 if (globalChecks[0] != -1) {
314 if (globalChecks[1] == 1) {
315 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
316 errPrefix << "numGlobal must be the same on all nodes (examine node " << globalChecks[0] << ").");
317 }
318 else if (globalChecks[1] == 2) {
319 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
320 errPrefix << "indexBase must be the same on all nodes (examine node " << globalChecks[0] << ").");
321 }
322 else {
323 // logic error on our part
324 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
325 errPrefix << "logic error. Please contact the Tpetra team.");
326 }
327 }
328 }
329
330 // Note: validity of numGlobalElements checked by Epetra.
331
332 IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), 1, indexBase, *toEpetra(comm))))));
333 }
334
336 EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
337 {
338 // This test come from Tpetra
339 using Teuchos::outArg;
340
341 const size_t L0 = Teuchos::OrdinalTraits<size_t>::zero();
342 const size_t L1 = Teuchos::OrdinalTraits<size_t>::one();
346
347 std::string errPrefix;
348 errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,numLocal,indexBase,platform): ";
349
350 // get a internodal communicator from the Platform
351 const int myImageID = comm->getRank();
352
353 global_size_t global_sum;
354 { // begin scoping block
355 // for communicating failures
356 int localChecks[2], globalChecks[2];
357 /* compute the global size
358 we are computing the number of global elements because exactly ONE of the following is true:
359 - the user didn't specify it, and we need it
360 - the user did specify it, but we need to
361 + validate it against the sum of the local sizes, and
362 + ensure that it is the same on all nodes
363 */
364 Teuchos::reduceAll<int,global_size_t>(*comm,Teuchos::REDUCE_SUM,
365 Teuchos::as<global_size_t>(numLocalElements),outArg(global_sum));
366 /* there are three errors we should be detecting:
367 - numGlobalElements != invalid() and it is incorrect/invalid
368 - numLocalElements invalid (<0)
369 */
370 localChecks[0] = -1;
371 localChecks[1] = 0;
372 if (numLocalElements < L1 && numLocalElements != L0) {
373 // invalid
374 localChecks[0] = myImageID;
375 localChecks[1] = 1;
376 }
377 else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
378 // invalid
379 localChecks[0] = myImageID;
380 localChecks[1] = 2;
381 }
382 else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
383 // incorrect
384 localChecks[0] = myImageID;
385 localChecks[1] = 3;
386 }
387 // now check that indexBase is equivalent across images
388 GlobalOrdinal rootIB = indexBase;
389 Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB); // broadcast one ordinal from node 0
390 if (indexBase != rootIB) {
391 localChecks[0] = myImageID;
392 localChecks[1] = 4;
393 }
394 // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass
395 // this will be -1 if all procs passed
396 Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
397 if (globalChecks[0] != -1) {
398 if (globalChecks[1] == 1) {
399 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
400 errPrefix << "numLocal is not valid on at least one node (possibly node "
401 << globalChecks[0] << ").");
402 }
403 else if (globalChecks[1] == 2) {
404 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
405 errPrefix << "numGlobal is not valid on at least one node (possibly node "
406 << globalChecks[0] << ").");
407 }
408 else if (globalChecks[1] == 3) {
409 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
410 errPrefix << "numGlobal doesn't match sum of numLocal (== "
411 << global_sum << ") on at least one node (possibly node "
412 << globalChecks[0] << ").");
413 }
414 else if (globalChecks[1] == 4) {
415 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
416 errPrefix << "indexBase is not the same on all nodes (examine node "
417 << globalChecks[0] << ").");
418 }
419 else {
420 // logic error on my part
421 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
422 errPrefix << "logic error. Please contact the Tpetra team.");
423 }
424 }
425
426 }
427
428 // set numGlobalElements
429 if (numGlobalElements == GSTI) {
430 numGlobalElements = global_sum;}
431
432 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))))));
433 }
434
436 EpetraMapT(global_size_t numGlobalElements,
438 GlobalOrdinal indexBase,
439 const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
440 {
441 if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
442 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))))));
443 } else {
444 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))))));
445 }
446 }
447
449
451
452
454 global_size_t getGlobalNumElements() const { XPETRA_MONITOR("EpetraMapT::getGlobalNumElements"); return map_->NumGlobalElements64(); }
455
457 size_t getLocalNumElements() const { XPETRA_MONITOR("EpetraMapT::getLocalNumElements"); return map_->NumMyElements(); }
458
460 GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("EpetraMapT::getIndexBase"); return (GlobalOrdinal) map_->IndexBase64(); }
461
463 LocalOrdinal getMinLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinLocalIndex"); return map_->MinLID(); }
464
466 LocalOrdinal getMaxLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxLocalIndex"); return map_->MaxLID(); }
467
469 GlobalOrdinal getMinGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinGlobalIndex"); return (GlobalOrdinal) map_->MinMyGID64(); }
470
472 GlobalOrdinal getMaxGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxGlobalIndex"); return (GlobalOrdinal) map_->MaxMyGID64(); }
473
475 GlobalOrdinal getMinAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinAllGlobalIndex"); return (GlobalOrdinal) map_->MinAllGID64(); }
476
478 GlobalOrdinal getMaxAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxAllGlobalIndex"); return (GlobalOrdinal) map_->MaxAllGID64(); }
479
481 LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::getLocalElement"); return map_->LID(globalIndex); }
482
483
486 const Teuchos::ArrayView< int > &nodeIDList,
487 const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
488 {
489 XPETRA_MONITOR("EpetraMapT::getRemoteIndexList");
490 return toXpetra(map_->RemoteIDList(static_cast<int>(GIDList.size()), GIDList.getRawPtr(), nodeIDList.getRawPtr(), LIDList.getRawPtr()));
491 }
492
493
496 const Teuchos::ArrayView< int > &nodeIDList) const
497 {
498 XPETRA_MONITOR("EpetraMapT::getRemoteIndexList");
499 return toXpetra(map_->RemoteIDList(static_cast<int>(GIDList.size()), GIDList.getRawPtr(), nodeIDList.getRawPtr(), 0));
500 }
501
502
504 Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const { XPETRA_MONITOR("EpetraMapT::getLocalElementList"); return ArrayView< const int >(map_->MyGlobalElements(), map_->NumMyElements()); }
506
508
509
511 bool isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeLocalElement"); return map_->MyLID(localIndex); }
512
514 bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeGlobalElement"); return map_->MyGID(globalIndex); }
515
517 bool isContiguous() const { XPETRA_MONITOR("EpetraMapT::isContiguous"); return map_->LinearMap(); }
518
520 bool isDistributed() const { XPETRA_MONITOR("EpetraMapT::isDistributed"); return map_->DistributedGlobal(); }
521
523 bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isCompatible"); return map_->PointSameAs(toEpetra<GlobalOrdinal,Node>(map)); }
524
526 bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isSameAs"); return map_->SameAs(toEpetra<GlobalOrdinal,Node>(map)); }
527
529
531
532
535 {
536 XPETRA_MONITOR("EpetraMapT::getComm");
537 return toXpetra(map_->Comm());
538 }
539
540
542
544
545
547 std::string description() const {
548 XPETRA_MONITOR("EpetraMapT::description");
549
550 // This implementation come from Tpetra_Map_def.hpp (without modification)
551 std::ostringstream oss;
553 oss << "{getGlobalNumElements() = " << getGlobalNumElements()
554 << ", getLocalNumElements() = " << getLocalNumElements()
555 << ", isContiguous() = " << isContiguous()
556 << ", isDistributed() = " << isDistributed()
557 << "}";
558 return oss.str();
559 }
560
563 XPETRA_MONITOR("EpetraMapT::describe");
564
566
567 // This implementation come from Tpetra_Map_def.hpp (without modification)
568 using std::endl;
569 using std::setw;
571 using Teuchos::VERB_NONE;
572 using Teuchos::VERB_LOW;
574 using Teuchos::VERB_HIGH;
576
577 const size_t nME = getLocalNumElements();
579 int myImageID = comm_->getRank();
580 int numImages = comm_->getSize();
581
582 Teuchos::EVerbosityLevel vl = verbLevel;
583 if (vl == VERB_DEFAULT) vl = VERB_LOW;
584
585 size_t width = 1;
586 for (size_t dec=10; dec<getGlobalNumElements(); dec *= 10) {
587 ++width;
588 }
589 width = ::std::max<size_t>(width, (size_t) 12) + 2; // casting to size_t to avoid ambiguity error when compiling Sacado.
590
591 Teuchos::OSTab tab(out);
592
593 if (vl == VERB_NONE) {
594 // do nothing
595 }
596 else if (vl == VERB_LOW) {
597 out << this->description() << endl;
598 }
599 else { // MEDIUM, HIGH or EXTREME
600 for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
601 if (myImageID == imageCtr) {
602 if (myImageID == 0) { // this is the root node (only output this info once)
603 out << endl
604 << "Number of Global Entries = " << getGlobalNumElements() << endl
605 << "Maximum of all GIDs = " << getMaxAllGlobalIndex() << endl
606 << "Minimum of all GIDs = " << getMinAllGlobalIndex() << endl
607 << "Index Base = " << getIndexBase() << endl;
608 }
609 out << endl;
610 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
611 out << "Number of Local Elements = " << nME << endl
612 << "Maximum of my GIDs = " << getMaxGlobalIndex() << endl
613 << "Minimum of my GIDs = " << getMinGlobalIndex() << endl;
614 out << endl;
615 }
616 if (vl == VERB_EXTREME) {
617 out << std::setw(width) << "Node ID"
618 << std::setw(width) << "Local Index"
619 << std::setw(width) << "Global Index"
620 << endl;
621 for (size_t i=0; i < nME; i++) {
622 out << std::setw(width) << myImageID
623 << std::setw(width) << i
624 << std::setw(width) << myEntries[i]
625 << endl;
626 }
627 out << std::flush;
628 }
629 }
630 // Do a few global ops to give I/O a chance to complete
631 comm_->barrier();
632 comm_->barrier();
633 comm_->barrier();
634 }
635 }
636 }
637
639
641
642
645 const Epetra_BlockMap * NewMap = map_->RemoveEmptyProcesses();
646 if (!NewMap) {
647 return Teuchos::null;
648 } else {
649 const RCP< const Map<int, GlobalOrdinal, Node> > NewMapX = toXpetra<GlobalOrdinal, Node>(*NewMap);
650 delete NewMap; // NOTE: toXpetra *copys* the epetra map rather than wrapping it, so we have to delete NewMap to avoid a memory leak.
651 return NewMapX;
652 }
653 }
654
657 throw std::runtime_error("Xpetra::EpetraMapT::replaceCommWithSubset has not yet been implemented in "+std::string(__FILE__)+":"+std::to_string(__LINE__));
658 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
659 }
660
662
665 XPETRA_MONITOR("EpetraMapT::getGlobalElement");
666
667 GlobalOrdinal gid = (GlobalOrdinal) map_->GID64(localIndex);
668 if (gid == map_->IndexBase64()-1) return (-1);
669 else return (gid);
670 }
671
673
674
676 virtual ~EpetraMapT() {}
677
680 : map_(map) {
681 TEUCHOS_TEST_FOR_EXCEPTION(!map->GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraMapT: GlobalOrdinal mismatch.");
682 }
683
686
688 const RCP< const Epetra_Map > getEpetra_MapRCP() const { return Teuchos::rcp_static_cast<const Epetra_Map>(map_); }
689 const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
690 const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
691
693
694#ifdef HAVE_XPETRA_TPETRA
698 throw std::runtime_error("Xpetra::EpetraMap::getLocalMap is not implemented in "+std::string(__FILE__)+":"+std::to_string(__LINE__));
699 }
700
701 private:
703#else
704#ifdef __GNUC__
705#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."
706#endif
707#endif
708
709 protected:
710
712}; // EpetraMapT class
713#endif // #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
714
715// specialization on GO=long long and EpetraNode
716#ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
717 template<>
718 class EpetraMapT<long long, EpetraNode>
719 : public virtual Map<int, long long, EpetraNode>
720 {
721 typedef int LocalOrdinal;
722 typedef long long GlobalOrdinal;
724
725 public:
729
731
732
734 EpetraMapT(global_size_t numGlobalElements,
735 GlobalOrdinal indexBase,
736 const Teuchos::RCP< const Teuchos::Comm< int > > &comm,
738 {
739 // This test come from Tpetra (Epetra doesn't check if numGlobalElements,indexBase are equivalent across images).
740 // 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.
741 std::string errPrefix;
742 errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,indexBase,comm,lOrG): ";
743
744 if (lg == GloballyDistributed) {
745 const int myImageID = comm->getRank();
746
747 // check that numGlobalElements,indexBase is equivalent across images
748 global_size_t rootNGE = numGlobalElements;
749 GlobalOrdinal rootIB = indexBase;
750 Teuchos::broadcast<int,global_size_t>(*comm,0,&rootNGE);
751 Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB);
752 int localChecks[2], globalChecks[2];
753 localChecks[0] = -1; // fail or pass
754 localChecks[1] = 0; // fail reason
755 if (numGlobalElements != rootNGE) {
756 localChecks[0] = myImageID;
757 localChecks[1] = 1;
758 }
759 else if (indexBase != rootIB) {
760 localChecks[0] = myImageID;
761 localChecks[1] = 2;
762 }
763 // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass, as well as the reason
764 // these will be -1 and 0 if all procs passed
765 Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
766 if (globalChecks[0] != -1) {
767 if (globalChecks[1] == 1) {
768 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
769 errPrefix << "numGlobal must be the same on all nodes (examine node " << globalChecks[0] << ").");
770 }
771 else if (globalChecks[1] == 2) {
772 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
773 errPrefix << "indexBase must be the same on all nodes (examine node " << globalChecks[0] << ").");
774 }
775 else {
776 // logic error on our part
777 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
778 errPrefix << "logic error. Please contact the Tpetra team.");
779 }
780 }
781 }
782
783 // Note: validity of numGlobalElements checked by Epetra.
784
785 IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), 1, indexBase, *toEpetra(comm))))));
786 }
787
789 EpetraMapT(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm) {
790 // This test come from Tpetra
791 using Teuchos::outArg;
792
793 const size_t L0 = Teuchos::OrdinalTraits<size_t>::zero();
794 const size_t L1 = Teuchos::OrdinalTraits<size_t>::one();
798
799 std::string errPrefix;
800 errPrefix = Teuchos::typeName(*this) + "::constructor(numGlobal,numLocal,indexBase,platform): ";
801
802 // get a internodal communicator from the Platform
803 const int myImageID = comm->getRank();
804
805 global_size_t global_sum;
806 { // begin scoping block
807 // for communicating failures
808 int localChecks[2], globalChecks[2];
809 /* compute the global size
810 we are computing the number of global elements because exactly ONE of the following is true:
811 - the user didn't specify it, and we need it
812 - the user did specify it, but we need to
813 + validate it against the sum of the local sizes, and
814 + ensure that it is the same on all nodes
815 */
816 Teuchos::reduceAll<int,global_size_t>(*comm,Teuchos::REDUCE_SUM,
817 Teuchos::as<global_size_t>(numLocalElements),outArg(global_sum));
818 /* there are three errors we should be detecting:
819 - numGlobalElements != invalid() and it is incorrect/invalid
820 - numLocalElements invalid (<0)
821 */
822 localChecks[0] = -1;
823 localChecks[1] = 0;
824 if (numLocalElements < L1 && numLocalElements != L0) {
825 // invalid
826 localChecks[0] = myImageID;
827 localChecks[1] = 1;
828 }
829 else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
830 // invalid
831 localChecks[0] = myImageID;
832 localChecks[1] = 2;
833 }
834 else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
835 // incorrect
836 localChecks[0] = myImageID;
837 localChecks[1] = 3;
838 }
839 // now check that indexBase is equivalent across images
840 GlobalOrdinal rootIB = indexBase;
841 Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB); // broadcast one ordinal from node 0
842 if (indexBase != rootIB) {
843 localChecks[0] = myImageID;
844 localChecks[1] = 4;
845 }
846 // REDUCE_MAX will give us the image ID of the highest rank proc that DID NOT pass
847 // this will be -1 if all procs passed
848 Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
849 if (globalChecks[0] != -1) {
850 if (globalChecks[1] == 1) {
851 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
852 errPrefix << "numLocal is not valid on at least one node (possibly node "
853 << globalChecks[0] << ").");
854 }
855 else if (globalChecks[1] == 2) {
856 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
857 errPrefix << "numGlobal is not valid on at least one node (possibly node "
858 << globalChecks[0] << ").");
859 }
860 else if (globalChecks[1] == 3) {
861 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
862 errPrefix << "numGlobal doesn't match sum of numLocal (== "
863 << global_sum << ") on at least one node (possibly node "
864 << globalChecks[0] << ").");
865 }
866 else if (globalChecks[1] == 4) {
867 TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
868 errPrefix << "indexBase is not the same on all nodes (examine node "
869 << globalChecks[0] << ").");
870 }
871 else {
872 // logic error on my part
873 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
874 errPrefix << "logic error. Please contact the Tpetra team.");
875 }
876 }
877
878 }
879
880 // set numGlobalElements
881 if (numGlobalElements == GSTI) {
882 numGlobalElements = global_sum;}
883
884 IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(static_cast<GlobalOrdinal>(numGlobalElements), numLocalElements, 1, indexBase, *toEpetra(comm))))));
885 }
886
888 EpetraMapT(global_size_t numGlobalElements,
890 GlobalOrdinal indexBase,
891 const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
892 {
893 if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
894 IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(-1, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
895 } else {
896 IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG((map_ = (rcp(new Epetra_BlockMap(numGlobalElements, elementList.size(), elementList.getRawPtr(), 1, indexBase, *toEpetra(comm))))));
897 }
898 }
899
901
903
904
906 global_size_t getGlobalNumElements() const { XPETRA_MONITOR("EpetraMapT::getGlobalNumElements"); return map_->NumGlobalElements64(); }
907
909 size_t getLocalNumElements() const { XPETRA_MONITOR("EpetraMapT::getLocalNumElements"); return map_->NumMyElements(); }
910
912 GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("EpetraMapT::getIndexBase"); return (GlobalOrdinal) map_->IndexBase64(); }
913
915 LocalOrdinal getMinLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinLocalIndex"); return map_->MinLID(); }
916
918 LocalOrdinal getMaxLocalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxLocalIndex"); return map_->MaxLID(); }
919
921 GlobalOrdinal getMinGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinGlobalIndex"); return (GlobalOrdinal) map_->MinMyGID64(); }
922
924 GlobalOrdinal getMaxGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxGlobalIndex"); return (GlobalOrdinal) map_->MaxMyGID64(); }
925
927 GlobalOrdinal getMinAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMinAllGlobalIndex"); return (GlobalOrdinal) map_->MinAllGID64(); }
928
930 GlobalOrdinal getMaxAllGlobalIndex() const { XPETRA_MONITOR("EpetraMapT::getMaxAllGlobalIndex"); return (GlobalOrdinal) map_->MaxAllGID64(); }
931
933 LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::getLocalElement"); return map_->LID(globalIndex); }
934
936 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())); }
937
939 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)); }
940
942 Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const { XPETRA_MONITOR("EpetraMapT::getLocalElementList"); return ArrayView< const long long >(map_->MyGlobalElements64(), map_->NumMyElements()); }
944
946
947
949 bool isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeLocalElement"); return map_->MyLID(localIndex); }
950
952 bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMapT::isNodeGlobalElement"); return map_->MyGID(globalIndex); }
953
955 bool isContiguous() const { XPETRA_MONITOR("EpetraMapT::isContiguous"); return map_->LinearMap(); }
956
958 bool isDistributed() const { XPETRA_MONITOR("EpetraMapT::isDistributed"); return map_->DistributedGlobal(); }
959
961 bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isCompatible"); return map_->PointSameAs(toEpetra<GlobalOrdinal,Node>(map)); }
962
964 bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMapT::isSameAs"); return map_->SameAs(toEpetra<GlobalOrdinal,Node>(map)); }
965
967
969
970
972 Teuchos::RCP< const Teuchos::Comm< int > > getComm() const { XPETRA_MONITOR("EpetraMapT::getComm"); return toXpetra(map_->Comm()); }
973
974
976
978
979
981 std::string description() const {
982 XPETRA_MONITOR("EpetraMapT::description");
983
984 // This implementation come from Tpetra_Map_def.hpp (without modification)
985 std::ostringstream oss;
987 oss << "{getGlobalNumElements() = " << getGlobalNumElements()
988 << ", getLocalNumElements() = " << getLocalNumElements()
989 << ", isContiguous() = " << isContiguous()
990 << ", isDistributed() = " << isDistributed()
991 << "}";
992 return oss.str();
993 }
994
997 XPETRA_MONITOR("EpetraMapT::describe");
998
1000
1001 // This implementation come from Tpetra_Map_def.hpp (without modification)
1002 using std::endl;
1003 using std::setw;
1005 using Teuchos::VERB_NONE;
1006 using Teuchos::VERB_LOW;
1008 using Teuchos::VERB_HIGH;
1010
1011 const size_t nME = getLocalNumElements();
1013 int myImageID = comm_->getRank();
1014 int numImages = comm_->getSize();
1015
1016 Teuchos::EVerbosityLevel vl = verbLevel;
1017 if (vl == VERB_DEFAULT) vl = VERB_LOW;
1018
1019 size_t width = 1;
1020 for (size_t dec=10; dec<getGlobalNumElements(); dec *= 10) {
1021 ++width;
1022 }
1023 width = ::std::max<size_t>(width, (size_t) 12) + 2; // casting to size_t to avoid ambiguity error when compiling Sacado.
1024
1025 Teuchos::OSTab tab(out);
1026
1027 if (vl == VERB_NONE) {
1028 // do nothing
1029 }
1030 else if (vl == VERB_LOW) {
1031 out << this->description() << endl;
1032 }
1033 else { // MEDIUM, HIGH or EXTREME
1034 for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1035 if (myImageID == imageCtr) {
1036 if (myImageID == 0) { // this is the root node (only output this info once)
1037 out << endl
1038 << "Number of Global Entries = " << getGlobalNumElements() << endl
1039 << "Maximum of all GIDs = " << getMaxAllGlobalIndex() << endl
1040 << "Minimum of all GIDs = " << getMinAllGlobalIndex() << endl
1041 << "Index Base = " << getIndexBase() << endl;
1042 }
1043 out << endl;
1044 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1045 out << "Number of Local Elements = " << nME << endl
1046 << "Maximum of my GIDs = " << getMaxGlobalIndex() << endl
1047 << "Minimum of my GIDs = " << getMinGlobalIndex() << endl;
1048 out << endl;
1049 }
1050 if (vl == VERB_EXTREME) {
1051 out << std::setw(width) << "Node ID"
1052 << std::setw(width) << "Local Index"
1053 << std::setw(width) << "Global Index"
1054 << endl;
1055 for (size_t i=0; i < nME; i++) {
1056 out << std::setw(width) << myImageID
1057 << std::setw(width) << i
1058 << std::setw(width) << myEntries[i]
1059 << endl;
1060 }
1061 out << std::flush;
1062 }
1063 }
1064 // Do a few global ops to give I/O a chance to complete
1065 comm_->barrier();
1066 comm_->barrier();
1067 comm_->barrier();
1068 }
1069 }
1070 }
1071
1073
1075
1076
1079 const Epetra_BlockMap * NewMap = map_->RemoveEmptyProcesses();
1080 if (!NewMap) {
1081 return Teuchos::null;
1082 } else {
1083 const RCP< const Map<int, GlobalOrdinal, Node> > NewMapX = toXpetra<GlobalOrdinal, Node>(*NewMap);
1084 delete NewMap; // NOTE: toXpetra *copys* the epetra map rather than wrapping it, so we have to delete NewMap to avoid a memory leak.
1085 return NewMapX;
1086 }
1087 }
1088
1091 throw std::runtime_error("Xpetra::EpetraMapT::replaceCommWithSubset has not yet been implemented in "+std::string(__FILE__)+":"+std::to_string(__LINE__));
1092 // return Teuchos::null; // unreachable
1093 }
1094
1096
1099 XPETRA_MONITOR("EpetraMapT::getGlobalElement");
1100
1101 GlobalOrdinal gid = (GlobalOrdinal) map_->GID64(localIndex);
1102 if (gid == map_->IndexBase64()-1) return (-1);
1103 else return (gid);
1104 }
1105
1107
1108
1110 virtual ~EpetraMapT() {}
1111
1114 : map_(map) {
1115 TEUCHOS_TEST_FOR_EXCEPTION(!map->GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraMapT: GlobalOrdinal mismatch.");
1116 }
1117
1120
1122 const RCP< const Epetra_Map > & getEpetra_MapRCP() const { return Teuchos::rcp_static_cast<const Epetra_Map>(map_); }
1123 const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
1124 const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
1125
1126#ifdef HAVE_XPETRA_TPETRA
1130 throw std::runtime_error("Xpetra::EpetraMap::getLocalMap is not implemented in "+std::string(__FILE__)+":"+std::to_string(__LINE__));
1131 }
1132
1133 private:
1135#else
1136#ifdef __GNUC__
1137#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."
1138#endif
1139#endif
1140
1142
1143 protected:
1144
1146}; // EpetraMapT class
1147#endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1148
1149} // Xpetra namespace
1150
1151#endif // XPETRA_EPETRAMAP_HPP
#define XPETRA_MONITOR(funcName)
#define IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG(sourceCode)
size_type size() const
T * getRawPtr() const
static const EVerbosityLevel verbLevel_default
virtual std::string description() const
bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on this process.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
size_t getLocalNumElements() 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.
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.
GlobalOrdinal getIndexBase() const
The index base for this Map.
const Epetra_Map & getEpetra_Map() const
const Epetra_BlockMap & getEpetra_BlockMap() const
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
UnderlyingLib lib() const
Get the library used by this object (Epetra or Epetra?)
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
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.
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.
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
EpetraMapT(const Teuchos::RCP< const Epetra_BlockMap > &map)
EpetraMapT constructor to wrap a Epetra_Map object.
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 getMinGlobalIndex() const
The minimum global index owned by the calling process.
EpetraMapT(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed)
Constructor with Tpetra-defined contiguous uniform distribution.
RCP< const Map< int, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &) const
Replace this Map's communicator with a subset communicator.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a view of the global indices owned by this process.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
std::string description() const
Return a simple one-line description of this object.
const RCP< const Epetra_Map > getEpetra_MapRCP() const
Get the underlying Epetra map.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const
Return the process ranks for the given global indices.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
typename Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
size_t getLocalNumElements() const
The number of elements belonging to the calling process.
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
GlobalOrdinal getIndexBase() const
The index base for this Map.
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
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(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.
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.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const
Return the process ranks for the given global indices.
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.
const Epetra_BlockMap & getEpetra_BlockMap() const
global_size_t getGlobalNumElements() const
The number of elements in this Map.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
const RCP< const Epetra_Map > & getEpetra_MapRCP() const
Get the underlying Epetra map.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a view of the global indices owned by this process.
UnderlyingLib lib() const
Get the library used by this object (Epetra or Epetra?)
RCP< const Map< int, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &) const
Replace this Map's communicator with a subset communicator.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
std::string description() const
Return a simple one-line description of this object.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map'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.
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.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
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 getMinLocalIndex() const
The minimum local index.
typename Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
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 isContiguous() const
True if this Map is distributed contiguously, else false.
LocalOrdinal getLocalElement(GlobalOrdinal) const
The local index corresponding to the given global index.
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.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &) const
True if and only if map is compatible with this Map.
const Epetra_BlockMap & getEpetra_BlockMap() const
bool isNodeGlobalElement(GlobalOrdinal) const
Whether the given global index is valid for this Map on this process.
virtual ~EpetraMapT()
Destructor.
UnderlyingLib lib() const
Get the library used by this object (Epetra or Epetra?)
RCP< const Map< int, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
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.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
size_t getLocalNumElements() const
The number of elements belonging to the calling process.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &, const Teuchos::ArrayView< int > &) const
Return the process ranks for the given global indices.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &) const
True if and only if map is identical to this Map.
std::string description() const
Return a simple one-line description of this object.
RCP< const Epetra_BlockMap > map_
bool isNodeLocalElement(LocalOrdinal) const
Whether the given local index is valid for this Map on this process.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
const Epetra_Map & getEpetra_Map() const
EpetraMapT(const Teuchos::RCP< const Epetra_BlockMap > &map)
EpetraMapT constructor to wrap a Epetra_Map object.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a view of the global indices owned by this process.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum 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.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
const RCP< const Epetra_Map > & getEpetra_MapRCP() const
Get the underlying Epetra map.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
GlobalOrdinal getIndexBase() const
The index base for this Map.
RCP< const Map< int, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &) const
Replace this Map's communicator with a subset communicator.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
typename Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
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.
GlobalOrdinal global_ordinal_type
Exception throws to report errors in the internal logical of the program.
Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
std::string typeName(const T &t)
Xpetra namespace
size_t global_size_t
Global size_t object.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)