Tpetra_Map_decl.hpp

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_RCP.hpp>
00034 #include <Teuchos_Describable.hpp>
00035 #include <Teuchos_Comm.hpp>
00036 #include <Teuchos_OrdinalTraits.hpp>
00037 
00038 // enums and defines
00039 #include "Tpetra_ConfigDefs.hpp"
00040 
00041 namespace Tpetra {
00042 
00043 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00044   // forward dec
00045   template <class LO, class GO, class N> class Directory;
00046 #endif
00047 
00049 
00053   template <class LocalOrdinal, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
00054   class Map : public Teuchos::Describable {
00055 
00056   public:
00057 
00059 
00060 
00066     Map(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 
00067         LocalGlobal lg=GloballyDistributed, const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode());
00068 
00078     Map(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, 
00079         const Teuchos::RCP<const Teuchos::Comm<int> > &comm, const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode());
00080         
00081 
00089     Map(global_size_t numGlobalElements, const Teuchos::ArrayView<const GlobalOrdinal> &elementList, GlobalOrdinal indexBase, 
00090         const Teuchos::RCP<const Teuchos::Comm<int> > &comm, const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode());
00091 
00093     ~Map();
00094 
00096 
00097 
00099 
00100 
00102     inline global_size_t getGlobalNumElements() const { return numGlobalElements_; }
00103 
00105     inline size_t getNodeNumElements() const { return numLocalElements_; }
00106 
00108     inline GlobalOrdinal getIndexBase() const { return indexBase_; }
00109 
00111     inline LocalOrdinal getMinLocalIndex() const { return Teuchos::OrdinalTraits<LocalOrdinal>::zero(); }
00112 
00114     inline LocalOrdinal getMaxLocalIndex() const { return Teuchos::as<LocalOrdinal>(numLocalElements_-1); }
00115 
00117     inline GlobalOrdinal getMinGlobalIndex() const { return minMyGID_; }
00118 
00120     inline GlobalOrdinal getMaxGlobalIndex() const { return maxMyGID_; }
00121 
00123     inline GlobalOrdinal getMinAllGlobalIndex() const { return minAllGID_; }
00124 
00126     inline GlobalOrdinal getMaxAllGlobalIndex() const { return maxAllGID_; }
00127 
00129 
00130     LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const;
00131 
00133 
00134     GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const;
00135 
00137 
00141     LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 
00142                                     const Teuchos::ArrayView<                int> & nodeIDList, 
00143                                     const Teuchos::ArrayView<       LocalOrdinal> & LIDList) const;
00144 
00146 
00150     LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 
00151                                     const Teuchos::ArrayView<                int> & nodeIDList) const;
00152 
00154     Teuchos::ArrayView<const GlobalOrdinal> getNodeElementList() const;
00155 
00157     bool isNodeLocalElement(LocalOrdinal localIndex) const;
00158 
00160     bool isNodeGlobalElement(GlobalOrdinal globalIndex) const;
00161 
00163     bool isContiguous() const;
00164 
00166     bool isDistributed() const;
00167 
00169 
00171 
00172 
00174     bool isCompatible (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const;
00175 
00177     bool isSameAs (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const;
00178 
00180 
00182 
00184     const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
00185 
00187     const Teuchos::RCP<Node> & getNode() const;
00188 
00190 
00192 
00194     std::string description() const;
00195 
00197     void describe( Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const;
00198 
00200 
00201 
00202   private:
00203 
00205     void setupDirectory();
00206 
00208     bool checkIsDist() const;
00209 
00211     Map(const Map<LocalOrdinal,GlobalOrdinal,Node> & source);
00212 
00214     Map<LocalOrdinal,GlobalOrdinal,Node>& operator=(const Map<LocalOrdinal,GlobalOrdinal,Node> & source);
00215 
00216     // some of the following are globally coherent: that is, they have been guaranteed to 
00217     // match across all images, and may be assumed to do so
00218     Teuchos::RCP<const Teuchos::Comm<int> > comm_;
00219 
00220     // 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 
00221     // pass a Node to downstream classes such as MultiVector, Vector, CrsGraph and CrsMatrix
00222     Teuchos::RCP<Node> node_;
00223 
00224     // The based for global IDs in this Map.
00225     GlobalOrdinal indexBase_;
00227     global_size_t numGlobalElements_;
00229     size_t numLocalElements_;
00231     GlobalOrdinal minMyGID_, maxMyGID_;
00233     GlobalOrdinal minAllGID_, maxAllGID_;
00235     bool contiguous_;
00237     bool distributed_;
00239     mutable Teuchos::ArrayRCP<GlobalOrdinal> lgMap_;
00241     std::map<GlobalOrdinal, LocalOrdinal> glMap_;
00244     Teuchos::RCP< Directory<LocalOrdinal,GlobalOrdinal,Node> > directory_;
00245 
00246   }; // Map class
00247 
00249   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00250   bool operator== (const Map<LocalOrdinal,GlobalOrdinal,Node> &map1, const Map<LocalOrdinal,GlobalOrdinal,Node> &map2);
00251 
00253   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00254   bool operator!= (const Map<LocalOrdinal,GlobalOrdinal,Node> &map1, const Map<LocalOrdinal,GlobalOrdinal,Node> &map2);
00255 
00257 
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 
00266 
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 
00272 } // Tpetra namespace
00273 
00274 #endif // TPETRA_MAP_DECL_HPP
00275 

Generated on Tue Jul 13 09:39:06 2010 for Tpetra Matrix/Vector Services by  doxygen 1.4.7