|
Tpetra Matrix/Vector Services Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Tpetra: Templated Linear Algebra Services Package 00005 // Copyright (2008) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef TPETRA_MAP_DECL_HPP 00030 #define TPETRA_MAP_DECL_HPP 00031 00032 #include <Kokkos_DefaultNode.hpp> 00033 #include <Teuchos_Describable.hpp> 00034 00035 // enums and defines 00036 #include "Tpetra_ConfigDefs.hpp" 00037 00043 namespace Tpetra { 00044 00045 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00046 // forward dec 00047 template <class LO, class GO, class N> class Directory; 00048 #endif 00049 00055 template <class LocalOrdinal, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType> 00056 class Map : public Teuchos::Describable { 00057 00058 public: 00059 00061 00062 00068 Map(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 00069 LocalGlobal lg=GloballyDistributed, const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode()); 00070 00080 Map(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, 00081 const Teuchos::RCP<const Teuchos::Comm<int> > &comm, const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode()); 00082 00083 00091 Map(global_size_t numGlobalElements, const Teuchos::ArrayView<const GlobalOrdinal> &elementList, GlobalOrdinal indexBase, 00092 const Teuchos::RCP<const Teuchos::Comm<int> > &comm, const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode()); 00093 00095 ~Map(); 00096 00098 00099 00101 00102 00104 inline global_size_t getGlobalNumElements() const { return numGlobalElements_; } 00105 00107 inline size_t getNodeNumElements() const { return numLocalElements_; } 00108 00110 inline GlobalOrdinal getIndexBase() const { return indexBase_; } 00111 00113 inline LocalOrdinal getMinLocalIndex() const { return Teuchos::OrdinalTraits<LocalOrdinal>::zero(); } 00114 00116 inline LocalOrdinal getMaxLocalIndex() const { return Teuchos::as<LocalOrdinal>(numLocalElements_-1); } 00117 00119 inline GlobalOrdinal getMinGlobalIndex() const { return minMyGID_; } 00120 00122 inline GlobalOrdinal getMaxGlobalIndex() const { return maxMyGID_; } 00123 00125 inline GlobalOrdinal getMinAllGlobalIndex() const { return minAllGID_; } 00126 00128 inline GlobalOrdinal getMaxAllGlobalIndex() const { return maxAllGID_; } 00129 00131 00132 LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const; 00133 00135 00136 GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const; 00137 00139 00143 LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 00144 const Teuchos::ArrayView< int> & nodeIDList, 00145 const Teuchos::ArrayView< LocalOrdinal> & LIDList) const; 00146 00148 00152 LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 00153 const Teuchos::ArrayView< int> & nodeIDList) const; 00154 00156 Teuchos::ArrayView<const GlobalOrdinal> getNodeElementList() const; 00157 00159 bool isNodeLocalElement(LocalOrdinal localIndex) const; 00160 00162 bool isNodeGlobalElement(GlobalOrdinal globalIndex) const; 00163 00165 bool isContiguous() const; 00166 00168 bool isDistributed() const; 00169 00171 00173 00174 00176 bool isCompatible (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const; 00177 00179 bool isSameAs (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const; 00180 00182 00184 00186 const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const; 00187 00189 const Teuchos::RCP<Node> & getNode() const; 00190 00192 00194 00196 std::string description() const; 00197 00199 void describe( Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const; 00200 00202 00203 00204 private: 00205 00207 void setupDirectory(); 00208 00210 bool checkIsDist() const; 00211 00213 Map(const Map<LocalOrdinal,GlobalOrdinal,Node> & source); 00214 00216 Map<LocalOrdinal,GlobalOrdinal,Node>& operator=(const Map<LocalOrdinal,GlobalOrdinal,Node> & source); 00217 00218 // some of the following are globally coherent: that is, they have been guaranteed to 00219 // match across all images, and may be assumed to do so 00220 Teuchos::RCP<const Teuchos::Comm<int> > comm_; 00221 00222 // Map doesn't need node yet, but it likely will later. In the meantime, passing a Node to Map means that we don't have to 00223 // pass a Node to downstream classes such as MultiVector, Vector, CrsGraph and CrsMatrix 00224 Teuchos::RCP<Node> node_; 00225 00226 // The based for global IDs in this Map. 00227 GlobalOrdinal indexBase_; 00229 global_size_t numGlobalElements_; 00231 size_t numLocalElements_; 00233 GlobalOrdinal minMyGID_, maxMyGID_; 00235 GlobalOrdinal minAllGID_, maxAllGID_; 00237 bool contiguous_; 00239 bool distributed_; 00241 mutable Teuchos::ArrayRCP<GlobalOrdinal> lgMap_; 00243 std::map<GlobalOrdinal, LocalOrdinal> glMap_; 00246 Teuchos::RCP< Directory<LocalOrdinal,GlobalOrdinal,Node> > directory_; 00247 00248 }; // Map class 00249 00258 template <class LocalOrdinal, class GlobalOrdinal> 00259 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> > 00260 createLocalMap(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm); 00261 00268 template <class LocalOrdinal, class GlobalOrdinal, class Node> 00269 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> > 00270 createLocalMapWithNode(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node); 00271 00278 template <class LocalOrdinal, class GlobalOrdinal, class Node> 00279 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> > 00280 createUniformContigMapWithNode(global_size_t numElements, 00281 const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node); 00282 00291 template <class LocalOrdinal, class GlobalOrdinal> 00292 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> > 00293 createUniformContigMap(global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm); 00294 00303 template <class LocalOrdinal, class GlobalOrdinal> 00304 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> > 00305 createContigMap(global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm); 00306 00313 template <class LocalOrdinal, class GlobalOrdinal, class Node> 00314 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> > 00315 createContigMapWithNode(global_size_t numElements, size_t localNumElements, 00316 const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node); 00317 00324 template <class LocalOrdinal, class GlobalOrdinal, class Node> 00325 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> > 00326 createWeightedContigMapWithNode(int thisNodeWeight, global_size_t numElements, 00327 const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node); 00328 00329 } // Tpetra namespace 00330 00333 template <class LocalOrdinal, class GlobalOrdinal, class Node> 00334 bool operator== (const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map1, const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map2); 00335 00338 template <class LocalOrdinal, class GlobalOrdinal, class Node> 00339 bool operator!= (const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map1, const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map2); 00340 00341 #endif // TPETRA_MAP_DECL_HPP 00342
1.7.4