All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Xpetra_EpetraMap.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 // Jeremie Gaidamour (jngaida@sandia.gov)
40 // Jonathan Hu (jhu@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_EPETRAMAP_HPP
47 #define XPETRA_EPETRAMAP_HPP
48 
49 /* this file is automatically generated - do not edit (see script/epetra.py) */
50 
52 
53 #include "Xpetra_Map.hpp"
54 
55 #include <Epetra_Map.h>
56 #include <Epetra_BlockMap.h>
57 
58 #include "Xpetra_Utils.hpp"
59 #include "Xpetra_EpetraUtils.hpp"
60 
61 #include "Xpetra_ConfigDefs.hpp"
62 
63 namespace Xpetra {
64 
65  // TODO: move that elsewhere
66  const Epetra_Map & toEpetra(const Map<int,int> &);
67  const Epetra_Map & toEpetra(const RCP< const Map<int, int> > &);
68  //const RCP< const Map<int, int> > toXpetra(const RCP< const Epetra_Map > &);
69  const RCP< const Map<int, int> > toXpetra(const Epetra_BlockMap &);
70  //
71 
72  class EpetraMap
73  : public virtual Map<int, int>
74  {
75 
76  typedef int LocalOrdinal;
77  typedef int GlobalOrdinal;
79 
80  public:
81 
83 
84 
87 
89  EpetraMap(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode());
90 
93 
95 
97 
98 
100  global_size_t getGlobalNumElements() const { XPETRA_MONITOR("EpetraMap::getGlobalNumElements"); return map_->NumGlobalElements(); }
101 
103  size_t getNodeNumElements() const { XPETRA_MONITOR("EpetraMap::getNodeNumElements"); return map_->NumMyElements(); }
104 
106  GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("EpetraMap::getIndexBase"); return map_->IndexBase(); }
107 
109  LocalOrdinal getMinLocalIndex() const { XPETRA_MONITOR("EpetraMap::getMinLocalIndex"); return map_->MinLID(); }
110 
112  LocalOrdinal getMaxLocalIndex() const { XPETRA_MONITOR("EpetraMap::getMaxLocalIndex"); return map_->MaxLID(); }
113 
115  GlobalOrdinal getMinGlobalIndex() const { XPETRA_MONITOR("EpetraMap::getMinGlobalIndex"); return map_->MinMyGID(); }
116 
118  GlobalOrdinal getMaxGlobalIndex() const { XPETRA_MONITOR("EpetraMap::getMaxGlobalIndex"); return map_->MaxMyGID(); }
119 
121  GlobalOrdinal getMinAllGlobalIndex() const { XPETRA_MONITOR("EpetraMap::getMinAllGlobalIndex"); return map_->MinAllGID(); }
122 
124  GlobalOrdinal getMaxAllGlobalIndex() const { XPETRA_MONITOR("EpetraMap::getMaxAllGlobalIndex"); return map_->MaxAllGID(); }
125 
127  LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMap::getLocalElement"); return map_->LID(globalIndex); }
128 
131 
134 
137 
139 
141 
142 
144  bool isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("EpetraMap::isNodeLocalElement"); return map_->MyLID(localIndex); }
145 
147  bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMap::isNodeGlobalElement"); return map_->MyGID(globalIndex); }
148 
150  bool isContiguous() const { XPETRA_MONITOR("EpetraMap::isContiguous"); return map_->LinearMap(); }
151 
153  bool isDistributed() const { XPETRA_MONITOR("EpetraMap::isDistributed"); return map_->DistributedGlobal(); }
154 
156  bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMap::isCompatible"); return map_->PointSameAs(toEpetra(map)); }
157 
159  bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMap::isSameAs"); return map_->SameAs(toEpetra(map)); }
160 
162 
164 
165 
167  const Teuchos::RCP< const Teuchos::Comm< int > > getComm() const { XPETRA_MONITOR("EpetraMap::getComm"); return toXpetra(map_->Comm()); }
168 
170  const Teuchos::RCP< Node > getNode() const;
171 
172 
174  const Epetra_BlockMap * NewMap = map_->RemoveEmptyProcesses();
175  if(!NewMap) return Teuchos::null;
176  else return toXpetra(*NewMap);
177  }
178 
180  throw std::runtime_error("Xpetra::EpetraMap::replaceCommWithSubset has not yet been implemented.");
181  return Teuchos::null;
182  }
183 
184 
186 
188 
189 
191  std::string description() const;
192 
195 
197 
200  XPETRA_MONITOR("EpetraMap::getGlobalElement");
201 
202  GlobalOrdinal gid = map_->GID(localIndex);
203  if (gid == map_->IndexBase()-1) return (-1);
204  else return (gid);
205  }
206 
208 
209 
211  virtual ~EpetraMap() { } // virtual because EpetraMap used as a base class of EpetraStridedMap
212 
215  : map_(map) { }
216 
218  UnderlyingLib lib() const { return Xpetra::UseEpetra; }
219 
221  //const RCP< const Epetra_Map > & getEpetra_Map() const { return map_; }
222  const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
223  const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
224 
226 
227  protected:
228 
230  //const RCP< const Epetra_BlockMap > map_;
231  //const RCP< const Epetra::Map< LocalOrdinal, GlobalOrdinal, Node > > map_;
232 
233  }; // EpetraMap class
234 
235 } // Xpetra namespace
236 
237 #endif // XPETRA_EPETRAMAP_HPP
std::string description() const
Return a simple one-line description of this object.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
Return the process IDs and corresponding local IDs for the given global IDs.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
Return the global index for a given local index. Note that this returns -1 if not found on this proce...
const Teuchos::RCP< Node > getNode() const
Get this Map&#39;s Node object.
static Teuchos::RCP< DefaultNodeType > getDefaultNode()
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this node.
RCP< const Epetra_BlockMap > map_
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, int > > &graph)
virtual ~EpetraMap()
Destructor.
size_t getNodeNumElements() const
The number of elements belonging to the calling node.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
bool isNodeLocalElement(LocalOrdinal localIndex) const
True if the local index is valid for this Map on this node, else false.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print this object with the given verbosity level to the given FancyOStream.
EpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode())
Constructor with Tpetra-defined contiguous uniform distribution.
size_t global_size_t
Global size_t object.
static const EVerbosityLevel verbLevel_default
UnderlyingLib lib() const
Get the library used by this object (Epetra or Epetra?)
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
True if the global index is found in this Map on this node, else false.
const Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map&#39;s Comm object.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
Kokkos::DefaultNode::DefaultNodeType Node
LocalOrdinal getMinLocalIndex() const
The minimum local index.
#define XPETRA_MONITOR(funcName)
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
GlobalOrdinal getIndexBase() const
The index base for this Map.
EpetraMap(const Teuchos::RCP< const Epetra_BlockMap > &map)
EpetraMap constructor to wrap a Epetra_Map object.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > > toXpetra(RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > >)
Convert an Epetra_Comm.to a Teuchos_Comm.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
const Epetra_Map & getEpetra_Map() const
const Epetra_BlockMap & getEpetra_BlockMap() const
Get the underlying Epetra map.