47 #ifndef PACKAGES_XPETRA_SUP_MAP_UTILS_HPP_
48 #define PACKAGES_XPETRA_SUP_MAP_UTILS_HPP_
57 #ifndef DOXYGEN_SHOULD_SKIP_THIS
59 template<
class LO,
class GO,
class N>
class BlockedMap;
69 template <
class LocalOrdinal,
73 #undef XPETRA_MAPUTILS_SHORT
97 std::vector<GlobalOrdinal> gids;
98 for(
size_t tt = 0; tt<subMaps.size(); ++tt) {
101 gids.insert(gids.end(), subMapGids.
begin(), subMapGids.
end());
140 std::vector<int> myGIDs(comm->getSize(),0);
141 std::vector<int> numGIDs(comm->getSize(),0);
144 size_t gidOffset = 0;
145 for(
int p = 0; p < comm->getRank(); p++) gidOffset += numGIDs[p];
148 std::map<const GlobalOrdinal, GlobalOrdinal> origGID2newGID;
150 origGID2newGID[nonOvlInput.
getGlobalElement(i)] = Teuchos::as<GlobalOrdinal>(i) + Teuchos::as<GlobalOrdinal>(gidOffset);
164 std::vector<int> myUnknownDofGIDs(comm->getSize(),0);
165 std::vector<int> numUnknownDofGIDs(comm->getSize(),0);
166 myUnknownDofGIDs[comm->getRank()] = ovlUnknownStatusGids.
size();
170 size_t cntUnknownDofGIDs = 0;
171 for(
int p = 0; p < comm->getSize(); p++) cntUnknownDofGIDs += numUnknownDofGIDs[p];
172 std::vector<GlobalOrdinal> lUnknownDofGIDs(cntUnknownDofGIDs,0);
173 std::vector<GlobalOrdinal> gUnknownDofGIDs(cntUnknownDofGIDs,0);
175 size_t cntUnknownOffset = 0;
176 for(
int p = 0; p < comm->getRank(); p++) cntUnknownOffset += numUnknownDofGIDs[p];
177 for(
size_t k=0; k < Teuchos::as<size_t>(ovlUnknownStatusGids.
size()); k++) {
178 lUnknownDofGIDs[k+cntUnknownOffset] = ovlUnknownStatusGids[k];
180 if(cntUnknownDofGIDs > 0)
182 std::vector<GlobalOrdinal> lTranslatedDofGIDs(cntUnknownDofGIDs,0);
183 std::vector<GlobalOrdinal> gTranslatedDofGIDs(cntUnknownDofGIDs,0);
185 for(
size_t k=0; k < gUnknownDofGIDs.size(); k++) {
186 GlobalOrdinal curgid = gUnknownDofGIDs[k];
188 lTranslatedDofGIDs[k] = origGID2newGID[curgid];
191 if(cntUnknownDofGIDs > 0)
194 for(
size_t k=0; k < Teuchos::as<size_t>(ovlUnknownStatusGids.
size()); k++) {
195 origGID2newGID[ovlUnknownStatusGids[k]] = gTranslatedDofGIDs[k+cntUnknownOffset];
200 ovlDomainMapArray.
push_back(origGID2newGID[gcid]);
235 std::map<const GlobalOrdinal, GlobalOrdinal> thyra2xpetraGID;
252 std::vector<int> myUnknownDofGIDs(comm->getSize(),0);
253 std::vector<int> numUnknownDofGIDs(comm->getSize(),0);
254 myUnknownDofGIDs[comm->getRank()] = ovlUnknownStatusGids.
size();
258 size_t cntUnknownDofGIDs = 0;
259 for(
int p = 0; p < comm->getSize(); p++) cntUnknownDofGIDs += numUnknownDofGIDs[p];
260 std::vector<GlobalOrdinal> lUnknownDofGIDs(cntUnknownDofGIDs,0);
261 std::vector<GlobalOrdinal> gUnknownDofGIDs(cntUnknownDofGIDs,0);
263 size_t cntUnknownOffset = 0;
264 for(
int p = 0; p < comm->getRank(); p++) cntUnknownOffset += numUnknownDofGIDs[p];
265 for(
size_t k=0; k < Teuchos::as<size_t>(ovlUnknownStatusGids.
size()); k++) {
266 lUnknownDofGIDs[k+cntUnknownOffset] = ovlUnknownStatusGids[k];
268 if(cntUnknownDofGIDs > 0)
270 std::vector<GlobalOrdinal> lTranslatedDofGIDs(cntUnknownDofGIDs,0);
271 std::vector<GlobalOrdinal> gTranslatedDofGIDs(cntUnknownDofGIDs,0);
273 for(
size_t k=0; k < gUnknownDofGIDs.size(); k++) {
274 GlobalOrdinal curgid = gUnknownDofGIDs[k];
276 lTranslatedDofGIDs[k] = thyra2xpetraGID[curgid];
279 if(cntUnknownDofGIDs > 0)
282 for(
size_t k=0; k < Teuchos::as<size_t>(ovlUnknownStatusGids.
size()); k++) {
283 thyra2xpetraGID[ovlUnknownStatusGids[k]] = gTranslatedDofGIDs[k+cntUnknownOffset];
288 ovlDomainMapArray.
push_back(thyra2xpetraGID[gcid]);
316 if(rcpBlockedInput.
is_null() ==
true) {
319 std::vector<GlobalOrdinal> gids;
320 for(LocalOrdinal l = 0; l < Teuchos::as<LocalOrdinal>(rcpInput->getNodeNumElements()); ++l) {
321 GlobalOrdinal gid = rcpInput->getGlobalElement(l) + offset;
332 size_t numMaps = rcpBlockedInput->getNumMaps();
336 std::vector<GlobalOrdinal> gidOffsets(numMaps,0);
337 for(
size_t i = 1; i < numMaps; ++i) {
338 gidOffsets[i] = rcpBlockedInput->getMap(i-1,
true)->getMaxAllGlobalIndex() + gidOffsets[i-1] + 1;
341 std::vector<RCP<const Map> > mapsXpetra(rcpBlockedInput->getNumMaps(), Teuchos::null);
342 std::vector<RCP<const Map> > mapsThyra (rcpBlockedInput->getNumMaps(), Teuchos::null);
343 for (
size_t b = 0; b < rcpBlockedInput->getNumMaps(); ++b){
348 mapsXpetra[b] = subMapXpetra;
349 mapsThyra[b] = subMapThyra;
360 #define XPETRA_MAPUTILS_SHORT
362 #endif // PACKAGES_XPETRA_SUP_MAP_UTILS_HPP_
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const =0
Get this Map's Comm object.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual size_t getNodeNumElements() const =0
The number of elements belonging to the calling process.
static Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > concatenateMaps(const std::vector< Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > > &subMaps)
Helper function to concatenate several maps.
virtual bool isNodeGlobalElement(GlobalOrdinal globalIndex) const =0
Whether the given global index is valid for this Map on this process.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static Teuchos::RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > transformThyra2XpetraGIDs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &input, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &nonOvlInput, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &nonOvlReferenceInput)
replace set of global ids by new global ids
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
virtual GlobalOrdinal getMaxAllGlobalIndex() const =0
The maximum global index over all processes in the communicator.
virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const =0
The global index corresponding to the given local index.
static Teuchos::RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > shrinkMapGIDs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &input, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &nonOvlInput)
Helper function to shrink the GIDs and generate a standard map whith GIDs starting at 0...
void push_back(const value_type &x)
Exception throws to report incompatible objects (like maps).
static Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > transformThyra2XpetraGIDs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &input, GlobalOrdinal offset)
replace set of global ids by new global ids
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=Xpetra::GloballyDistributed)
Map constructor with Xpetra-defined contiguous uniform distribution.
virtual UnderlyingLib lib() const =0
Get the library used by this object (Tpetra or Epetra?)