All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Xpetra_BlockedMap.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Tobias Wiesner (tawiesn@sandia.gov)
42 // Ray Tuminaro (rstumin@sandia.gov)
43 //
44 // ***********************************************************************
45 //
46 // @HEADER
47 #ifndef PACKAGES_XPETRA_SUP_BLOCKEDMAP_XPETRA_BLOCKEDMAP_HPP_
48 #define PACKAGES_XPETRA_SUP_BLOCKEDMAP_XPETRA_BLOCKEDMAP_HPP_
49 
50 #include "Xpetra_ConfigDefs.hpp"
51 #include "Xpetra_Map.hpp"
52 //#include "Xpetra_MapFactory.hpp"
53 #include "Xpetra_ImportFactory.hpp"
54 //#include "Xpetra_MapUtils.hpp"
55 
56 namespace Xpetra {
57 
58 #ifndef DOXYGEN_SHOULD_SKIP_THIS
59  // forward declaration of Vector, needed to prevent circular inclusions
60 // template<class S, class LO, class GO, class N> class Vector;
61  template<class LO, class GO, class N> class MapFactory;
62 #endif
63 
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>
67  class BlockedMap
68  : public Map< LocalOrdinal, GlobalOrdinal, Node >
69  {
70  public:
71  typedef LocalOrdinal local_ordinal_type;
72  typedef GlobalOrdinal global_ordinal_type;
73  typedef Node node_type;
74 
75  private:
76 #undef XPETRA_BLOCKEDMAP_SHORT
78 
79  public:
81 
82 
84 
87  bThyraMode_ = false;
88  }
89 
102  BlockedMap(const RCP<const Map>& fullmap, const std::vector<RCP<const Map> >& maps, bool bThyraMode = false) {
103  bThyraMode_ = bThyraMode;
104 
105  if(bThyraMode == false) {
106  // use Xpetra-style numbering for sub-block maps
107  // That is, all sub-block maps have unique GIDs which may not be contiguous and start with GIDs different than zero.
108 
109  // plausibility check
110  size_t numAllElements = 0;
111  for(size_t v = 0; v < maps.size(); ++v) {
112  numAllElements += maps[v]->getGlobalNumElements();
113  }
114  TEUCHOS_TEST_FOR_EXCEPTION(fullmap->getGlobalNumElements() != numAllElements, std::logic_error,
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.");
116 
117  fullmap_ = fullmap;
118  maps_ = maps;
119  } else {
120  //std::cout << "Create Map Extractor in Thyra Mode!!! " << std::endl;
121  // use Thyra-style numbering for sub-block maps
122  // That is, all sub-block maps start with zero as GID and are contiguous
123 
124  // plausibility check
125  for(size_t v = 0; v < maps.size(); ++v) {
126  TEUCHOS_TEST_FOR_EXCEPTION(maps[v]->getMinAllGlobalIndex() != 0, std::logic_error,
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());
128  }
129 
130  // store submaps in Thyra-style ordering
131  thyraMaps_ = maps;
132 
133  // get offsets
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;
137  }
138 
139  // build submaps
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]);
150  }
151  //std::sort(subMapGids.begin(), subMapGids.end());
152  //subMapGids.erase(std::unique(subMapGids.begin(), subMapGids.end()), subMapGids.end());
153 
154  Teuchos::ArrayView<GlobalOrdinal> subMapGidsView(&subMapGids[0], subMapGids.size());
155  Teuchos::RCP<Map> mySubMap = Xpetra::MapFactory<LocalOrdinal,GlobalOrdinal,Node>::Build(maps[v]->lib(), INVALID, subMapGidsView, maps[v]->getIndexBase(), maps[v]->getComm());
156  maps_[v] = mySubMap;
157  }
158 
159  //const GO INVALID = Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid();
160  //std::sort(coarseMapGids.begin(), coarseMapGids.end());
161  //coarseMapGids.erase(std::unique(coarseMapGids.begin(), coarseMapGids.end()), coarseMapGids.end());
162  //Teuchos::ArrayView<GO> coarseMapGidsView(&coarseMapGids[0], coarseMapGids.size());
163  //std::sort(fullMapGids.begin(), fullMapGids.end());
164  //fullMapGids.erase(std::unique(fullMapGids.begin(), fullMapGids.end()), fullMapGids.end());
165 
166  Teuchos::ArrayView<GlobalOrdinal> fullMapGidsView(&fullMapGids[0], fullMapGids.size());
167  fullmap_ = Xpetra::MapFactory<LocalOrdinal,GlobalOrdinal,Node>::Build(fullmap->lib(), INVALID, fullMapGidsView, fullmap->getIndexBase(), fullmap->getComm());
168 
169  // plausibility check
170  size_t numAllElements = 0;
171  for(size_t v = 0; v < maps_.size(); ++v) {
172  numAllElements += maps_[v]->getGlobalNumElements();
173  }
174  TEUCHOS_TEST_FOR_EXCEPTION(fullmap_->getGlobalNumElements() != numAllElements, std::logic_error,
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!");
176  }
177 
178  // build importers for sub maps
179  importers_.resize(maps_.size());
180  for (unsigned i = 0; i < maps_.size(); ++i)
181  if (maps[i] != null)
183  TEUCHOS_TEST_FOR_EXCEPTION(CheckConsistency() == false, std::logic_error,
184  "logic error. full map and sub maps are inconsistently distributed over the processors.");
185 
186  }
187 
189  BlockedMap(const std::vector<RCP<const Map> >& maps, const std::vector<RCP<const Map> >& thyramaps) {
190  bThyraMode_ = true;
191 
192  // plausibility check
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) {
195  TEUCHOS_TEST_FOR_EXCEPTION(thyramaps[v]->getMinAllGlobalIndex() != 0, std::logic_error,
196  "logic error. When using Thyra-style numbering all sub-block maps must start with zero as GID.");
197  XPETRA_TEST_FOR_EXCEPTION(thyramaps[v]->getNodeNumElements() != maps[v]->getNodeNumElements(), std::logic_error,
198  "logic error. The size of the submaps must be identical (same distribution, just different GIDs)");
199  }
200 
201  // store user-provided maps and thyramaps
202  thyraMaps_ = thyramaps;
203  maps_ = maps;
204 
205  fullmap_ = this->concatenateMaps(maps);
206 
207  // plausibility check
208  size_t numAllElements = 0;
209  for(size_t v = 0; v < maps_.size(); ++v) {
210  numAllElements += maps_[v]->getGlobalNumElements();
211  }
212  TEUCHOS_TEST_FOR_EXCEPTION(fullmap_->getGlobalNumElements() != numAllElements, std::logic_error,
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!");
214 
215  // build importers for sub maps
216  importers_.resize(maps_.size());
217  for (unsigned i = 0; i < maps_.size(); ++i)
218  if (maps[i] != null)
220  TEUCHOS_TEST_FOR_EXCEPTION(CheckConsistency() == false, std::logic_error,
221  "logic error. full map and sub maps are inconsistently distributed over the processors.");
222  }
223 
225  BlockedMap(const BlockedMap& input) {
226  bThyraMode_ = input.getThyraMode();
227  fullmap_ = Teuchos::null;
228  maps_.resize(input.getNumMaps(), Teuchos::null);
229  thyraMaps_.resize(input.getNumMaps(), Teuchos::null);
230  this->assign(input);
231  }
232 
234  virtual ~BlockedMap() {
235 
236  // make sure all RCP's are freed
237  for(size_t v = 0; v < maps_.size(); ++v) {
238  maps_[v] = Teuchos::null;
239  if(bThyraMode_ == true)
240  thyraMaps_[v] = Teuchos::null;
241  importers_[v] = Teuchos::null;
242  }
243 
244  fullmap_ = Teuchos::null;
245  }
246 
248 
249 
251  virtual global_size_t getGlobalNumElements() const { return fullmap_->getGlobalNumElements(); };
252 
254  virtual size_t getNodeNumElements() const { return fullmap_->getNodeNumElements(); };
255 
257  virtual GlobalOrdinal getIndexBase() const { return fullmap_->getIndexBase(); };
258 
260  virtual LocalOrdinal getMinLocalIndex() const { return fullmap_->getMinLocalIndex(); };
261 
263  virtual LocalOrdinal getMaxLocalIndex() const { return fullmap_->getMaxLocalIndex(); };
264 
266  virtual GlobalOrdinal getMinGlobalIndex() const { return fullmap_->getMinGlobalIndex(); };
267 
269  virtual GlobalOrdinal getMaxGlobalIndex() const { return fullmap_->getMaxGlobalIndex(); };
270 
272  virtual GlobalOrdinal getMinAllGlobalIndex() const { return fullmap_->getMinAllGlobalIndex(); };
273 
275  virtual GlobalOrdinal getMaxAllGlobalIndex() const { return fullmap_->getMaxAllGlobalIndex(); };
276 
278  virtual LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { return fullmap_->getLocalElement(globalIndex); };
279 
281  virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const { return fullmap_->getGlobalElement(localIndex); };
282 
284  virtual LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &/* GIDList */, const Teuchos::ArrayView< int > &/* nodeIDList */, const Teuchos::ArrayView< LocalOrdinal > &/* LIDList */) const {
285  throw Xpetra::Exceptions::RuntimeError("BlockedMap::getRemoteIndexList: routine not implemented.");
287  };
288 
290  virtual LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &/* GIDList */, const Teuchos::ArrayView< int > &/* nodeIDList */) const {
291  throw Xpetra::Exceptions::RuntimeError("BlockedMap::getRemoteIndexList: routine not implemented.");
293  };
294 
297  return fullmap_->getNodeElementList();
298  };
299 
301 
303 
304 
306  virtual bool isNodeLocalElement(LocalOrdinal localIndex) const {return fullmap_->isNodeLocalElement(localIndex);};
307 
309  virtual bool isNodeGlobalElement(GlobalOrdinal globalIndex) const {return fullmap_->isNodeGlobalElement(globalIndex);};
310 
312  virtual bool isContiguous() const {
313  throw Xpetra::Exceptions::RuntimeError("BlockedMap::isContiguous: routine not implemented.");
315  };
316 
318  virtual bool isDistributed() const {return fullmap_->isDistributed();};
319 
322  RCP<const Map> rcpMap = Teuchos::rcpFromRef(map);
323  RCP<const BlockedMap> rcpBMap = Teuchos::rcp_dynamic_cast<const BlockedMap>(rcpMap);
324  if(rcpBMap.is_null() == true) return false;
325 
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;
329  if (bThyraMode_) {
330  bSame = getMap(v,true)->isCompatible(*(rcpBMap->getMap(v,true)));
331  }
332  }
333  return true;
334  };
335 
338  RCP<const Map> rcpMap = Teuchos::rcpFromRef(map);
339  RCP<const BlockedMap> rcpBMap = Teuchos::rcp_dynamic_cast<const BlockedMap>(rcpMap);
340  if(rcpBMap.is_null() == true) {
341  // If this is a blocked map with > 1 blocks but "map" is a plain map they can't be the same
342  if (this->getNumMaps() > 1)
343  return false;
344  // special case: this is a single blocked map and "map" is a plain map object
345  bool bSame = getMap(0,bThyraMode_)->isSameAs(*rcpMap);
346  return bSame;
347  }
348 
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;
352  if (bThyraMode_) {
353  bSame = getMap(v,true)->isSameAs(*(rcpBMap->getMap(v,true)));
354  if (bSame == false) return false;
355  }
356  }
357  return true;
358  };
359 
361 
363 
364 
366  virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const { return fullmap_->getComm(); } ;
367 
368 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
369  virtual Teuchos::RCP< Node > getNode() const { return fullmap_->getNode();};
371 #endif // TPETRA_ENABLE_DEPRECATED_CODE
372 
374 
382  BlockedMap<LocalOrdinal,GlobalOrdinal,Node>&
383  operator= (const BlockedMap& rhs) {
384  assign (rhs); // dispatch to protected virtual method
385  return *this;
386  }
387 
389 
391 
392  /*virtual size_t getLocalLength() const {
394  throw Xpetra::Exceptions::RuntimeError("BlockedMap::getLocalLength: routine not implemented.");
395  return 0;
396  }*/
397 
399  /*virtual global_size_t getGlobalLength() const {
400  throw Xpetra::Exceptions::RuntimeError("BlockedMap::getGlobalLength: routine not implemented.");
401  return 0;
402  }*/
403 
405  virtual bool getThyraMode() const {
406  return bThyraMode_;
407  }
409 
412 
415  throw Xpetra::Exceptions::RuntimeError("BlockedMap::removeEmptyProcesses: routine not implemented.");
416  }
417 
418 
421  throw Xpetra::Exceptions::RuntimeError("BlockedMap::replaceCommWithSubset: routine not implemented.");
422  }
423 
425 
427 
428 
430  virtual UnderlyingLib lib() const { return fullmap_->lib(); } ;
431 
432  // TODO: find a better solution for this hack
433  // The problem is that EpetraMap, TpetraMap and StridedMap all inherit Map. To have proper toEpetra() we
434  // need to understand the type of underlying matrix. But in src/Map we have no knowledge of StridedMaps, so
435  // we cannot check for it by casting. This function allows us to avoid the restriction, as StridedMap redefines
436  // it to return the base map.
438 
440 
441 
443  size_t getNumMaps() const { return maps_.size(); }
444 
449  const RCP<const Map> getMap(size_t i, bool bThyraMode = false) const {
450  XPETRA_TEST_FOR_EXCEPTION( i >= getNumMaps(), Xpetra::Exceptions::RuntimeError, "BlockedMap::getMap: tried to access block " << i << ", but BlockedMap has only " << getNumMaps() << " blocks! Block indices must be between 0 and " << getNumMaps() - 1 << ".");
451  if(bThyraMode_ == true && bThyraMode == true)
452  return thyraMaps_[i];
454  "BlockedMap::getMap: cannot return sub map in Thyra-style numbering if BlockedMap object is not created using Thyra-style numbered submaps.");
455  return maps_[i];
456  }
457 
459  const RCP<Import> getImporter(size_t i) const {
460  XPETRA_TEST_FOR_EXCEPTION( i >= getNumMaps(), Xpetra::Exceptions::RuntimeError, "BlockedMap::getImporter: tried to access block " << i << ", but BlockedMap has only " << getNumMaps() << " blocks! Block indices must be between 0 and " << getNumMaps() - 1 << ".");
461  return importers_[i];
462  }
463 
465  const RCP<const Map> getFullMap() const { return fullmap_; }
466 
468  size_t getMapIndexForGID(GlobalOrdinal gid) const {
469  for (size_t i = 0; i < getNumMaps(); i++)
470  if (getMap(i)->isNodeGlobalElement(gid) == true)
471  return i;
472 
474  "getMapIndexForGID: GID " << gid << " is not contained by a map in mapextractor." );
475  return 0;
476  }
477 
478 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
479 #ifdef HAVE_XPETRA_TPETRA
482  local_map_type getLocalMap () const {
483  return fullmap_->getLocalMap();
484  }
485 #else
486 #ifdef __GNUC__
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."
488 #endif
489 #endif
490 #endif
491 
493 
495 
496 
498  virtual std::string description() const {
499  return std::string("BlockedMap");
500  }
501 
504  out << "------------- Blocked Map -----------" << std::endl;
505  out << description() << std::endl;
506  out << "Thyra mode: " << getThyraMode() << std::endl;
507  out << "No of submaps: " << getNumMaps() << std::endl;
508  Teuchos::OSTab tab(out);
509  for(size_t r = 0; r < getNumMaps(); r++) {
510  std::cout << "MAP " << r << "/" << getNumMaps() - 1 << std::endl;
511  getMap(r,false)->describe(out, verbLevel);
512  }
513  if(getThyraMode() == true) {
514  for(size_t r = 0; r < getNumMaps(); r++) {
515  std::cout << "Thyra MAP " << r << "/" << getNumMaps() - 1 << std::endl;
516  getMap(r,true)->describe(out, verbLevel);
517  }
518  }
519  out << "-------------------------------------" << std::endl;
520  }
521 
522 
524 
525 
526  protected:
529  virtual void assign (const BlockedMap& input) {
530  // TODO check implementation, simplify copy constructor
531  bThyraMode_ = input.getThyraMode();
532 
534 
535  maps_.resize(input.getNumMaps(), Teuchos::null);
536  if(bThyraMode_ == true)
537  thyraMaps_.resize(input.getNumMaps(), Teuchos::null);
538  for(size_t i = 0; i < input.getNumMaps(); ++i) {
540  if(bThyraMode_ == true)
542  }
543 
544  // plausibility check
545  size_t numAllElements = 0;
546  for(size_t v = 0; v < maps_.size(); ++v) {
547  numAllElements += maps_[v]->getGlobalNumElements();
548  }
549  TEUCHOS_TEST_FOR_EXCEPTION(fullmap_->getGlobalNumElements() != numAllElements, std::logic_error,
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!");
551 
552  // build importers for sub maps
553  importers_.resize(maps_.size());
554  for (unsigned i = 0; i < maps_.size(); ++i)
555  if (maps_[i] != null)
557  TEUCHOS_TEST_FOR_EXCEPTION(CheckConsistency() == false, std::logic_error,
558  "logic error. full map and sub maps are inconsistently distributed over the processors.");
559  }
560 
576 
577  // merge submaps to global map
578  std::vector<GlobalOrdinal> gids;
579  for(size_t tt = 0; tt<subMaps.size(); ++tt) {
581 #if 1
582  Teuchos::ArrayView< const GlobalOrdinal > subMapGids = subMap->getNodeElementList();
583  gids.insert(gids.end(), subMapGids.begin(), subMapGids.end());
584 #else
585  size_t myNumElements = subMap->getNodeNumElements();
586  for(LocalOrdinal l = 0; l < Teuchos::as<LocalOrdinal>(myNumElements); ++l) {
587  GlobalOrdinal gid = subMap->getGlobalElement(l);
588  gids.push_back(gid);
589  }
590 #endif
591  }
592 
593  const GlobalOrdinal INVALID = Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid();
594  //std::sort(gids.begin(), gids.end());
595  //gids.erase(std::unique(gids.begin(), gids.end()), gids.end());
596  Teuchos::ArrayView<GlobalOrdinal> gidsView(&gids[0], gids.size());
598  return fullMap;
599  }
600 
601  private:
602  bool CheckConsistency() const {
603  const RCP<const Map> fullMap = getFullMap();
604 
605  for (size_t i = 0; i < getNumMaps(); i++) {
606  const RCP<const Map> map = getMap(i);
607 
608  ArrayView<const GlobalOrdinal> mapGids = map->getNodeElementList();
609  for (typename ArrayView< const GlobalOrdinal >::const_iterator it = mapGids.begin(); it != mapGids.end(); it++)
610  if (fullMap->isNodeGlobalElement(*it) == false)
611  return false; // Global ID (*it) not found locally on this proc in fullMap -> error
612  }
613  return true;
614  }
615 
616  private:
618  std::vector<RCP<const Map> > maps_;
619  std::vector<RCP<Import > > importers_;
620  bool bThyraMode_; //< boolean flag: use Thyra numbering for local sub-block maps. default = false (for Xpetra mode)
621  std::vector<RCP<const Map> > thyraMaps_; //< store Thyra-style numbering maps here in Thyra mode. In Xpetra mode this vector is empty.
622  }; // BlockedMap class
623 
624 } // Xpetra namespace
625 
626 #define XPETRA_BLOCKEDMAP_SHORT
627 
628 #endif /* PACKAGES_XPETRA_SUP_BLOCKEDMAP_XPETRA_BLOCKEDMAP_HPP_ */
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.
iterator begin() const
GlobalOrdinal GO
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&#39;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.
BlockedMap()
Constructor.
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&#39;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)
iterator end() const
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
bool is_null() const