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,
 
   65             class GlobalOrdinal = 
typename Map<LocalOrdinal>::global_ordinal_type,
 
   66             class Node = 
typename Map<LocalOrdinal, GlobalOrdinal>::node_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 (" << fullmap->getGlobalNumElements() <<
" versus " << numAllElements << 
"). 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;
 
  368 #ifdef TPETRA_ENABLE_DEPRECATED_CODE 
  371 #endif // TPETRA_ENABLE_DEPRECATED_CODE 
  382     BlockedMap<LocalOrdinal,GlobalOrdinal,Node>&
 
  454                  "BlockedMap::getMap: cannot return sub map in Thyra-style numbering if BlockedMap object is not created using Thyra-style numbered submaps.");
 
  470         if (
getMap(i)->isNodeGlobalElement(gid) == 
true)
 
  474                                  "getMapIndexForGID: GID " << gid << 
" is not contained by a map in mapextractor." );
 
  478 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 
  479 #ifdef HAVE_XPETRA_TPETRA 
  482     local_map_type getLocalMap ()
 const {
 
  487 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too." 
  499       return std::string(
"BlockedMap");
 
  504       out << 
"------------- Blocked Map -----------" << std::endl;
 
  507       out << 
"No of submaps: " << 
getNumMaps() << std::endl;
 
  510         std::cout << 
"MAP " << r << 
"/" << 
getNumMaps() - 1 << std::endl;
 
  511         getMap(r,
false)->describe(out, verbLevel);
 
  515           std::cout << 
"Thyra MAP " << r << 
"/" << 
getNumMaps() - 1 << std::endl;
 
  516           getMap(r,
true)->describe(out, verbLevel);
 
  519       out << 
"-------------------------------------" << std::endl;
 
  538       for(
size_t i = 0; i < input.
getNumMaps(); ++i) {
 
  545       size_t numAllElements = 0;
 
  546       for(
size_t v = 0; v < 
maps_.size(); ++v) {
 
  547         numAllElements += 
maps_[v]->getGlobalNumElements();
 
  550                                  "logic error. full map and sub maps have not same number of elements. This cannot be. Please report the bug to the Xpetra developers!");
 
  554       for (
unsigned i = 0; i < 
maps_.size(); ++i)
 
  555         if (
maps_[i] != null)
 
  558                                  "logic error. full map and sub maps are inconsistently distributed over the processors.");
 
  578       std::vector<GlobalOrdinal> gids;
 
  579       for(
size_t tt = 0; tt<subMaps.size(); ++tt) {
 
  583         gids.insert(gids.end(), subMapGids.
begin(), subMapGids.
end());
 
  585         size_t myNumElements = subMap->getNodeNumElements();
 
  586         for(LocalOrdinal l = 0; l < Teuchos::as<LocalOrdinal>(myNumElements); ++l) {
 
  587           GlobalOrdinal gid = subMap->getGlobalElement(l);
 
  610           if (fullMap->isNodeGlobalElement(*it) == 
false)
 
  626 #define XPETRA_BLOCKEDMAP_SHORT 
virtual LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &, const Teuchos::ArrayView< int > &) const 
Return the process ranks for the given global indices. 
 
virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const 
The global index corresponding to the given local index. 
 
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. 
 
virtual GlobalOrdinal getMaxGlobalIndex() const 
The maximum global index owned by the calling process. 
 
bool CheckConsistency() const 
 
virtual global_size_t getGlobalNumElements() const 
The number of elements in this Map. 
 
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. 
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
virtual size_t getNodeNumElements() const 
The number of elements belonging to the calling process. 
 
const_pointer const_iterator
 
virtual bool isDistributed() const 
Whether this Map is globally distributed or locally replicated. 
 
std::vector< RCP< const Map > > maps_
 
virtual LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &, const Teuchos::ArrayView< int > &, const Teuchos::ArrayView< LocalOrdinal > &) const 
Return the process ranks and corresponding local indices for the given global indices. 
 
Exception throws to report errors in the internal logical of the program. 
 
virtual bool isCompatible(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map) const 
True if and only if map is compatible with this Map. 
 
virtual bool isContiguous() const 
True if this Map is distributed contiguously, else false. 
 
virtual std::string description() const 
A simple one-line description of this object. 
 
virtual GlobalOrdinal getMinAllGlobalIndex() const 
The minimum global index over all processes in the communicator. 
 
virtual bool isNodeLocalElement(LocalOrdinal localIndex) const 
Whether the given local index is valid for this Map on this process. 
 
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const 
Get this Map's Comm object. 
 
BlockedMap(const std::vector< RCP< const Map > > &maps, const std::vector< RCP< const Map > > &thyramaps)
Expert constructor for Thyra maps. 
 
const RCP< const Map > getFullMap() const 
the full map 
 
RCP< const Map > fullmap_
 
size_t getNumMaps() const 
number of partial maps 
 
virtual ~BlockedMap()
Destructor. 
 
GlobalOrdinal global_ordinal_type
 
virtual GlobalOrdinal getMaxAllGlobalIndex() const 
The maximum global index over all processes in the communicator. 
 
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const 
Return a new Map with processes with zero elements removed. 
 
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &) const 
Replace this Map's communicator with a subset communicator. 
 
virtual GlobalOrdinal getMinGlobalIndex() const 
The minimum global index owned by the calling process. 
 
std::vector< RCP< Import > > importers_
 
virtual void assign(const BlockedMap &input)
Implementation of the assignment operator (operator=); does a deep copy. 
 
virtual Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const 
Return a view of the global indices owned by this process. 
 
size_t global_size_t
Global size_t object. 
 
static const EVerbosityLevel verbLevel_default
 
const RCP< const Map > getMap(size_t i, bool bThyraMode=false) const 
 
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. 
 
LocalOrdinal local_ordinal_type
 
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
 
const RCP< Import > getImporter(size_t i) const 
get the importer between full map and partial map 
 
#define XPETRA_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. 
 
virtual GlobalOrdinal getIndexBase() const 
The index base for this Map. 
 
virtual LocalOrdinal getMinLocalIndex() const 
The minimum local index. 
 
BlockedMap< LocalOrdinal, GlobalOrdinal, Node > & operator=(const BlockedMap &rhs)
Assignment operator: Does a deep copy. 
 
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const 
 
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 
Get the library used by this object (Tpetra or Epetra?) 
 
size_t getMapIndexForGID(GlobalOrdinal gid) const 
returns map index in map extractor which contains GID 
 
BlockedMap(const RCP< const Map > &fullmap, const std::vector< RCP< const Map > > &maps, bool bThyraMode=false)
 
std::vector< RCP< const Map > > thyraMaps_
 
virtual bool isSameAs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map) const 
True if and only if map is identical to this Map. 
 
virtual LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const 
The local index corresponding to the given global index. 
 
virtual bool getThyraMode() const 
Local number of rows on the calling process. 
 
virtual LocalOrdinal getMaxLocalIndex() const 
The maximum local index on the calling process. 
 
BlockedMap(const BlockedMap &input)
copy constructor