53 const Teuchos::RCP <
const Teuchos::Comm<int> > &comm_,
54 const Teuchos::RCP <const MachineRep> &machine_,
55 const Teuchos::RCP <const Adapter> &adapter_,
57 const Teuchos::RCP <const Environment> &envConst):
58 nRanks(comm_->getSize()), myRank(comm_->getRank()),
59 nMyParts(0), myParts(
Teuchos::null)
63 const part_t *partList;
64 if (psoln_ != Teuchos::null) {
65 partList = psoln_->getPartListView();
68 adapter_->getPartsView(partList);
73 part_t minPart, maxPart;
75 if (partList == NULL) {
87 size_t nLocal = adapter_->getLocalNumIDs();
93 typedef Tpetra::Map<>::global_ordinal_type use_this_gno_t;
95 std::set<use_this_gno_t> unique;
96 for (
size_t i = 0; i < nLocal; i++)
97 unique.insert(partList[i]);
99 size_t nUnique = unique.size();
100 Array<use_this_gno_t> uniquePartList(nUnique);
102 for (
typename std::set<use_this_gno_t>::iterator it = unique.begin();
103 it != unique.end(); it++)
104 uniquePartList[k++] = *it;
109 Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid();
110 Tpetra::Map<lno_t, use_this_gno_t> tmap(nGlobalElts, uniquePartList(),
113 nParts = Teuchos::as<part_t>(tmap.getGlobalNumElements());
114 minPart = tmap.getMinAllGlobalIndex();
115 maxPart = tmap.getMaxAllGlobalIndex();
121 if ((minPart != 0) || (maxPart != nParts-1)) {
123 throw std::runtime_error(
"Cannot use mapping_algorithm = contiguous "
124 "unless parts are numbered from 0 to nParts-1");
175 if (myParts == Teuchos::null) {
176 myParts = arcp(
new part_t[nMyParts], 0, nMyParts,
true);
177 for (part_t i = 0; i < nMyParts; i++)
178 myParts[i] = firstPart(myRank) + i;
180 parts = myParts.getRawPtr();