Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_Map_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 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_MAP_DECL_HPP
47 #define XPETRA_MAP_DECL_HPP
48 
49 #include "Xpetra_ConfigDefs.hpp"
50 
51 #include <Tpetra_KokkosCompat_DefaultNode.hpp>
52 #include <Teuchos_Describable.hpp>
53 
54 #ifdef HAVE_XPETRA_EPETRA
55 #include "Epetra_config.h"
56 #endif
57 
58 #ifdef HAVE_XPETRA_TPETRA
59 #include <Tpetra_Map.hpp>
60 #endif
61 
62 namespace Xpetra {
63 
64 // TODO move this typedef to another place
65 // Node which is used for Epetra. This can be either the
66 // Serial node or OpenMP node (but not both)
67 #ifdef HAVE_XPETRA_EPETRA
68 #ifdef EPETRA_HAVE_OMP
69 typedef Tpetra::KokkosCompat::KokkosOpenMPWrapperNode EpetraNode;
70 #else
71 typedef Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode;
72 #endif
73 #endif
74 
79 };
80 
81 template <class LocalOrdinal,
82  class GlobalOrdinal,
83  class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
84 class Map
85  : public Teuchos::Describable {
86  public:
87  typedef LocalOrdinal local_ordinal_type;
88  typedef GlobalOrdinal global_ordinal_type;
89  typedef Node node_type;
90 
91  typedef Kokkos::View<const global_ordinal_type *, typename Node::device_type> global_indices_array_device_type;
92 
94 
95 
97  virtual ~Map();
98 
100 
102 
103 
105  virtual global_size_t getGlobalNumElements() const = 0;
106 
108  virtual size_t getLocalNumElements() const = 0;
109 
111  virtual GlobalOrdinal getIndexBase() const = 0;
112 
114  virtual LocalOrdinal getMinLocalIndex() const = 0;
115 
117  virtual LocalOrdinal getMaxLocalIndex() const = 0;
118 
120  virtual GlobalOrdinal getMinGlobalIndex() const = 0;
121 
123  virtual GlobalOrdinal getMaxGlobalIndex() const = 0;
124 
126  virtual GlobalOrdinal getMinAllGlobalIndex() const = 0;
127 
129  virtual GlobalOrdinal getMaxAllGlobalIndex() const = 0;
130 
132  virtual LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const = 0;
133 
135  virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const = 0;
136 
138  virtual LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList,
139  const Teuchos::ArrayView<int> &nodeIDList,
140  const Teuchos::ArrayView<LocalOrdinal> &LIDList) const = 0;
141 
143  virtual LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> &GIDList,
144  const Teuchos::ArrayView<int> &nodeIDList) const = 0;
145 
147  virtual Teuchos::ArrayView<const GlobalOrdinal> getLocalElementList() const = 0;
148 
151 
153 
155 
156 
158  virtual bool isNodeLocalElement(LocalOrdinal localIndex) const = 0;
159 
161  virtual bool isNodeGlobalElement(GlobalOrdinal globalIndex) const = 0;
162 
164  virtual bool isContiguous() const = 0;
165 
167  virtual bool isDistributed() const = 0;
168 
170  virtual bool isCompatible(const Map<LocalOrdinal, GlobalOrdinal, Node> &map) const = 0;
171 
173  virtual bool isSameAs(const Map<LocalOrdinal, GlobalOrdinal, Node> &map) const = 0;
174 
176 
178 
179 
181  virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const = 0;
182 
184 
186 
187 
189  virtual std::string description() const = 0;
190 
192  virtual void describe(Teuchos::FancyOStream &out,
193  const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const = 0;
194 
196 
198 
199 
201  virtual RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > removeEmptyProcesses() const = 0;
202 
204  virtual RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
205  replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int> > &newComm) const = 0;
206 
208 
210 
211 
213  virtual UnderlyingLib lib() const = 0;
214 
215  // TODO: find a better solution for this hack
216  // The problem is that EpetraMap, TpetraMap and StridedMap all inherit Map. To have proper toEpetra() we
217  // need to understand the type of underlying matrix. But in src/Map we have no knowledge of StridedMaps, so
218  // we cannot check for it by casting. This function allows us to avoid the restriction, as StridedMap redefines
219  // it to return the base map.
220  virtual RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const;
221 
222 #ifdef HAVE_XPETRA_TPETRA
223  typedef typename Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>::local_map_type local_map_type;
224 
226  virtual local_map_type getLocalMap() const = 0;
227 #endif
228 
230 
231 }; // Map class
232 
233 } // namespace Xpetra
234 
235 #define XPETRA_MAP_SHORT
236 #endif // XPETRA_MAP_DECL_HPP
virtual LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const =0
Return the process ranks and corresponding local indices for the given global indices.
virtual RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const =0
Return a new Map with processes with zero elements removed.
LocalOrdinal local_ordinal_type
virtual bool isDistributed() const =0
Whether this Map is globally distributed or locally replicated.
virtual LocalOrdinal getMinLocalIndex() const =0
The minimum local index.
GlobalOrdinal global_ordinal_type
virtual bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const =0
True if and only if map is compatible with this Map.
Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node >::local_map_type local_map_type
virtual global_indices_array_device_type getMyGlobalIndicesDevice() const =0
Return a view of the global indices owned by this process on the Map&#39;s device.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const =0
Get this Map&#39;s Comm object.
virtual size_t getLocalNumElements() const =0
The number of elements belonging to the calling process.
virtual GlobalOrdinal getMinAllGlobalIndex() const =0
The minimum global index over all processes in the communicator.
virtual LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const =0
The local index corresponding to the given global index.
virtual GlobalOrdinal getMinGlobalIndex() const =0
The minimum global index owned by the calling process.
virtual GlobalOrdinal getIndexBase() const =0
The index base for this Map.
virtual Teuchos::ArrayView< const GlobalOrdinal > getLocalElementList() const =0
Return a view of the global indices owned by this process.
virtual RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
virtual bool isNodeGlobalElement(GlobalOrdinal globalIndex) const =0
Whether the given global index is valid for this Map on this process.
virtual GlobalOrdinal getMaxGlobalIndex() const =0
The maximum global index owned by the calling process.
virtual GlobalOrdinal getMaxAllGlobalIndex() const =0
The maximum global index over all processes in the communicator.
virtual local_map_type getLocalMap() const =0
Get the local Map for Kokkos kernels.
virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const =0
The global index corresponding to the given local index.
virtual LocalOrdinal getMaxLocalIndex() const =0
The maximum local index on the calling process.
size_t global_size_t
Global size_t object.
Kokkos::View< const global_ordinal_type *, typename Node::device_type > global_indices_array_device_type
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
virtual bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const =0
True if and only if map is identical to this Map.
virtual bool isNodeLocalElement(LocalOrdinal localIndex) const =0
Whether the given local index is valid for this Map on this process.
virtual global_size_t getGlobalNumElements() const =0
The number of elements in this Map.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const =0
Print this object with the given verbosity level to the given Teuchos::FancyOStream.
virtual bool isContiguous() const =0
True if this Map is distributed contiguously, else false.
virtual RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const =0
Replace this Map&#39;s communicator with a subset communicator.
virtual ~Map()
Destructor.
virtual UnderlyingLib lib() const =0
Get the library used by this object (Tpetra or Epetra?)
virtual std::string description() const =0
Return a simple one-line description of this object.