All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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_ */
virtual GlobalOrdinal getIndexBase() const
The index base for this Map.
virtual Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this process.
virtual std::string description() const
A simple one-line description of this object.
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
virtual ~BlockedMap()
Destructor.
std::vector< RCP< const Map > > maps_
virtual bool isCompatible(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getFullMap() const
the full map
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
virtual global_size_t getGlobalNumElements() const
The number of elements in this Map.
virtual size_t getNodeNumElements() const
The number of elements belonging to the calling process.
virtual GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
virtual bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
const RCP< Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter(size_t i) const
get the importer between full map and partial map
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 void assign(const BlockedMap &input)
Implementation of the assignment operator (operator=); does a deep copy.
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.
virtual bool isSameAs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
virtual LocalOrdinal getMinLocalIndex() const
The minimum local index.
size_t getNumMaps() const
number of partial maps
virtual GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
virtual LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
virtual bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on this process.
BlockedMap< LocalOrdinal, GlobalOrdinal, Node > & operator=(const BlockedMap &rhs)
Assignment operator: Does a deep copy.
size_t global_size_t
Global size_t object.
static const EVerbosityLevel verbLevel_default
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 UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
virtual GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
std::vector< RCP< Import > > importers_
virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
virtual LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
virtual bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
virtual bool isContiguous() const
True if this Map is distributed contiguously, else false.
virtual GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
size_t getMapIndexForGID(GlobalOrdinal gid) const
returns map index in map extractor which contains GID
std::vector< RCP< const Map > > thyraMaps_
virtual bool getThyraMode() const
Local number of rows on the calling process.
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.