Tpetra Matrix/Vector Services Version of the Day
Tpetra_Map_decl.hpp
Go to the documentation of this file.
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 
00145     LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 
00146                                     const Teuchos::ArrayView<                int> & nodeIDList, 
00147                                     const Teuchos::ArrayView<       LocalOrdinal> & LIDList) const;
00148 
00150 
00155     LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 
00156                                     const Teuchos::ArrayView<                int> & nodeIDList) const;
00157 
00159     Teuchos::ArrayView<const GlobalOrdinal> getNodeElementList() const;
00160 
00162     bool isNodeLocalElement(LocalOrdinal localIndex) const;
00163 
00165     bool isNodeGlobalElement(GlobalOrdinal globalIndex) const;
00166 
00168     bool isContiguous() const;
00169 
00171     bool isDistributed() const;
00172 
00174 
00176 
00177 
00179     bool isCompatible (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const;
00180 
00182     bool isSameAs (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const;
00183 
00185 
00187 
00189     const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
00190 
00192     const Teuchos::RCP<Node> & getNode() const;
00193 
00195 
00197 
00199     std::string description() const;
00200 
00202     void describe( Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const;
00203 
00205 
00206 
00207   private:
00208 
00210     void setupDirectory();
00211 
00213     bool checkIsDist() const;
00214 
00216     Map(const Map<LocalOrdinal,GlobalOrdinal,Node> & source);
00217 
00219     Map<LocalOrdinal,GlobalOrdinal,Node>& operator=(const Map<LocalOrdinal,GlobalOrdinal,Node> & source);
00220 
00221     // some of the following are globally coherent: that is, they have been guaranteed to 
00222     // match across all images, and may be assumed to do so
00223     Teuchos::RCP<const Teuchos::Comm<int> > comm_;
00224 
00225     // 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 
00226     // pass a Node to downstream classes such as MultiVector, Vector, CrsGraph and CrsMatrix
00227     Teuchos::RCP<Node> node_;
00228 
00229     // The based for global IDs in this Map.
00230     GlobalOrdinal indexBase_;
00232     global_size_t numGlobalElements_;
00234     size_t numLocalElements_;
00236     GlobalOrdinal minMyGID_, maxMyGID_;
00238     GlobalOrdinal minAllGID_, maxAllGID_;
00240     bool contiguous_;
00242     bool distributed_;
00244     mutable Teuchos::ArrayRCP<GlobalOrdinal> lgMap_;
00246     std::map<GlobalOrdinal, LocalOrdinal> glMap_;
00249     Teuchos::RCP< Directory<LocalOrdinal,GlobalOrdinal,Node> > directory_;
00250 
00251   }; // Map class
00252 
00261   template <class LocalOrdinal, class GlobalOrdinal>
00262   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
00263   createLocalMap(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm);
00264 
00271   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00272   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
00273   createLocalMapWithNode(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node);
00274 
00283   template <class LocalOrdinal, class GlobalOrdinal>
00284   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
00285   createUniformContigMap(global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm);
00286 
00293   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00294   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
00295   createUniformContigMapWithNode(global_size_t numElements,
00296                                  const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node);
00297 
00306   template <class LocalOrdinal, class GlobalOrdinal>
00307   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
00308   createContigMap(global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm);
00309 
00316   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00317   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
00318   createContigMapWithNode(global_size_t numElements, size_t localNumElements, 
00319                           const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node);
00320 
00329   template <class LocalOrdinal, class GlobalOrdinal>
00330   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
00331   createNonContigMap(const ArrayView<const GlobalOrdinal> &elementList,
00332                      const RCP<const Teuchos::Comm<int> > &comm);
00333 
00340   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00341   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
00342   createNonContigMapWithNode(const ArrayView<const GlobalOrdinal> &elementList,
00343                              const RCP<const Teuchos::Comm<int> > &comm, 
00344                              const RCP<Node> &node);
00345 
00352   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00353   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
00354   createWeightedContigMapWithNode(int thisNodeWeight, global_size_t numElements, 
00355                                   const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node);
00356 
00357 } // Tpetra namespace
00358 
00361 template <class LocalOrdinal, class GlobalOrdinal, class Node>
00362 bool operator== (const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map1, const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map2)
00363 { return map1.isSameAs(map2); }
00364 
00367 template <class LocalOrdinal, class GlobalOrdinal, class Node>
00368 bool operator!= (const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map1, const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map2)
00369 { return !map1.isSameAs(map2); }
00370 
00371 #endif // TPETRA_MAP_DECL_HPP
00372 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines