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