Xpetra Version of the Day
Loading...
Searching...
No Matches
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_decl.hpp"
54
55
56
57namespace Xpetra {
58
59
60
61template<class LocalOrdinal,
62 class GlobalOrdinal,
64class 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 getLocalNumElements() 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
204
205
207 virtual bool isSameAs(const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>& map) const;
208
209
211
213
214
217
218
219
220
222
223
232
233
235
236
238
239
240 /*virtual size_t getLocalLength() const {
241 throw Xpetra::Exceptions::RuntimeError("BlockedMap::getLocalLength: routine not implemented.");
242 return 0;
243 }*/
244
246 /*virtual global_size_t getGlobalLength() const {
247 throw Xpetra::Exceptions::RuntimeError("BlockedMap::getGlobalLength: routine not implemented.");
248 return 0;
249 }*/
250
251
253 virtual bool getThyraMode() const;
254
255
257
258
260
261
262
265
266
269 replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int>>& /* newComm */) const;
270
271
273
274
276
277
279 virtual UnderlyingLib lib() const;
280
281
282 // TODO: find a better solution for this hack
283 // The problem is that EpetraMap, TpetraMap and StridedMap all inherit Map. To have proper toEpetra() we
284 // need to understand the type of underlying matrix. But in src/Map we have no knowledge of StridedMaps, so
285 // we cannot check for it by casting. This function allows us to avoid the restriction, as StridedMap redefines
286 // it to return the base map.
288 getMap() const;
289
290
292
293
295 size_t getNumMaps() const;
296
297
303 getMap(size_t i, bool bThyraMode = false) const;
304
305
308 getImporter(size_t i) const;
309
310
313 getFullMap() const;
314
315
317 size_t getMapIndexForGID(GlobalOrdinal gid) const;
318
319
320 #ifdef HAVE_XPETRA_TPETRA
322
324 local_map_type getLocalMap() const { return fullmap_->getLocalMap(); }
325
326 #else // HAVE_XPETRA_TPETRA
327 #ifdef __GNUC__
328 #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."
329 #endif // __GNUC__
330 #endif // #else !HAVE_XPETRA_TPETRA
331
332
334
335
337
338
339
341 virtual std::string description() const;
342
345
346
348
349
350 protected:
351
352
355 virtual void assign(const BlockedMap& input);
356
357
374
375
376 private:
377
378
379 bool CheckConsistency() const;
380
381
382 private:
383
384
386 std::vector<RCP<const Map>> maps_;
387 std::vector<RCP<Import>> importers_;
388 bool bThyraMode_; //< boolean flag: use Thyra numbering for local sub-block maps. default = false (for Xpetra mode)
389 std::vector<RCP<const Map>> thyraMaps_; //< store Thyra-style numbering maps here in Thyra mode. In Xpetra mode this vector is empty.
390}; // BlockedMap class
391
392} // namespace Xpetra
393
394#define XPETRA_BLOCKEDMAP_SHORT
395
396#endif /* PACKAGES_XPETRA_SUP_BLOCKEDMAP_XPETRA_BLOCKEDMAP_DECL_HPP_ */
static const EVerbosityLevel verbLevel_default
virtual GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
virtual global_size_t getGlobalNumElements() const
The number of elements in this Map.
virtual GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
BlockedMap< LocalOrdinal, GlobalOrdinal, Node > & operator=(const BlockedMap &rhs)
Assignment operator: Does a deep copy.
virtual GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
virtual GlobalOrdinal getIndexBase() const
The index base for this Map.
virtual bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is valid for this Map on this process.
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
const RCP< Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter(size_t i) const
get the importer between full map and partial map
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 Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const
Return a view of the global indices owned by this process.
virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
virtual bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
typename Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
size_t getMapIndexForGID(GlobalOrdinal gid) const
returns map index in map extractor which contains GID
virtual bool isSameAs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
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
std::vector< RCP< const Map > > thyraMaps_
size_t getNumMaps() const
number of partial maps
virtual GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
virtual LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
std::vector< RCP< const Map > > maps_
virtual bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on this process.
std::vector< RCP< Import > > importers_
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
virtual ~BlockedMap()
Destructor.
virtual bool getThyraMode() const
Local number of rows on the calling process.
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 bool isContiguous() const
True if this Map is distributed contiguously, else false.
virtual UnderlyingLib lib() const
Get the library used by this object (Tpetra or Epetra?)
virtual LocalOrdinal getMinLocalIndex() const
The minimum local index.
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 LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
virtual std::string description() const
A simple one-line description of this object.
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
virtual size_t getLocalNumElements() const
The number of elements belonging to the calling process.
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.
Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
Xpetra namespace
size_t global_size_t
Global size_t object.