48 #ifdef HAVE_XPETRA_EPETRA 64 std::string errPrefix;
65 errPrefix = Teuchos::typeName(*
this) +
"::constructor(numGlobal,indexBase,comm,lOrG): ";
68 const int myImageID = comm->getRank();
72 int rootIB = indexBase;
73 Teuchos::broadcast<int,global_size_t>(*comm,0,&rootNGE);
74 Teuchos::broadcast<int,int>(*comm,0,&rootIB);
75 int localChecks[2], globalChecks[2];
78 if (numGlobalElements != rootNGE) {
79 localChecks[0] = myImageID;
82 else if (indexBase != rootIB) {
83 localChecks[0] = myImageID;
88 Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
89 if (globalChecks[0] != -1) {
90 if (globalChecks[1] == 1) {
91 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
92 errPrefix <<
"numGlobal must be the same on all nodes (examine node " << globalChecks[0] <<
").");
94 else if (globalChecks[1] == 2) {
95 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
96 errPrefix <<
"indexBase must be the same on all nodes (examine node " << globalChecks[0] <<
").");
100 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
101 errPrefix <<
"logic error. Please contact the Tpetra team.");
112 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
const Teuchos::RCP<Node> &node)
115 using Teuchos::outArg;
117 const size_t L0 = Teuchos::OrdinalTraits<size_t>::zero();
118 const size_t L1 = Teuchos::OrdinalTraits<size_t>::one();
119 const global_size_t GST0 = Teuchos::OrdinalTraits<global_size_t>::zero();
120 const global_size_t GST1 = Teuchos::OrdinalTraits<global_size_t>::one();
121 const global_size_t GSTI = Teuchos::OrdinalTraits<global_size_t>::invalid();
123 std::string errPrefix;
124 errPrefix = Teuchos::typeName(*
this) +
"::constructor(numGlobal,numLocal,indexBase,platform): ";
127 const int myImageID = comm->getRank();
132 int localChecks[2], globalChecks[2];
140 Teuchos::reduceAll<int,global_size_t>(*comm,Teuchos::REDUCE_SUM,
141 Teuchos::as<global_size_t>(numLocalElements),outArg(global_sum));
148 if (numLocalElements < L1 && numLocalElements != L0) {
150 localChecks[0] = myImageID;
153 else if (numGlobalElements < GST1 && numGlobalElements != GST0 && numGlobalElements != GSTI) {
155 localChecks[0] = myImageID;
158 else if (numGlobalElements != GSTI && numGlobalElements != global_sum) {
160 localChecks[0] = myImageID;
164 int rootIB = indexBase;
165 Teuchos::broadcast<int,int>(*comm,0,&rootIB);
166 if (indexBase != rootIB) {
167 localChecks[0] = myImageID;
172 Teuchos::reduceAll<int,int>(*comm,Teuchos::REDUCE_MAX,2,localChecks,globalChecks);
173 if (globalChecks[0] != -1) {
174 if (globalChecks[1] == 1) {
175 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
176 errPrefix <<
"numLocal is not valid on at least one node (possibly node " 177 << globalChecks[0] <<
").");
179 else if (globalChecks[1] == 2) {
180 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
181 errPrefix <<
"numGlobal is not valid on at least one node (possibly node " 182 << globalChecks[0] <<
").");
184 else if (globalChecks[1] == 3) {
185 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
186 errPrefix <<
"numGlobal doesn't match sum of numLocal (== " 187 << global_sum <<
") on at least one node (possibly node " 188 << globalChecks[0] <<
").");
190 else if (globalChecks[1] == 4) {
191 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
192 errPrefix <<
"indexBase is not the same on all nodes (examine node " 193 << globalChecks[0] <<
").");
197 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
198 errPrefix <<
"logic error. Please contact the Tpetra team.");
205 if (numGlobalElements == GSTI) {
206 numGlobalElements = global_sum;}
213 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
const Teuchos::RCP<Node> &node)
215 if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
228 LookupStatus EpetraMap::getRemoteIndexList(
const Teuchos::ArrayView< const GlobalOrdinal > &GIDList,
const Teuchos::ArrayView< int > &nodeIDList,
const Teuchos::ArrayView< int > &LIDList)
const {
XPETRA_MONITOR(
"EpetraMap::getRemoteIndexList");
return toXpetra(
map_->RemoteIDList(GIDList.size(), GIDList.getRawPtr(), nodeIDList.getRawPtr(), LIDList.getRawPtr())); }
246 std::ostringstream oss;
247 oss << Teuchos::Describable::description();
259 const Teuchos::RCP<const Teuchos::Comm<int> > comm_ =
getComm();
264 using Teuchos::VERB_DEFAULT;
265 using Teuchos::VERB_NONE;
266 using Teuchos::VERB_LOW;
267 using Teuchos::VERB_MEDIUM;
268 using Teuchos::VERB_HIGH;
269 using Teuchos::VERB_EXTREME;
273 int myImageID = comm_->getRank();
274 int numImages = comm_->getSize();
276 Teuchos::EVerbosityLevel vl = verbLevel;
277 if (vl == VERB_DEFAULT) vl = VERB_LOW;
283 width = std::max<size_t>(width,12) + 2;
285 Teuchos::OSTab tab(out);
287 if (vl == VERB_NONE) {
290 else if (vl == VERB_LOW) {
294 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
295 if (myImageID == imageCtr) {
296 if (myImageID == 0) {
304 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
305 out <<
"Number of Local Elements = " << nME << endl
310 if (vl == VERB_EXTREME) {
311 out << std::setw(width) <<
"Node ID" 312 << std::setw(width) <<
"Local Index" 313 << std::setw(width) <<
"Global Index" 315 for (
size_t i=0; i < nME; i++) {
316 out << std::setw(width) << myImageID
317 << std::setw(width) << i
318 << std::setw(width) << myEntries[i]
344 return epetraMap->getEpetra_Map();
351 const RCP< const Map<int, int> >
toXpetra(
const Epetra_BlockMap &map) {
352 RCP<const Epetra_BlockMap> m = rcp(
new Epetra_BlockMap(map));
std::string description() const
Return a simple one-line description of this object.
RCP< const CrsGraph< int, int > > toXpetra(const Epetra_CrsGraph &g)
bool isContiguous() const
True if this Map is distributed contiguously, else false.
#define IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG(sourceCode)
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
Return the process IDs and corresponding local IDs for the given global IDs.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
const Teuchos::RCP< Node > getNode() const
Get this Map's Node object.
static Teuchos::RCP< DefaultNodeType > getDefaultNode()
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this node.
RCP< const Epetra_BlockMap > map_
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, int > > &graph)
size_t getNodeNumElements() const
The number of elements belonging to the calling node.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by 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 FancyOStream.
EpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode())
Constructor with Tpetra-defined contiguous uniform distribution.
size_t global_size_t
Global size_t object.
const Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
#define XPETRA_MONITOR(funcName)
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
GlobalOrdinal getIndexBase() const
The index base for this Map.
const Epetra_Map & getEpetra_Map() const