Tpetra_MapDecl.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 
00037 // enums and defines
00038 #include "Tpetra_ConfigDefs.hpp"
00039 
00040 namespace Tpetra {
00041 
00042 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00043   // forward dec
00044   template <class LO, class GO, class N> class Directory;
00045 #endif
00046 
00048 
00052   template <class LocalOrdinal, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
00053   class Map : public Teuchos::Describable {
00054 
00055   public:
00056 
00058 
00059 
00065     Map(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 
00066         LocalGlobal lg=GloballyDistributed, const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode());
00067 
00077     Map(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, 
00078         const Teuchos::RCP<const Teuchos::Comm<int> > &comm, const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode());
00079         
00080 
00088     Map(global_size_t numGlobalElements, const Teuchos::ArrayView<const GlobalOrdinal> &elementList, GlobalOrdinal indexBase, 
00089         const Teuchos::RCP<const Teuchos::Comm<int> > &comm, const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode());
00090 
00092     ~Map();
00093 
00095 
00096 
00098 
00099 
00101     inline global_size_t getGlobalNumElements() const;
00102 
00104     inline size_t getNodeNumElements() const;
00105 
00107     inline GlobalOrdinal getIndexBase() const;
00108 
00110     inline LocalOrdinal getMinLocalIndex() const;
00111 
00113     inline LocalOrdinal getMaxLocalIndex() const;
00114 
00116     inline GlobalOrdinal getMinGlobalIndex() const;
00117 
00119     inline GlobalOrdinal getMaxGlobalIndex() const;
00120 
00122     inline GlobalOrdinal getMinAllGlobalIndex() const;
00123 
00125     inline GlobalOrdinal getMaxAllGlobalIndex() const;
00126 
00128 
00129     LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const;
00130 
00132 
00133     GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const;
00134 
00136 
00140     LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 
00141                                     const Teuchos::ArrayView<                int> & nodeIDList, 
00142                                     const Teuchos::ArrayView<       LocalOrdinal> & LIDList) const;
00143 
00145 
00149     LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 
00150                                     const Teuchos::ArrayView<                int> & nodeIDList) const;
00151 
00153     Teuchos::ArrayView<const GlobalOrdinal> getNodeElementList() const;
00154 
00156     bool isNodeLocalElement(LocalOrdinal localIndex) const;
00157 
00159     bool isNodeGlobalElement(GlobalOrdinal globalIndex) const;
00160 
00162     bool isContiguous() const;
00163 
00165     bool isDistributed() const;
00166 
00168 
00170 
00171 
00173     bool isCompatible (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const;
00174 
00176     bool isSameAs (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const;
00177 
00179 
00181 
00183     const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
00184 
00186     const Teuchos::RCP<Node> & getNode() const;
00187 
00189 
00191 
00193     std::string description() const;
00194 
00196     void describe( Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const;
00197 
00199 
00200 
00201   private:
00202 
00204     void setupDirectory();
00205 
00207     bool checkIsDist() const;
00208 
00210     Map(const Map<LocalOrdinal,GlobalOrdinal,Node> & source);
00211 
00213     Map<LocalOrdinal,GlobalOrdinal,Node>& operator=(const Map<LocalOrdinal,GlobalOrdinal,Node> & source);
00214 
00215     // some of the following are globally coherent: that is, they have been guaranteed to 
00216     // match across all images, and may be assumed to do so
00217     Teuchos::RCP<const Teuchos::Comm<int> > comm_;
00218 
00219     // 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 
00220     // pass a Node to downstream classes such as MultiVector, Vector, CrsGraph and CrsMatrix
00221     Teuchos::RCP<Node> node_;
00222 
00223     // The based for global IDs in this Map.
00224     GlobalOrdinal indexBase_;
00226     global_size_t numGlobalElements_;
00228     size_t numLocalElements_;
00230     GlobalOrdinal minMyGID_, maxMyGID_;
00232     GlobalOrdinal minAllGID_, maxAllGID_;
00234     bool contiguous_;
00236     bool distributed_;
00238     mutable Teuchos::ArrayRCP<GlobalOrdinal> lgMap_;
00240     std::map<GlobalOrdinal, LocalOrdinal> glMap_;
00243     Teuchos::RCP< Directory<LocalOrdinal,GlobalOrdinal,Node> > directory_;
00244 
00245   }; // Map class
00246 
00248   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00249   bool operator== (const Map<LocalOrdinal,GlobalOrdinal,Node> &map1, const Map<LocalOrdinal,GlobalOrdinal,Node> &map2);
00250 
00252   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00253   bool operator!= (const Map<LocalOrdinal,GlobalOrdinal,Node> &map1, const Map<LocalOrdinal,GlobalOrdinal,Node> &map2);
00254 
00255 
00256 } // Tpetra namespace
00257 
00258 #endif // TPETRA_MAP_DECL_HPP
00259 

Generated on Wed May 12 21:40:14 2010 for Tpetra Matrix/Vector Services by  doxygen 1.4.7