Xpetra_BlockedMap_decl.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_DECL_HPP_
48 #define PACKAGES_XPETRA_SUP_BLOCKEDMAP_XPETRA_BLOCKEDMAP_DECL_HPP_
49 
50 #include "Xpetra_ConfigDefs.hpp"
51 
52 #include "Xpetra_Import.hpp"
53 #include "Xpetra_Map.hpp"
54 
55 
56 
57 namespace Xpetra {
58 
59 
60 
61 template<class LocalOrdinal,
62  class GlobalOrdinal,
64 class BlockedMap : public Map<LocalOrdinal, GlobalOrdinal, Node>
65 {
66  public:
67 
68  typedef LocalOrdinal local_ordinal_type;
69  typedef GlobalOrdinal global_ordinal_type;
70  typedef Node node_type;
71 
72  private:
73 
74 #undef XPETRA_BLOCKEDMAP_SHORT
76 
77  public:
78 
80 
81 
83 
85  BlockedMap();
86 
87 
105  BlockedMap(const RCP<const Map>& fullmap, const std::vector<RCP<const Map>>& maps, bool bThyraMode = false);
106 
107 
109  BlockedMap(const std::vector<RCP<const Map>>& maps, const std::vector<RCP<const Map>>& thyramaps);
110 
111 
113  BlockedMap(const BlockedMap& input);
114 
115 
117  virtual ~BlockedMap();
118 
119 
121 
122 
124  virtual global_size_t getGlobalNumElements() const;
125 
126 
128  virtual size_t getNodeNumElements() const;
129 
130 
132  virtual GlobalOrdinal getIndexBase() const;
133 
134 
136  virtual LocalOrdinal getMinLocalIndex() const;
137 
138 
140  virtual LocalOrdinal getMaxLocalIndex() const;
141 
142 
144  virtual GlobalOrdinal getMinGlobalIndex() const;
145 
146 
148  virtual GlobalOrdinal getMaxGlobalIndex() const;
149 
150 
152  virtual GlobalOrdinal getMinAllGlobalIndex() const;
153 
154 
156  virtual GlobalOrdinal getMaxAllGlobalIndex() const;
157 
158 
160  virtual LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const;
161 
162 
164  virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const;
165 
166 
169  const Teuchos::ArrayView<int>& /* nodeIDList */,
170  const Teuchos::ArrayView<LocalOrdinal>& /* LIDList */) const;
171 
172 
175  const Teuchos::ArrayView<int>& /* nodeIDList */) const;
176 
177 
180 
181 
183 
184 
186 
187 
189  virtual bool isNodeLocalElement(LocalOrdinal localIndex) const;
190 
192  virtual bool isNodeGlobalElement(GlobalOrdinal globalIndex) const;
193 
195  virtual bool isContiguous() const;
196 
197 
199  virtual bool isDistributed() const;
200 
201 
203  virtual bool isCompatible(const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>& map) const;
204 
205 
207  virtual bool isSameAs(const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>& map) const;
208 
209 
211 
213 
214 
217 
218 
219 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
220  virtual Teuchos::RCP<Node> getNode() const;
222 #endif // TPETRA_ENABLE_DEPRECATED_CODE
223 
224 
226 
227 
236 
237 
239 
240 
242 
243  /*virtual size_t getLocalLength() const {
245  throw Xpetra::Exceptions::RuntimeError("BlockedMap::getLocalLength: routine not implemented.");
246  return 0;
247  }*/
248 
250  /*virtual global_size_t getGlobalLength() const {
251  throw Xpetra::Exceptions::RuntimeError("BlockedMap::getGlobalLength: routine not implemented.");
252  return 0;
253  }*/
254 
255 
257  virtual bool getThyraMode() const;
258 
259 
261 
262 
264 
265 
266 
269 
270 
273  replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int>>& /* newComm */) const;
274 
275 
277 
278 
280 
281 
283  virtual UnderlyingLib lib() const;
284 
285 
286  // TODO: find a better solution for this hack
287  // The problem is that EpetraMap, TpetraMap and StridedMap all inherit Map. To have proper toEpetra() we
288  // need to understand the type of underlying matrix. But in src/Map we have no knowledge of StridedMaps, so
289  // we cannot check for it by casting. This function allows us to avoid the restriction, as StridedMap redefines
290  // it to return the base map.
292  getMap() const;
293 
294 
296 
297 
299  size_t getNumMaps() const;
300 
301 
307  getMap(size_t i, bool bThyraMode = false) const;
308 
309 
312  getImporter(size_t i) const;
313 
314 
317  getFullMap() const;
318 
319 
321  size_t getMapIndexForGID(GlobalOrdinal gid) const;
322 
323 
324 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
325  #ifdef HAVE_XPETRA_TPETRA
327 
329  local_map_type getLocalMap() const { return fullmap_->getLocalMap(); }
330 
331  #else // HAVE_XPETRA_TPETRA
332  #ifdef __GNUC__
333  #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."
334  #endif // __GNUC__
335  #endif // #else !HAVE_XPETRA_TPETRA
336 #endif // HAVE_XPETRA_KOKKOS_REFACTOR
337 
338 
340 
341 
343 
344 
345 
347  virtual std::string description() const;
348 
351 
352 
354 
355 
356  protected:
357 
358 
361  virtual void assign(const BlockedMap& input);
362 
363 
380 
381 
382  private:
383 
384 
385  bool CheckConsistency() const;
386 
387 
388  private:
389 
390 
392  std::vector<RCP<const Map>> maps_;
393  std::vector<RCP<Import>> importers_;
394  bool bThyraMode_; //< boolean flag: use Thyra numbering for local sub-block maps. default = false (for Xpetra mode)
395  std::vector<RCP<const Map>> thyraMaps_; //< store Thyra-style numbering maps here in Thyra mode. In Xpetra mode this vector is empty.
396 }; // BlockedMap class
397 
398 } // namespace Xpetra
399 
400 #define XPETRA_BLOCKEDMAP_SHORT
401 
402 #endif /* PACKAGES_XPETRA_SUP_BLOCKEDMAP_XPETRA_BLOCKEDMAP_DECL_HPP_ */
Xpetra::BlockedMap::CheckConsistency
bool CheckConsistency() const
Definition: Xpetra_BlockedMap_def.hpp:754
Kokkos::Compat::KokkosSerialWrapperNode
Definition: Kokkos_SerialNode.hpp:57
Xpetra::BlockedMap::getMinLocalIndex
virtual LocalOrdinal getMinLocalIndex() const
The minimum local index.
Definition: Xpetra_BlockedMap_def.hpp:291
Xpetra::BlockedMap::local_ordinal_type
LocalOrdinal local_ordinal_type
Definition: Xpetra_BlockedMap_decl.hpp:68
Xpetra::BlockedMap::getNodeNumElements
virtual size_t getNodeNumElements() const
The number of elements belonging to the calling process.
Definition: Xpetra_BlockedMap_def.hpp:273
Xpetra::BlockedMap::operator=
BlockedMap< LocalOrdinal, GlobalOrdinal, Node > & operator=(const BlockedMap &rhs)
Assignment operator: Does a deep copy.
Definition: Xpetra_BlockedMap_def.hpp:517
Xpetra
Xpetra namespace
Definition: Xpetra_BlockedCrsMatrix.hpp:88
Xpetra::global_size_t
size_t global_size_t
Global size_t object.
Definition: Xpetra_ConfigDefs.hpp:174
Xpetra::BlockedMap::global_ordinal_type
GlobalOrdinal global_ordinal_type
Definition: Xpetra_BlockedMap_decl.hpp:69
Xpetra::BlockedMap::getMinAllGlobalIndex
virtual GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
Definition: Xpetra_BlockedMap_def.hpp:327
Xpetra::BlockedMap::isNodeGlobalElement
virtual bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
Definition: Xpetra_BlockedMap_def.hpp:404
Xpetra_Import.hpp
Xpetra::BlockedMap::getLocalElement
virtual LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
Definition: Xpetra_BlockedMap_def.hpp:345
Xpetra::BlockedMap::getImporter
const RCP< Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter(size_t i) const
get the importer between full map and partial map
Definition: Xpetra_BlockedMap_def.hpp:602
Xpetra::BlockedMap::getNodeElementList
virtual Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this process.
Definition: Xpetra_BlockedMap_def.hpp:386
Xpetra::BlockedMap::getIndexBase
virtual GlobalOrdinal getIndexBase() const
The index base for this Map.
Definition: Xpetra_BlockedMap_def.hpp:282
Xpetra::BlockedMap::replaceCommWithSubset
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.
Definition: Xpetra_BlockedMap_def.hpp:543
Xpetra::BlockedMap::describe
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.
Definition: Xpetra_BlockedMap_def.hpp:649
Xpetra::BlockedMap::getThyraMode
virtual bool getThyraMode() const
Local number of rows on the calling process.
Definition: Xpetra_BlockedMap_def.hpp:525
Teuchos::EVerbosityLevel
EVerbosityLevel
Xpetra::BlockedMap::BlockedMap
BlockedMap()
Constructor.
Definition: Xpetra_BlockedMap_def.hpp:64
Xpetra::BlockedMap::isCompatible
virtual bool isCompatible(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
Definition: Xpetra_BlockedMap_def.hpp:432
Xpetra::BlockedMap::thyraMaps_
std::vector< RCP< const Map > > thyraMaps_
Definition: Xpetra_BlockedMap_decl.hpp:395
Xpetra::BlockedMap::isNodeLocalElement
virtual bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on this process.
Definition: Xpetra_BlockedMap_def.hpp:395
Teuchos::ArrayView
Xpetra::Map
Definition: Xpetra_Map_decl.hpp:91
Xpetra::BlockedMap::getMap
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Definition: Xpetra_BlockedMap_def.hpp:560
Teuchos::RCP
Xpetra::BlockedMap::getGlobalNumElements
virtual global_size_t getGlobalNumElements() const
The number of elements in this Map.
Definition: Xpetra_BlockedMap_def.hpp:265
Xpetra::BlockedMap::getNumMaps
size_t getNumMaps() const
number of partial maps
Definition: Xpetra_BlockedMap_def.hpp:569
Xpetra::BlockedMap::getMaxGlobalIndex
virtual GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
Definition: Xpetra_BlockedMap_def.hpp:318
Xpetra::BlockedMap::description
virtual std::string description() const
A simple one-line description of this object.
Definition: Xpetra_BlockedMap_def.hpp:640
Teuchos::basic_FancyOStream
Xpetra::BlockedMap::importers_
std::vector< RCP< Import > > importers_
Definition: Xpetra_BlockedMap_decl.hpp:393
Xpetra::BlockedMap::getFullMap
const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getFullMap() const
the full map
Definition: Xpetra_BlockedMap_def.hpp:616
Xpetra::BlockedMap::isSameAs
virtual bool isSameAs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
Definition: Xpetra_BlockedMap_def.hpp:456
Xpetra::BlockedMap::isContiguous
virtual bool isContiguous() const
True if this Map is distributed contiguously, else false.
Definition: Xpetra_BlockedMap_def.hpp:413
Xpetra::BlockedMap::getRemoteIndexList
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.
Definition: Xpetra_BlockedMap_def.hpp:363
Xpetra::BlockedMap::getMapIndexForGID
size_t getMapIndexForGID(GlobalOrdinal gid) const
returns map index in map extractor which contains GID
Definition: Xpetra_BlockedMap_def.hpp:625
Xpetra_ConfigDefs.hpp
Xpetra_UseShortNamesOrdinal.hpp
Xpetra::BlockedMap::~BlockedMap
virtual ~BlockedMap()
Destructor.
Definition: Xpetra_BlockedMap_def.hpp:247
Xpetra::BlockedMap::fullmap_
RCP< const Map > fullmap_
Definition: Xpetra_BlockedMap_decl.hpp:391
Xpetra::BlockedMap::maps_
std::vector< RCP< const Map > > maps_
Definition: Xpetra_BlockedMap_decl.hpp:392
Xpetra::UnderlyingLib
UnderlyingLib
Definition: Xpetra_Map_decl.hpp:79
Xpetra::BlockedMap::bThyraMode_
bool bThyraMode_
Definition: Xpetra_BlockedMap_decl.hpp:394
Xpetra::BlockedMap::getComm
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
Definition: Xpetra_BlockedMap_def.hpp:496
Xpetra::BlockedMap::getMinGlobalIndex
virtual GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
Definition: Xpetra_BlockedMap_def.hpp:309
Xpetra::BlockedMap::getMaxLocalIndex
virtual LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
Definition: Xpetra_BlockedMap_def.hpp:300
Teuchos::Comm
Xpetra::BlockedMap::getGlobalElement
virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
Definition: Xpetra_BlockedMap_def.hpp:354
Xpetra::BlockedMap::concatenateMaps
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.
Definition: Xpetra_BlockedMap_def.hpp:717
Teuchos::Describable::verbLevel_default
static const EVerbosityLevel verbLevel_default
Xpetra::LookupStatus
LookupStatus
Definition: Xpetra_ConfigDefs.hpp:183
Xpetra::BlockedMap
Definition: Xpetra_BlockedMap_decl.hpp:65
Xpetra::BlockedMap::lib
virtual UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
Definition: Xpetra_BlockedMap_def.hpp:551
Xpetra::BlockedMap::assign
virtual void assign(const BlockedMap &input)
Implementation of the assignment operator (operator=); does a deep copy.
Definition: Xpetra_BlockedMap_def.hpp:676
Xpetra::BlockedMap::isDistributed
virtual bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
Definition: Xpetra_BlockedMap_def.hpp:423
Xpetra::BlockedMap::getMaxAllGlobalIndex
virtual GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
Definition: Xpetra_BlockedMap_def.hpp:336
Xpetra::BlockedMap::node_type
Node node_type
Definition: Xpetra_BlockedMap_decl.hpp:70
Xpetra::BlockedMap::removeEmptyProcesses
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
Definition: Xpetra_BlockedMap_def.hpp:534