42 #ifndef TPETRA_IMPORT_DEF_HPP
43 #define TPETRA_IMPORT_DEF_HPP
45 #ifdef DOXYGEN_USE_ONLY
46 # include <Tpetra_Import_decl.hpp>
47 #endif // DOXYGEN_USE_ONLY
49 #include <Tpetra_Distributor.hpp>
50 #include <Tpetra_Map.hpp>
51 #include <Tpetra_ImportExportData.hpp>
53 #include <Tpetra_Export.hpp>
54 #include <Teuchos_as.hpp>
59 const bool tpetraImportDebugDefault =
false;
64 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 bool debug = tpetraImportDebugDefault;
70 if (! plist.is_null ()) {
72 debug = plist->get<
bool> (
"Debug");
73 }
catch (Teuchos::Exceptions::InvalidParameter&) {}
76 ImportData_->distributor_.setParameterList (plist);
79 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
84 const Teuchos::RCP<Teuchos::ParameterList>& plist)
93 bool debug = tpetraImportDebugDefault;
94 if (! plist.is_null ()) {
96 debug = plist->get<
bool> (
"Debug");
97 }
catch (Teuchos::Exceptions::InvalidParameter&) {}
101 if (! out_.is_null ()) {
105 std::ostringstream os;
106 const int myRank = source->getComm ()->getRank ();
107 os << myRank <<
": Import ctor" << endl;
110 ImportData_ = rcp (
new data_type (source, target, out_, plist));
112 Array<GlobalOrdinal> remoteGIDs;
113 setupSamePermuteRemote (remoteGIDs);
115 std::ostringstream os;
116 const int myRank = source->getComm ()->getRank ();
117 os << myRank <<
": Import ctor: "
118 <<
"setupSamePermuteRemote done" << endl;
121 if (source->isDistributed ()) {
122 setupExport (remoteGIDs);
125 std::ostringstream os;
126 const int myRank = source->getComm ()->getRank ();
127 os << myRank <<
": Import ctor: done" << endl;
130 if (! out_.is_null ()) {
135 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
137 Import (
const RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& source,
138 const RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& target) :
139 out_ (Teuchos::getFancyOStream (Teuchos::rcpFromRef (std::cerr))),
140 debug_ (tpetraImportDebugDefault)
142 init (source, target, Teuchos::null);
145 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
147 Import (
const RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& source,
148 const RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& target,
149 const RCP<Teuchos::FancyOStream>& out) :
151 debug_ (tpetraImportDebugDefault)
153 init (source, target, Teuchos::null);
156 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
160 const Teuchos::RCP<Teuchos::ParameterList>& plist) :
161 out_ (Teuchos::getFancyOStream (Teuchos::rcpFromRef (std::cerr))),
162 debug_ (tpetraImportDebugDefault)
164 init (source, target, plist);
167 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
171 const RCP<Teuchos::FancyOStream>& out,
172 const Teuchos::RCP<Teuchos::ParameterList>& plist) :
174 debug_ (tpetraImportDebugDefault)
176 init (source, target, plist);
179 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
182 : ImportData_ (rhs.ImportData_)
184 , debug_ (rhs.debug_)
187 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
190 : out_ (exporter.out_)
191 , debug_ (exporter.debug_)
193 if (! exporter.ExportData_.is_null ()) {
194 ImportData_ = exporter.ExportData_->reverseClone ();
198 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
200 Import (
const Teuchos::RCP<const map_type>& source,
201 const Teuchos::RCP<const map_type>& target,
202 const size_t numSameIDs,
203 Teuchos::Array<LocalOrdinal>& permuteToLIDs,
204 Teuchos::Array<LocalOrdinal>& permuteFromLIDs,
205 Teuchos::Array<LocalOrdinal>& remoteLIDs,
206 Teuchos::Array<LocalOrdinal>& exportLIDs,
207 Teuchos::Array<int>& exportPIDs,
209 const Teuchos::RCP<Teuchos::FancyOStream>& out,
210 const Teuchos::RCP<Teuchos::ParameterList>& plist) :
211 out_ (out.is_null () ? Teuchos::getFancyOStream (Teuchos::rcpFromRef (std::cerr)) : out),
212 debug_ (tpetraImportDebugDefault)
222 bool debug = tpetraImportDebugDefault;
223 if (! plist.is_null ()) {
225 debug = plist->get<
bool> (
"Debug");
226 }
catch (Teuchos::Exceptions::InvalidParameter&) {}
230 if (! out_.is_null ()) {
233 if (debug_ && ! out_.is_null ()) {
234 std::ostringstream os;
235 const int myRank = source->getComm ()->getRank ();
236 os << myRank <<
": Import expert ctor" << endl;
239 ImportData_ = rcp (
new data_type (source, target, out_, plist));
241 ImportData_->numSameIDs_ = numSameIDs;
242 ImportData_->permuteToLIDs_.swap (permuteToLIDs);
243 ImportData_->permuteFromLIDs_.swap (permuteFromLIDs);
244 ImportData_->remoteLIDs_.swap (remoteLIDs);
245 ImportData_->distributor_.swap (distributor);
246 ImportData_->exportLIDs_.swap (exportLIDs);
247 ImportData_->exportPIDs_.swap (exportPIDs);
250 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
254 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
256 return ImportData_->numSameIDs_;
259 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
261 return ImportData_->permuteFromLIDs_.size();
264 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
265 ArrayView<const LocalOrdinal>
267 return ImportData_->permuteFromLIDs_();
270 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
271 ArrayView<const LocalOrdinal>
273 return ImportData_->permuteToLIDs_();
276 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
278 return ImportData_->remoteLIDs_.size();
281 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
282 ArrayView<const LocalOrdinal>
284 return ImportData_->remoteLIDs_();
287 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
289 return ImportData_->exportLIDs_.size();
292 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
293 ArrayView<const LocalOrdinal>
295 return ImportData_->exportLIDs_();
298 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
301 return ImportData_->exportPIDs_();
304 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
305 const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > &
307 return ImportData_->source_;
310 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
311 const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > &
313 return ImportData_->target_;
316 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
319 return ImportData_->distributor_;
322 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
327 ImportData_ = rhs.ImportData_;
332 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
337 using Teuchos::getFancyOStream;
339 using Teuchos::rcpFromRef;
340 using Teuchos::toString;
343 RCP<const Comm<int> > comm = getSourceMap ()->getComm ();
344 const int myImageID = comm->getRank ();
345 const int numImages = comm->getSize ();
346 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
347 if (myImageID == imageCtr) {
349 if (myImageID == 0) {
350 os <<
"Import Data Members:" << endl;
352 os <<
"Image ID : " << myImageID << endl;
354 os <<
"permuteFromLIDs: " << toString (getPermuteFromLIDs ()) << endl;
355 os <<
"permuteToLIDs : " << toString (getPermuteToLIDs ()) << endl;
356 os <<
"remoteLIDs : " << toString (getRemoteLIDs ()) << endl;
357 os <<
"exportLIDs : " << toString (getExportLIDs ()) << endl;
358 os <<
"exportPIDs : " << toString (getExportPIDs ()) << endl;
360 os <<
"numSameIDs : " << getNumSameIDs () << endl;
361 os <<
"numPermuteIDs : " << getNumPermuteIDs () << endl;
362 os <<
"numRemoteIDs : " << getNumRemoteIDs () << endl;
363 os <<
"numExportIDs : " << getNumExportIDs () << endl;
371 const bool printMaps =
false;
373 if (myImageID == 0) {
374 os << endl << endl <<
"Source Map:" << endl << std::flush;
377 os << *getSourceMap();
380 if (myImageID == 0) {
381 os << endl << endl <<
"Target Map:" << endl << std::flush;
384 os << *getTargetMap();
391 if (myImageID == 0) {
392 os << endl << endl <<
"Distributor:" << endl << std::flush;
395 getDistributor().describe (*(getFancyOStream (rcpFromRef (os))),
396 Teuchos::VERB_EXTREME);
400 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
406 using Teuchos::Array;
407 using Teuchos::ArrayRCP;
408 using Teuchos::ArrayView;
411 typedef LocalOrdinal LO;
412 typedef GlobalOrdinal GO;
413 typedef typename ArrayView<const GO>::size_type size_type;
419 #ifdef HAVE_TPETRA_DEBUG
420 ArrayView<const GO> rawSrcGids = sourceGIDs;
421 ArrayView<const GO> rawTgtGids = targetGIDs;
423 const GO*
const rawSrcGids = sourceGIDs.getRawPtr ();
424 const GO*
const rawTgtGids = targetGIDs.getRawPtr ();
425 #endif // HAVE_TPETRA_DEBUG
426 const size_type numSrcGids = sourceGIDs.size ();
427 const size_type numTgtGids = targetGIDs.size ();
428 const size_type numGids = std::min (numSrcGids, numTgtGids);
436 size_type numSameGids = 0;
437 for ( ; numSameGids < numGids && rawSrcGids[numSameGids] == rawTgtGids[numSameGids]; ++numSameGids)
439 ImportData_->numSameIDs_ = numSameGids;
451 Array<LO>& permuteToLIDs = ImportData_->permuteToLIDs_;
452 Array<LO>& permuteFromLIDs = ImportData_->permuteFromLIDs_;
453 Array<LO>& remoteLIDs = ImportData_->remoteLIDs_;
454 const LO LINVALID = Teuchos::OrdinalTraits<LO>::invalid ();
455 const LO numTgtLids = as<LO> (numTgtGids);
458 for (LO tgtLid = numSameGids; tgtLid < numTgtLids; ++tgtLid) {
459 const GO curTargetGid = rawTgtGids[tgtLid];
463 if (srcLid != LINVALID) {
464 permuteToLIDs.push_back (tgtLid);
465 permuteFromLIDs.push_back (srcLid);
467 remoteGIDs.push_back (curTargetGid);
468 remoteLIDs.push_back (tgtLid);
475 "::setupSamePermuteRemote(): Target has remote LIDs but Source is not "
476 "distributed globally." << std::endl
477 <<
"Importing to a submap of the target map.");
481 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
482 void Import<LocalOrdinal,GlobalOrdinal,Node>::
483 setupExport (Teuchos::Array<GlobalOrdinal>& remoteGIDs)
486 using Teuchos::Array;
487 using Teuchos::ArrayRCP;
488 using Teuchos::ArrayView;
491 typedef LocalOrdinal LO;
492 typedef GlobalOrdinal GO;
493 typedef typename Array<int>::difference_type size_type;
494 const Map<LO, GO, Node> & source = *getSourceMap ();
496 Teuchos::OSTab tab (out_);
499 std::ostringstream os;
500 const int myRank = source.getComm ()->getRank ();
501 os << myRank <<
": Import::setupExport" << endl;
507 ArrayView<GO> remoteGIDsView = remoteGIDs ();
508 Array<int> remoteProcIDs (remoteGIDsView.size ());
529 source.getRemoteIndexList (remoteGIDsView, remoteProcIDs ());
531 std::ostringstream os;
532 const int myRank = source.getComm ()->getRank ();
533 os << myRank <<
": Import::setupExport: finished lookup" << endl;
538 "::setupExport(): the source Map wasn't able to figure out which process "
539 "owns one or more of the GIDs in the list of remote GIDs. This probably "
540 "means that there is at least one GID owned by some process in the target"
541 " Map which is not owned by any process in the source Map. (That is, the"
542 " source and target Maps do not contain the same set of GIDs globally.)");
548 const size_type numInvalidRemote =
549 std::count_if (remoteProcIDs.begin (), remoteProcIDs.end (),
550 std::bind1st (std::equal_to<int> (), -1));
552 const size_type totalNumRemote = getNumRemoteIDs ();
553 if (numInvalidRemote == totalNumRemote) {
555 remoteProcIDs.clear ();
557 ImportData_->remoteLIDs_.clear();
562 size_type numValidRemote = 0;
563 #ifdef HAVE_TPETRA_DEBUG
564 ArrayView<GlobalOrdinal> remoteGIDsPtr = remoteGIDsView;
566 GlobalOrdinal*
const remoteGIDsPtr = remoteGIDsView.getRawPtr ();
567 #endif // HAVE_TPETRA_DEBUG
568 for (size_type r = 0; r < totalNumRemote; ++r) {
570 if (remoteProcIDs[r] != -1) {
571 remoteProcIDs[numValidRemote] = remoteProcIDs[r];
572 remoteGIDsPtr[numValidRemote] = remoteGIDsPtr[r];
573 ImportData_->remoteLIDs_[numValidRemote] = ImportData_->remoteLIDs_[r];
577 TEUCHOS_TEST_FOR_EXCEPTION(
578 numValidRemote != totalNumRemote - numInvalidRemote, std::logic_error,
579 "Tpetra::Import::setupExport(): After removing invalid remote GIDs and"
580 " packing the valid remote GIDs, numValidRemote = " << numValidRemote
581 <<
" != totalNumRemote - numInvalidRemote = "
582 << totalNumRemote - numInvalidRemote
583 <<
". Please report this bug to the Tpetra developers.");
585 remoteProcIDs.resize (numValidRemote);
586 remoteGIDs.resize (numValidRemote);
587 ImportData_->remoteLIDs_.resize (numValidRemote);
590 remoteGIDsView = remoteGIDs ();
597 sort3 (remoteProcIDs.begin (),
598 remoteProcIDs.end (),
599 remoteGIDsView.begin (),
600 ImportData_->remoteLIDs_.begin ());
607 Array<GO> exportGIDs;
608 ImportData_->distributor_.createFromRecvs (remoteGIDsView ().getConst (),
609 remoteProcIDs, exportGIDs,
610 ImportData_->exportPIDs_);
616 const size_type numExportIDs = exportGIDs.size ();
617 if (numExportIDs > 0) {
618 ImportData_->exportLIDs_.resize(numExportIDs);
620 ArrayView<const GO> expGIDs = exportGIDs ();
621 ArrayView<LO> expLIDs = ImportData_->exportLIDs_ ();
622 for (size_type k = 0; k < numExportIDs; ++k) {
623 expLIDs[k] = source.getLocalElement (expGIDs[k]);
627 std::ostringstream os;
628 const int myRank = source.getComm ()->getRank ();
629 os << myRank <<
": Import::setupExport: done" << endl;
634 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
635 Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
636 Import<LocalOrdinal,GlobalOrdinal,Node>::
637 setUnionNaiveImpl (
const Import<LocalOrdinal, GlobalOrdinal, Node>& rhs)
const
643 using Teuchos::Array;
644 using Teuchos::ArrayView;
648 using Teuchos::outArg;
649 using Teuchos::REDUCE_MIN;
650 using Teuchos::reduceAll;
651 typedef LocalOrdinal LO;
652 typedef GlobalOrdinal GO;
653 typedef Import<LO, GO, Node> import_type;
655 RCP<const map_type> srcMap = this->getSourceMap ();
656 RCP<const map_type> tgtMap1 = this->getTargetMap ();
657 RCP<const map_type> tgtMap2 = rhs.getTargetMap ();
658 RCP<const Comm<int> > comm = srcMap->getComm ();
659 #ifdef HAVE_TPETRA_DEBUG
660 TEUCHOS_TEST_FOR_EXCEPTION(
661 ! srcMap->isSameAs (* (rhs.getSourceMap ())), std::invalid_argument,
662 "Tpetra::Import::setUnion: The source Map of the input Import must be the "
663 "same as (in the sense of Map::isSameAs) the source Map of this Import.");
664 TEUCHOS_TEST_FOR_EXCEPTION(
665 ! Details::congruent (* (tgtMap1->getComm ()), * (tgtMap2->getComm ())),
666 std::invalid_argument,
"Tpetra::Import::setUnion: "
667 "The target Maps must have congruent communicators.");
668 #endif // HAVE_TPETRA_DEBUG
670 ArrayView<const GO> gids1 = tgtMap1->getNodeElementList ();
671 ArrayView<const GO> gids2 = tgtMap2->getNodeElementList ();
675 Array<GO> gids1Copy, gids2Copy;
676 if (! SortDetails::isAlreadySorted (gids1.begin (), gids1.end ())) {
677 gids1Copy.reserve (gids1.size ());
678 gids1Copy.assign (gids1.begin (), gids1.end ());
679 std::sort (gids1Copy.begin (), gids1Copy.end ());
680 gids1 = gids1Copy ();
682 if (! SortDetails::isAlreadySorted (gids2.begin (), gids2.end ())) {
683 gids2Copy.reserve (gids2.size ());
684 gids2Copy.assign (gids2.begin (), gids2.end ());
685 std::sort (gids2Copy.begin (), gids2Copy.end ());
686 gids2 = gids2Copy ();
690 gidsUnion.reserve (std::max (gids1.size (), gids2.size ()));
691 std::set_union (gids1.begin (), gids1.end (), gids2.begin (), gids2.end (),
692 std::back_inserter (gidsUnion));
696 typename Array<GO>::const_iterator minPos =
697 std::min_element (gidsUnion.begin (), gidsUnion.end ());
698 const GO myMinGid = (minPos == gidsUnion.end ()) ? 0 : *minPos;
700 reduceAll<int, GO> (*comm, REDUCE_MIN, myMinGid, outArg (globalMinGid));
701 const GST INVALID = Teuchos::OrdinalTraits<GST>::invalid ();
702 RCP<const map_type> unionMap =
703 rcp (
new map_type (INVALID, gidsUnion (), globalMinGid,
704 comm, srcMap->getNode ()));
705 return rcp (
new import_type (srcMap, unionMap));
708 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
709 Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
713 return setUnionImpl (rhs);
717 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
718 Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
723 using Teuchos::Array;
724 using Teuchos::ArrayView;
729 using Teuchos::outArg;
730 using Teuchos::REDUCE_MIN;
731 using Teuchos::reduceAll;
732 typedef LocalOrdinal LO;
733 typedef GlobalOrdinal GO;
735 typedef typename Array<GO>::size_type size_type;
737 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
738 using Teuchos::toString;
741 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
743 RCP<const map_type> srcMap = this->getSourceMap ();
744 RCP<const map_type> tgtMap1 = this->getTargetMap ();
746 RCP<const Comm<int> > comm = srcMap->getComm ();
748 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
749 const int myRank = comm->getRank ();
750 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
752 #ifdef HAVE_TPETRA_DEBUG
753 TEUCHOS_TEST_FOR_EXCEPTION(
754 ! srcMap->isSameAs (* (rhs.
getSourceMap ())), std::invalid_argument,
755 "Tpetra::Import::setUnion: The source Map of the input Import must be the "
756 "same as (in the sense of Map::isSameAs) the source Map of this Import.");
757 TEUCHOS_TEST_FOR_EXCEPTION(
758 ! Details::congruent (* (tgtMap1->getComm ()), * (tgtMap2->getComm ())),
759 std::invalid_argument,
"Tpetra::Import::setUnion: "
760 "The target Maps must have congruent communicators.");
761 #endif // HAVE_TPETRA_DEBUG
766 if (tgtMap1->isSameAs (*tgtMap2)) {
767 return rcp (
new import_type (*
this));
772 ArrayView<const GO> srcGIDs = srcMap->getNodeElementList ();
773 ArrayView<const GO> tgtGIDs1 = tgtMap1->getNodeElementList ();
774 ArrayView<const GO> tgtGIDs2 = tgtMap2->getNodeElementList ();
776 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
779 std::ostringstream os;
780 os << myRank <<
": srcGIDs: " << toString (srcGIDs) << endl;
781 os << myRank <<
": tgtGIDs1: " << toString (tgtGIDs1) << endl;
782 os << myRank <<
": tgtGIDs2: " << toString (tgtGIDs2) << endl;
786 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
791 Array<GO> unionTgtGIDs;
796 unionTgtGIDs.reserve (tgtGIDs1.size () + tgtGIDs2.size ());
798 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
805 cerr << myRank <<
": Computing \"same\" GIDs" << endl;
806 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
812 const size_type numSameGIDs1 = this->getNumSameIDs ();
814 ArrayView<const GO> sameGIDs1 = tgtGIDs1 (0, numSameGIDs1);
815 ArrayView<const GO> sameGIDs2 = tgtGIDs2 (0, numSameGIDs2);
816 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
818 std::ostringstream os;
819 os << myRank <<
": same IDs for target Map 1: " << toString (sameGIDs1) << endl;
820 os << myRank <<
": same IDs for target Map 2: " << toString (sameGIDs2) << endl;
823 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
831 ArrayView<const GO> doubleCountedSameGIDs;
832 size_type numSameIDsUnion;
833 bool tgtMap1HadMaxSameGIDs;
834 if (numSameGIDs1 >= numSameGIDs2) {
835 tgtMap1HadMaxSameGIDs =
true;
836 numSameIDsUnion = numSameGIDs1;
837 std::copy (sameGIDs1.begin (), sameGIDs1.end (), std::back_inserter (unionTgtGIDs));
842 doubleCountedSameGIDs = tgtGIDs1 (numSameGIDs2, numSameGIDs1 - numSameGIDs2);
844 tgtMap1HadMaxSameGIDs =
false;
845 numSameIDsUnion = numSameGIDs2;
846 std::copy (sameGIDs2.begin (), sameGIDs2.end (), std::back_inserter (unionTgtGIDs));
851 doubleCountedSameGIDs = tgtGIDs2 (numSameGIDs1, numSameGIDs2 - numSameGIDs1);
854 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
856 std::ostringstream os;
857 os << myRank <<
": union Map's same GIDs: " << toString (unionTgtGIDs ()) << endl;
858 os << myRank <<
": doubleCountedSameGIDs: " << toString (doubleCountedSameGIDs) << endl;
867 cerr << myRank <<
": Computing permute IDs" << endl;
868 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
874 Array<LO> permuteFromLIDsUnion;
875 Array<LO> permuteToLIDsUnion;
876 LO curTgtLid = as<LO> (numSameIDsUnion);
879 ArrayView<const LO> permuteToLIDs1 = this->getPermuteToLIDs ();
881 const size_type numPermuteIDs1 = this->getNumPermuteIDs ();
884 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
885 cerr << myRank <<
": Converting permute-to LIDs to GIDs" << endl;
886 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
890 Array<GO> permuteGIDs1 (numPermuteIDs1);
891 for (size_type k = 0; k < numPermuteIDs1; ++k) {
892 permuteGIDs1[k] = tgtMap1->getGlobalElement (permuteToLIDs1[k]);
894 Array<GO> permuteGIDs2 (numPermuteIDs2);
895 for (size_type k = 0; k < numPermuteIDs2; ++k) {
896 permuteGIDs2[k] = tgtMap2->getGlobalElement (permuteToLIDs2[k]);
899 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
901 std::ostringstream os;
902 os << myRank <<
": permuteGIDs1: " << toString (permuteGIDs1) << endl;
903 os << myRank <<
": permuteGIDs2: " << toString (permuteGIDs2) << endl;
906 cerr << myRank <<
": Sorting and merging permute GID lists" << endl;
907 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
912 std::sort (permuteGIDs1.begin (), permuteGIDs1.end ());
913 std::sort (permuteGIDs2.begin (), permuteGIDs2.end ());
915 typename Array<GO>::iterator permuteGIDs1_beg = permuteGIDs1.begin ();
916 typename Array<GO>::iterator permuteGIDs1_end = permuteGIDs1.end ();
917 typename Array<GO>::iterator permuteGIDs2_beg = permuteGIDs2.begin ();
918 typename Array<GO>::iterator permuteGIDs2_end = permuteGIDs2.end ();
919 if (tgtMap1HadMaxSameGIDs) {
922 std::set_intersection (permuteGIDs2_beg,
924 doubleCountedSameGIDs.begin (),
925 doubleCountedSameGIDs.end (),
930 std::set_intersection (permuteGIDs1_beg,
932 doubleCountedSameGIDs.begin (),
933 doubleCountedSameGIDs.end (),
936 std::set_union (permuteGIDs1_beg, permuteGIDs1_end,
937 permuteGIDs2_beg, permuteGIDs2_end,
938 std::back_inserter (unionTgtGIDs));
939 const size_type numPermuteIDsUnion =
940 unionTgtGIDs.size () - numSameIDsUnion;
941 ArrayView<const GO> permuteGIDsUnion =
942 unionTgtGIDs (numSameIDsUnion, numPermuteIDsUnion).getConst ();
944 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
946 std::ostringstream os;
947 os << myRank <<
": permuteGIDsUnion: " << toString (permuteGIDsUnion) << endl;
950 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
952 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
954 cerr << myRank <<
": Computing permute-to LIDs" << endl;
955 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
958 permuteToLIDsUnion.resize (numPermuteIDsUnion);
959 for (size_type k = 0; k < numPermuteIDsUnion; ++k) {
960 permuteToLIDsUnion[k] = curTgtLid++;
963 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
965 std::ostringstream os;
966 os << myRank <<
": permuteToLIDsUnion: " << toString (permuteToLIDsUnion) << endl;
969 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
971 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
973 cerr << myRank <<
": Computing permute-from LIDs" << endl;
974 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
977 permuteFromLIDsUnion.resize (numPermuteIDsUnion);
978 for (size_type k = 0; k < numPermuteIDsUnion; ++k) {
979 permuteFromLIDsUnion[k] = srcMap->getLocalElement (permuteGIDsUnion[k]);
982 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
984 std::ostringstream os;
985 os << myRank <<
": permuteFromLIDsUnion: " << toString (permuteFromLIDsUnion) << endl;
988 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1010 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1017 cerr << myRank <<
": Computing remote IDs" << endl;
1018 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1020 ArrayView<GO> remoteGIDsUnion;
1021 Array<int> remotePIDsUnion;
1022 Array<LO> remoteLIDsUnion;
1023 size_type numRemoteIDsUnion = 0;
1032 ArrayView<const LO> remoteLIDs1 = this->getRemoteLIDs ();
1035 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1036 cerr << myRank <<
": Converting remote LIDs to GIDs" << endl;
1037 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1042 Array<GO> remoteGIDs1 (remoteLIDs1.size ());
1043 for (size_type k = 0; k < remoteLIDs1.size (); ++k) {
1044 remoteGIDs1[k] = tgtMap1->getGlobalElement (remoteLIDs1[k]);
1046 std::sort (remoteGIDs1.begin (), remoteGIDs1.end ());
1048 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1050 std::ostringstream os;
1051 os << myRank <<
": remoteGIDs1: " << toString (remoteGIDs1 ()) << endl;
1054 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1056 Array<GO> remoteGIDs2 (remoteLIDs2.size ());
1057 for (size_type k = 0; k < remoteLIDs2.size (); ++k) {
1058 remoteGIDs2[k] = tgtMap2->getGlobalElement (remoteLIDs2[k]);
1060 std::sort (remoteGIDs2.begin (), remoteGIDs2.end ());
1062 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1064 std::ostringstream os;
1065 os << myRank <<
": remoteGIDs2: " << toString (remoteGIDs2 ()) << endl;
1068 cerr << myRank <<
": Merging remote GID lists" << endl;
1069 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1073 const size_type oldSize = unionTgtGIDs.size ();
1074 std::set_union (remoteGIDs1.begin (), remoteGIDs1.end (),
1075 remoteGIDs2.begin (), remoteGIDs2.end (),
1076 std::back_inserter (unionTgtGIDs));
1077 const size_type newSize = unionTgtGIDs.size ();
1078 numRemoteIDsUnion = newSize - oldSize;
1079 remoteGIDsUnion = unionTgtGIDs (oldSize, numRemoteIDsUnion);
1081 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1083 std::ostringstream os;
1084 os << myRank <<
": remoteGIDsUnion: " << toString (remoteGIDsUnion ()) << endl;
1087 cerr << myRank <<
": Looking up remote GIDs' PIDs in the source Map" << endl;
1088 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1091 remotePIDsUnion.resize (numRemoteIDsUnion);
1093 srcMap->getRemoteIndexList (remoteGIDsUnion (), remotePIDsUnion ());
1095 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1097 std::ostringstream os;
1098 os << myRank <<
": remotePIDsUnion: " << toString (remotePIDsUnion ()) << endl;
1101 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1106 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1107 cerr << myRank <<
": Filtering remote GIDs not owned by any process in the source Map" << endl;
1108 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1110 const size_type numInvalidRemote =
1111 std::count_if (remotePIDsUnion.begin (), remotePIDsUnion.end (),
1112 std::bind1st (std::equal_to<int> (), -1));
1113 if (numInvalidRemote == numRemoteIDsUnion) {
1115 unionTgtGIDs.resize (oldSize);
1116 numRemoteIDsUnion = 0;
1117 remoteGIDsUnion = ArrayView<GO> (NULL, 0);
1119 Array<int> newRemotePIDsUnion;
1120 std::swap (remotePIDsUnion, newRemotePIDsUnion);
1126 size_type numValidRemote = 0;
1127 for (size_type r = 0; r < numRemoteIDsUnion; ++r) {
1129 if (remotePIDsUnion[r] != -1) {
1130 remotePIDsUnion[numValidRemote] = remotePIDsUnion[r];
1131 remoteGIDsUnion[numValidRemote] = remoteGIDsUnion[r];
1135 TEUCHOS_TEST_FOR_EXCEPTION(
1136 numValidRemote != numRemoteIDsUnion - numInvalidRemote, std::logic_error,
1137 "Tpetra::Import::setUnion(): After removing invalid remote GIDs and"
1138 " packing the valid remote GIDs, numValidRemote = " << numValidRemote
1139 <<
" != numRemoteIDsUnion - numInvalidRemote = "
1140 << numRemoteIDsUnion - numInvalidRemote
1141 <<
". Please report this bug to the Tpetra developers.");
1143 unionTgtGIDs.resize (oldSize + numValidRemote);
1144 numRemoteIDsUnion = numValidRemote;
1145 remoteGIDsUnion = unionTgtGIDs (oldSize, numValidRemote);
1146 remotePIDsUnion.resize (numValidRemote);
1149 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1151 std::ostringstream os;
1152 os << myRank <<
": remoteGIDsUnion after filtering: " << toString (remoteGIDsUnion ()) << endl;
1153 os << myRank <<
": remotePIDsUnion after filtering: " << toString (remotePIDsUnion ()) << endl;
1156 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1159 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1160 cerr << myRank <<
": Assigning LIDs (in union target Map) to remote IDs" << endl;
1161 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1166 remoteLIDsUnion.resize (numRemoteIDsUnion);
1167 for (size_type k = 0; k < numRemoteIDsUnion; ++k) {
1168 remoteLIDsUnion[k] = curTgtLid++;
1171 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1173 std::ostringstream os;
1174 os << myRank <<
": remoteLIDsUnion: " << toString (remoteLIDsUnion ()) << endl;
1177 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1179 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1180 cerr << myRank <<
": Sorting remote PIDs, GIDs, and LIDs jointly by PID" << endl;
1181 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1183 sort3 (remotePIDsUnion.begin (), remotePIDsUnion.end (),
1184 remoteGIDsUnion.begin (), remoteLIDsUnion.begin ());
1186 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1188 std::ostringstream os;
1189 os << myRank <<
": remoteGIDsUnion sorted: " << toString (remoteGIDsUnion ()) << endl;
1190 os << myRank <<
": remotePIDsUnion sorted: " << toString (remotePIDsUnion ()) << endl;
1191 os << myRank <<
": remoteLIDsUnion sorted: " << toString (remoteLIDsUnion ()) << endl;
1194 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1197 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1199 std::ostringstream os;
1200 os << myRank <<
": unionTgtGIDs after remotes: "
1201 << toString (unionTgtGIDs ()) << endl;
1204 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1211 const GO indexBaseUnion =
1212 std::min (tgtMap1->getIndexBase (), tgtMap2->getIndexBase ());
1214 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1215 cerr << myRank <<
"Creating union target Map" << endl;
1216 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1223 const GST INVALID = Teuchos::OrdinalTraits<GST>::invalid ();
1224 RCP<const map_type> unionTgtMap =
1225 rcp (
new map_type (INVALID, unionTgtGIDs (), indexBaseUnion,
1226 comm, srcMap->getNode ()));
1228 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1235 cerr << myRank <<
": Computing export IDs and Distributor" << endl;
1236 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1246 Array<GO> exportGIDsUnion;
1247 Array<LO> exportLIDsUnion;
1248 Array<int> exportPIDsUnion;
1249 Distributor distributor (comm, this->out_);
1251 #ifdef TPETRA_IMPORT_SETUNION_USE_CREATE_FROM_SENDS
1259 ArrayView<const LO> exportLIDs1 = this->getExportLIDs ();
1260 ArrayView<const LO> exportPIDs1 = this->getExportPIDs ();
1273 Array<LO> exportLIDs1Copy (exportLIDs1.begin (), exportLIDs1.end ());
1274 Array<int> exportPIDs1Copy (exportLIDs1.begin (), exportLIDs1.end ());
1275 sort2 (exportLIDs1Copy.begin (), exportLIDs1Copy.end (),
1276 exportPIDs1Copy.begin ());
1277 typename ArrayView<LO>::iterator exportLIDs1_end = exportLIDs1Copy.end ();
1278 typename ArrayView<LO>::iterator exportPIDs1_end = exportPIDs1Copy.end ();
1279 merge2 (exportLIDs1_end, exportPIDs1_end,
1280 exportLIDs1Copy.begin (), exportLIDs1_end,
1281 exportPIDs1Copy.begin (), exportPIDs1_end,
1282 project1st<LO, LO> ());
1284 Array<LO> exportLIDs2Copy (exportLIDs2.begin (), exportLIDs2.end ());
1285 Array<int> exportPIDs2Copy (exportLIDs2.begin (), exportLIDs2.end ());
1286 sort2 (exportLIDs2Copy.begin (), exportLIDs2Copy.end (),
1287 exportPIDs2Copy.begin ());
1288 typename ArrayView<LO>::iterator exportLIDs2_end = exportLIDs2Copy.end ();
1289 typename ArrayView<LO>::iterator exportPIDs2_end = exportPIDs2Copy.end ();
1290 merge2 (exportLIDs2_end, exportPIDs2_end,
1291 exportLIDs2Copy.begin (), exportLIDs2_end,
1292 exportPIDs2Copy.begin (), exportPIDs2_end,
1293 project1st<LO, LO> ());
1299 keyValueMerge (exportLIDs1Copy.begin (), exportLIDs1Copy.end (),
1300 exportPIDs1Copy.begin (), exportPIDs1Copy.end (),
1301 exportLIDs2Copy.begin (), exportLIDs2Copy.end (),
1302 exportPIDs2Copy.begin (), exportPIDs2Copy.end (),
1303 std::back_inserter (exportLIDsUnion),
1304 std::back_inserter (exportPIDsUnion),
1305 project1st<int, int> ());
1308 sort2 (exportPIDsUnion.begin (), exportPIDsUnion.end (),
1309 exportLIDsUnion.begin ());
1315 #else // NOT TPETRA_IMPORT_SETUNION_USE_CREATE_FROM_SENDS
1323 remotePIDsUnion ().getConst (),
1324 exportGIDsUnion, exportPIDsUnion);
1327 const size_type numExportIDsUnion = exportGIDsUnion.size ();
1328 exportLIDsUnion.resize (numExportIDsUnion);
1329 for (size_type k = 0; k < numExportIDsUnion; ++k) {
1330 exportLIDsUnion[k] = srcMap->getLocalElement (exportGIDsUnion[k]);
1332 #endif // TPETRA_IMPORT_SETUNION_USE_CREATE_FROM_SENDS
1334 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1336 std::ostringstream os;
1337 os << myRank <<
": exportGIDsUnion: " << toString (exportGIDsUnion ()) << endl;
1338 os << myRank <<
": exportPIDsUnion: " << toString (exportPIDsUnion ()) << endl;
1339 os << myRank <<
": exportLIDsUnion: " << toString (exportLIDsUnion ()) << endl;
1343 cerr <<
"Creating union Import" << endl;
1344 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1347 RCP<const import_type> unionImport =
1348 rcp (
new import_type (srcMap, unionTgtMap,
1349 as<size_t> (numSameIDsUnion),
1350 permuteToLIDsUnion, permuteFromLIDsUnion,
1351 remoteLIDsUnion, exportLIDsUnion,
1352 exportPIDsUnion, distributor, this->out_));
1353 #ifdef HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1355 cerr <<
"Created union Import; done!" << endl;
1356 #endif // HAVE_TPETRA_IMPORT_SETUNION_EXTRA_DEBUG_OUTPUT
1369 #define TPETRA_IMPORT_INSTANT(LO, GO, NODE) \
1371 template class Import< LO , GO , NODE >;
1373 #endif // TPETRA_IMPORT_DEF_HPP
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getTargetMap() const
The Target Map used to construct this Import object.
void sort3(const IT1 &first1, const IT1 &last1, const IT2 &first2, const IT3 &first3)
Sort the first array, and apply the same permutation to the second and third arrays.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
size_t global_size_t
Global size_t object.
void merge2(IT1 &indResultOut, IT2 &valResultOut, IT1 indBeg, IT1 indEnd, IT2 valBeg, IT2 valEnd)
Merge values in place, additively, with the same index.
Import(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
void keyValueMerge(KeyInputIterType keyBeg1, KeyInputIterType keyEnd1, ValueInputIterType valBeg1, ValueInputIterType valEnd1, KeyInputIterType keyBeg2, KeyInputIterType keyEnd2, ValueInputIterType valBeg2, ValueInputIterType valEnd2, KeyOutputIterType keyOut, ValueOutputIterType valOut, BinaryFunction f)
Merge two sorted (by keys) sequences of unique (key,value) pairs by combining pairs with equal keys...
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
#define TPETRA_ABUSE_WARNING(throw_exception_test, Exception, msg)
Handle an abuse warning, according to HAVE_TPETRA_THROW_ABUSE_WARNINGS and HAVE_TPETRA_PRINT_ABUSE_WA...
Import< LocalOrdinal, GlobalOrdinal, Node > & operator=(const Import< LocalOrdinal, GlobalOrdinal, Node > &Source)
Assignment operator.
Implementation detail of Import and Export.
Sets up and executes a communication plan for a Tpetra DistObject.
size_t createFromSends(const ArrayView< const int > &exportNodeIDs)
Set up Distributor using list of process ranks to which this process will send.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Set parameters.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this process.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
void sort2(const IT1 &first1, const IT1 &last1, const IT2 &first2)
Sort the first array, and apply the resulting permutation to the second array.
Describes a parallel distribution of objects over processes.
Stand-alone utility functions and macros.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getSourceMap() const
The Source Map used to construct this Import object.
size_t getNumSameIDs() const
Number of initial identical IDs.
Distributor & getDistributor() const
The Distributor that this Import object uses to move data.
virtual void print(std::ostream &os) const
Print the Import's data to the given output stream.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
void createFromRecvs(const ArrayView< const Ordinal > &remoteIDs, const ArrayView< const int > &remoteNodeIDs, Array< Ordinal > &exportIDs, Array< int > &exportNodeIDs)
Set up Distributor using list of process ranks from which to receive.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > setUnion(const Import< LocalOrdinal, GlobalOrdinal, Node > &rhs) const
Return the union of this Import and rhs.