46 #ifndef XPETRA_EPETRAMAP_HPP 47 #define XPETRA_EPETRAMAP_HPP 55 #include <Epetra_Map.h> 56 #include <Epetra_BlockMap.h> 67 template<
class GlobalOrdinal>
68 const Epetra_Map &
toEpetra(
const Map<int,GlobalOrdinal> &);
69 template<
class GlobalOrdinal>
70 const Epetra_Map &
toEpetra(
const RCP<
const Map<int, GlobalOrdinal> > &);
73 template<
class GlobalOrdinal>
74 const RCP< const Map<int, GlobalOrdinal> >
toXpetra(
const Epetra_BlockMap &);
77 template<
class EpetraGlobalOrdinal>
79 :
public virtual Map<int, EpetraGlobalOrdinal>
96 return KokkosClassic::Details::getNode<Node>();
104 GlobalOrdinal indexBase,
115 GlobalOrdinal indexBase,
226 if (gid ==
map_->IndexBase64()-1)
return (-1);
239 TEUCHOS_TEST_FOR_EXCEPTION(!map->GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error,
"Xpetra::EpetraMapT: GlobalOrdinal mismatch.");
260 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES 264 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES 273 template<
class EpetraGlobalOrdinal>
279 std::string errPrefix;
280 errPrefix =
Teuchos::typeName(*
this) +
"::constructor(numGlobal,indexBase,comm,lOrG): ";
283 const int myImageID = comm->getRank();
288 Teuchos::broadcast<int,global_size_t>(*comm,0,&rootNGE);
289 Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB);
290 int localChecks[2], globalChecks[2];
293 if (numGlobalElements != rootNGE) {
294 localChecks[0] = myImageID;
297 else if (indexBase != rootIB) {
298 localChecks[0] = myImageID;
303 Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
304 if (globalChecks[0] != -1) {
305 if (globalChecks[1] == 1) {
307 errPrefix <<
"numGlobal must be the same on all nodes (examine node " << globalChecks[0] <<
").");
309 else if (globalChecks[1] == 2) {
311 errPrefix <<
"indexBase must be the same on all nodes (examine node " << globalChecks[0] <<
").");
316 errPrefix <<
"logic error. Please contact the Tpetra team.");
326 template<
class EpetraGlobalOrdinal>
331 using Teuchos::outArg;
339 std::string errPrefix;
340 errPrefix =
Teuchos::typeName(*
this) +
"::constructor(numGlobal,numLocal,indexBase,platform): ";
343 const int myImageID = comm->getRank();
348 int localChecks[2], globalChecks[2];
356 Teuchos::reduceAll<int,global_size_t>(*comm,Teuchos::REDUCE_SUM,
357 Teuchos::as<global_size_t>(numLocalElements),outArg(global_sum));
364 if (numLocalElements < L1 && numLocalElements != L0) {
366 localChecks[0] = myImageID;
369 else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
371 localChecks[0] = myImageID;
374 else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
376 localChecks[0] = myImageID;
381 Teuchos::broadcast<int,GlobalOrdinal>(*comm,0,&rootIB);
382 if (indexBase != rootIB) {
383 localChecks[0] = myImageID;
388 Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
389 if (globalChecks[0] != -1) {
390 if (globalChecks[1] == 1) {
392 errPrefix <<
"numLocal is not valid on at least one node (possibly node " 393 << globalChecks[0] <<
").");
395 else if (globalChecks[1] == 2) {
397 errPrefix <<
"numGlobal is not valid on at least one node (possibly node " 398 << globalChecks[0] <<
").");
400 else if (globalChecks[1] == 3) {
402 errPrefix <<
"numGlobal doesn't match sum of numLocal (== " 403 << global_sum <<
") on at least one node (possibly node " 404 << globalChecks[0] <<
").");
406 else if (globalChecks[1] == 4) {
408 errPrefix <<
"indexBase is not the same on all nodes (examine node " 409 << globalChecks[0] <<
").");
414 errPrefix <<
"logic error. Please contact the Tpetra team.");
421 if (numGlobalElements == GSTI) {
422 numGlobalElements = global_sum;}
428 template<
class EpetraGlobalOrdinal>
440 template<
class EpetraGlobalOrdinal>
443 template<
class EpetraGlobalOrdinal>
446 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES 451 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES 456 template<
class EpetraGlobalOrdinal>
464 template<
class EpetraGlobalOrdinal>
466 const Epetra_BlockMap * NewMap =
map_->RemoveEmptyProcesses();
468 return Teuchos::null;
476 template<
class EpetraGlobalOrdinal>
478 throw std::runtime_error(
"Xpetra::EpetraMapT::replaceCommWithSubset has not yet been implemented.");
479 return Teuchos::null;
482 template<
class EpetraGlobalOrdinal>
487 std::ostringstream oss;
497 template<
class EpetraGlobalOrdinal>
515 int myImageID = comm_->getRank();
516 int numImages = comm_->getSize();
525 width = ::std::max<size_t>(width, (size_t) 12) + 2;
536 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
537 if (myImageID == imageCtr) {
538 if (myImageID == 0) {
547 out <<
"Number of Local Elements = " << nME << endl
553 out << std::setw(width) <<
"Node ID" 554 << std::setw(width) <<
"Local Index" 555 << std::setw(width) <<
"Global Index" 557 for (
size_t i=0; i < nME; i++) {
558 out << std::setw(width) << myImageID
559 << std::setw(width) << i
560 << std::setw(width) << myEntries[i]
579 #endif // XPETRA_EPETRAMAP_HPP
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...
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal > > &graph)
size_t getNodeNumElements() const
The number of elements belonging to the calling process.
Map< int, GlobalOrdinal >::node_type Node
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static Teuchos::RCP< Node > defaultArgNode()
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 getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
RCP< const CrsGraph< int, GlobalOrdinal > > toXpetra(const Epetra_CrsGraph &g)
GlobalOrdinal getIndexBase() const
The index base for this Map.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
std::string description() const
Return a simple one-line description of this object.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print this object with the given verbosity level to the given Teuchos::FancyOStream.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
GlobalOrdinal getMaxGlobalIndex() const
The maximum 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, const Teuchos::RCP< Node > &node=defaultArgNode())
Constructor with Tpetra-defined contiguous uniform distribution.
#define IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG(sourceCode)
EpetraGlobalOrdinal GlobalOrdinal
virtual std::string description() const
EpetraMapT(const Teuchos::RCP< const Epetra_BlockMap > &map)
EpetraMapT constructor to wrap a Epetra_Map object.
RCP< const Map< int, GlobalOrdinal > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map's communicator with a subset communicator.
Teuchos::RCP< Node > getNode() const
Get this Map's Node object.
RCP< const Epetra_BlockMap > map_
EpetraMapT< long long > EpetraMap64
UnderlyingLib lib() const
Get the library used by this object (Epetra or Epetra?)
RCP< const Map< int, GlobalOrdinal > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
size_t global_size_t
Global size_t object.
static const EVerbosityLevel verbLevel_default
bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on this process.
EpetraMapT< int > EpetraMap
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
static Teuchos::RCP< DefaultNodeType > getDefaultNode()
LocalOrdinal getMinLocalIndex() const
The minimum local index.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
#define XPETRA_MONITOR(funcName)
Map< int, int >::node_type node_type
const Epetra_Map & getEpetra_Map() const
virtual ~EpetraMapT()
Destructor.
const Epetra_BlockMap & getEpetra_BlockMap() const
Get the underlying Epetra map.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
std::string typeName(const T &t)
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this process.