47 #ifndef PACKAGES_XPETRA_SUP_BLOCKEDMAP_XPETRA_BLOCKEDMAP_HPP_ 48 #define PACKAGES_XPETRA_SUP_BLOCKEDMAP_XPETRA_BLOCKEDMAP_HPP_ 58 #ifndef DOXYGEN_SHOULD_SKIP_THIS 61 template<
class LO,
class GO,
class N>
class MapFactory;
64 template <class LocalOrdinal = Map<>::local_ordinal_type,
68 :
public Map< LocalOrdinal, GlobalOrdinal, Node >
76 #undef XPETRA_BLOCKEDMAP_SHORT 105 if(bThyraMode ==
false) {
110 size_t numAllElements = 0;
111 for(
size_t v = 0; v < maps.size(); ++v) {
112 numAllElements += maps[v]->getGlobalNumElements();
115 "logic error. full map and sub maps have not same number of elements. We cannot build MapExtractor with Xpetra-style numbering. Please make sure that you want Xpetra-style numbering instead of Thyra-style numbering.");
125 for(
size_t v = 0; v < maps.size(); ++v) {
127 "logic error. When using Thyra-style numbering all sub-block maps must start with zero as GID. Map block " << v <<
" starts with GID " << maps[v]->
getMinAllGlobalIndex());
134 std::vector<GlobalOrdinal> gidOffsets(maps.size(),0);
135 for(
size_t v = 1; v < maps.size(); ++v) {
136 gidOffsets[v] = maps[v-1]->getMaxAllGlobalIndex() + gidOffsets[v-1] + 1;
140 maps_.resize(maps.size());
141 std::vector<GlobalOrdinal> fullMapGids;
143 for(
size_t v = 0; v < maps.size(); ++v) {
144 size_t myNumElements = maps[v]->getNodeNumElements();
145 std::vector<GlobalOrdinal> subMapGids(myNumElements,0);
146 for (LocalOrdinal l = 0; l < Teuchos::as<LocalOrdinal>(myNumElements); ++l) {
147 GlobalOrdinal myGid = maps[v]->getGlobalElement(l);
148 subMapGids[l] = myGid + gidOffsets[v];
149 fullMapGids.push_back(myGid + gidOffsets[v]);
170 size_t numAllElements = 0;
171 for(
size_t v = 0; v <
maps_.size(); ++v) {
172 numAllElements +=
maps_[v]->getGlobalNumElements();
175 "logic error. full map and sub maps have not same number of elements. This cannot be. Please report the bug to the Xpetra developers!");
180 for (
unsigned i = 0; i <
maps_.size(); ++i)
184 "logic error. full map and sub maps are inconsistently distributed over the processors.");
193 TEUCHOS_TEST_FOR_EXCEPTION(thyramaps.size() != maps.size(), std::logic_error,
"logic error. The number of submaps must be identical!");
194 for(
size_t v = 0; v < thyramaps.size(); ++v) {
196 "logic error. When using Thyra-style numbering all sub-block maps must start with zero as GID.");
198 "logic error. The size of the submaps must be identical (same distribution, just different GIDs)");
208 size_t numAllElements = 0;
209 for(
size_t v = 0; v <
maps_.size(); ++v) {
210 numAllElements +=
maps_[v]->getGlobalNumElements();
213 "logic error. full map and sub maps have not same number of elements. This cannot be. Please report the bug to the Xpetra developers!");
217 for (
unsigned i = 0; i <
maps_.size(); ++i)
221 "logic error. full map and sub maps are inconsistently distributed over the processors.");
237 for(
size_t v = 0; v <
maps_.size(); ++v) {
238 maps_[v] = Teuchos::null;
297 return fullmap_->getNodeElementList();
324 if(rcpBMap.
is_null() ==
true)
return false;
326 for(
size_t v = 0; v <
maps_.size(); ++v) {
327 bool bSame =
getMap(v,
false)->isCompatible(*(rcpBMap->getMap(v,
false)));
328 if (bSame ==
false)
return false;
330 bSame =
getMap(v,
true)->isCompatible(*(rcpBMap->getMap(v,
true)));
340 if(rcpBMap.
is_null() ==
true) {
349 for(
size_t v = 0; v <
maps_.size(); ++v) {
350 bool bSame =
getMap(v,
false)->isSameAs(*(rcpBMap->getMap(v,
false)));
351 if (bSame ==
false)
return false;
353 bSame =
getMap(v,
true)->isSameAs(*(rcpBMap->getMap(v,
true)));
354 if (bSame ==
false)
return false;
452 "BlockedMap::getMap: cannot return sub map in Thyra-style numbering if BlockedMap object is not created using Thyra-style numbered submaps.");
468 if (
getMap(i)->isNodeGlobalElement(gid) ==
true)
472 "getMapIndexForGID: GID " << gid <<
" is not contained by a map in mapextractor." );
483 return std::string(
"BlockedMap");
488 out <<
"------------- Blocked Map -----------" << std::endl;
491 out <<
"No of submaps: " <<
getNumMaps() << std::endl;
494 std::cout <<
"MAP " << r <<
"/" <<
getNumMaps() - 1 << std::endl;
495 getMap(r,
false)->describe(out, verbLevel);
499 std::cout <<
"Thyra MAP " << r <<
"/" <<
getNumMaps() - 1 << std::endl;
500 getMap(r,
true)->describe(out, verbLevel);
503 out <<
"-------------------------------------" << std::endl;
522 for(
size_t i = 0; i < input.
getNumMaps(); ++i) {
529 size_t numAllElements = 0;
530 for(
size_t v = 0; v <
maps_.size(); ++v) {
531 numAllElements +=
maps_[v]->getGlobalNumElements();
534 "logic error. full map and sub maps have not same number of elements. This cannot be. Please report the bug to the Xpetra developers!");
538 for (
unsigned i = 0; i <
maps_.size(); ++i)
539 if (
maps_[i] != null)
542 "logic error. full map and sub maps are inconsistently distributed over the processors.");
562 std::vector<GlobalOrdinal> gids;
563 for(
size_t tt = 0; tt<subMaps.size(); ++tt) {
567 gids.insert(gids.end(), subMapGids.
begin(), subMapGids.
end());
569 size_t myNumElements = subMap->getNodeNumElements();
570 for(LocalOrdinal l = 0; l < Teuchos::as<LocalOrdinal>(myNumElements); ++l) {
571 GlobalOrdinal gid = subMap->getGlobalElement(l);
594 if (fullMap->isNodeGlobalElement(*it) ==
false)
610 #define XPETRA_BLOCKEDMAP_SHORT virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
virtual LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const
Return the process ranks for the given global indices.
static RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target)
Constructor specifying the number of non-zeros for all rows.
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, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with Xpetra-defined contiguous uniform distribution.
virtual size_t getNodeNumElements() const
The number of elements belonging to the calling process.
size_t getNumMaps() const
number of partial maps
GlobalOrdinal global_ordinal_type
virtual bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
const_pointer const_iterator
size_t getMapIndexForGID(GlobalOrdinal gid) const
returns map index in map extractor which contains GID
std::vector< RCP< const Map > > maps_
virtual GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
Exception throws to report errors in the internal logical of the program.
virtual LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
virtual bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on this process.
virtual Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this process.
const RCP< const Map > getMap(size_t i, bool bThyraMode=false) const
virtual LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
virtual 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.
virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
virtual Teuchos::RCP< Node > getNode() const
Get this Map's Node object.
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
BlockedMap(const std::vector< RCP< const Map > > &maps, const std::vector< RCP< const Map > > &thyramaps)
Expert constructor for Thyra maps.
RCP< const Map > fullmap_
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
virtual ~BlockedMap()
Destructor.
bool CheckConsistency() const
GlobalOrdinal global_ordinal_type
virtual bool getThyraMode() const
Local number of rows on the calling process.
virtual global_size_t getGlobalNumElements() const
The number of elements in this Map.
std::vector< RCP< Import > > importers_
virtual void assign(const BlockedMap &input)
Implementation of the assignment operator (operator=); does a deep copy.
virtual bool isContiguous() const
True if this Map is distributed contiguously, else false.
size_t global_size_t
Global size_t object.
static const EVerbosityLevel verbLevel_default
virtual std::string description() const
A simple one-line description of this object.
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 LocalOrdinal getMinLocalIndex() const
The minimum local index.
LocalOrdinal local_ordinal_type
#define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
const RCP< const Map > getFullMap() const
the full map
const RCP< Import > getImporter(size_t i) const
get the importer between full map and partial map
virtual GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map's communicator with a subset communicator.
BlockedMap< LocalOrdinal, GlobalOrdinal, Node > & operator=(const BlockedMap &rhs)
Assignment operator: Does a deep copy.
virtual GlobalOrdinal getIndexBase() const
The index base for this Map.
virtual UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
BlockedMap(const RCP< const Map > &fullmap, const std::vector< RCP< const Map > > &maps, bool bThyraMode=false)
virtual bool isSameAs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
std::vector< RCP< const Map > > thyraMaps_
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
virtual GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
BlockedMap(const BlockedMap &input)
copy constructor
virtual bool isCompatible(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
virtual GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.