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 the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00038 // 
00039 // ************************************************************************
00040 // @HEADER
00041 
00042 #ifndef TPETRA_MAP_DECL_HPP
00043 #define TPETRA_MAP_DECL_HPP
00044 
00045 #include <Kokkos_DefaultNode.hpp>
00046 #include <Teuchos_Describable.hpp>
00047 
00048 // enums and defines
00049 #include "Tpetra_ConfigDefs.hpp"
00050 
00056 namespace Tpetra {
00057 
00058 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00059   // Forward declaration of Directory.
00060   template <class LO, class GO, class N> class Directory;
00061 #endif
00062 
00068   template <class LocalOrdinal, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
00069   class Map : public Teuchos::Describable {
00070 
00071   public:
00072 
00074 
00075 
00082     Map (global_size_t numGlobalElements, 
00083    GlobalOrdinal indexBase, 
00084    const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 
00085    LocalGlobal lg=GloballyDistributed, 
00086    const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode());
00087 
00102     Map (global_size_t numGlobalElements, 
00103    size_t numLocalElements, 
00104    GlobalOrdinal indexBase, 
00105    const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 
00106    const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode());
00107 
00119     Map (global_size_t numGlobalElements, 
00120    const Teuchos::ArrayView<const GlobalOrdinal> &elementList, 
00121    GlobalOrdinal indexBase, 
00122    const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 
00123    const Teuchos::RCP<Node> &node = Kokkos::DefaultNode::getDefaultNode());
00124 
00126     ~Map();
00127 
00129 
00130 
00132 
00133 
00135     inline global_size_t getGlobalNumElements() const { return numGlobalElements_; }
00136 
00138     inline size_t getNodeNumElements() const { return numLocalElements_; }
00139 
00141     inline GlobalOrdinal getIndexBase() const { return indexBase_; }
00142 
00144     inline LocalOrdinal getMinLocalIndex() const { return Teuchos::OrdinalTraits<LocalOrdinal>::zero(); }
00145 
00147     inline LocalOrdinal getMaxLocalIndex() const { return Teuchos::as<LocalOrdinal>(numLocalElements_-1); }
00148 
00150     inline GlobalOrdinal getMinGlobalIndex() const { return minMyGID_; }
00151 
00153     inline GlobalOrdinal getMaxGlobalIndex() const { return maxMyGID_; }
00154 
00156     inline GlobalOrdinal getMinAllGlobalIndex() const { return minAllGID_; }
00157 
00159     inline GlobalOrdinal getMaxAllGlobalIndex() const { return maxAllGID_; }
00160 
00165     LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const;
00166 
00171     GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const;
00172 
00185     LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 
00186                                     const Teuchos::ArrayView<                int> & nodeIDList, 
00187                                     const Teuchos::ArrayView<       LocalOrdinal> & LIDList) const;
00188 
00201     LookupStatus getRemoteIndexList(const Teuchos::ArrayView<const GlobalOrdinal> & GIDList, 
00202                                     const Teuchos::ArrayView<                int> & nodeIDList) const;
00203 
00205     Teuchos::ArrayView<const GlobalOrdinal> getNodeElementList() const;
00206 
00208     bool isNodeLocalElement(LocalOrdinal localIndex) const;
00209 
00211     bool isNodeGlobalElement(GlobalOrdinal globalIndex) const;
00212 
00224     bool isContiguous() const;
00225 
00245     bool isDistributed() const;
00246 
00248 
00250 
00251 
00267     bool isCompatible (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const;
00268 
00289     bool isSameAs (const Map<LocalOrdinal,GlobalOrdinal,Node> &map) const;
00290 
00292 
00294 
00296     const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const;
00297 
00299     const Teuchos::RCP<Node> & getNode() const;
00300 
00302 
00304 
00306     std::string description() const;
00307 
00309     void describe( Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const;
00310 
00312 
00313 
00314   private:
00315 
00317     void setupDirectory();
00318 
00333     bool checkIsDist() const;
00334 
00336     Map(const Map<LocalOrdinal,GlobalOrdinal,Node> & source);
00337 
00339     Map<LocalOrdinal,GlobalOrdinal,Node>& operator=(const Map<LocalOrdinal,GlobalOrdinal,Node> & source);
00340 
00342     Teuchos::RCP<const Teuchos::Comm<int> > comm_;
00343 
00350     Teuchos::RCP<Node> node_;
00351 
00353     GlobalOrdinal indexBase_;
00355     global_size_t numGlobalElements_;
00357     size_t numLocalElements_;
00359     GlobalOrdinal minMyGID_, maxMyGID_;
00361     GlobalOrdinal minAllGID_, maxAllGID_;
00363     bool contiguous_;
00365     bool distributed_;
00366 
00382     mutable Teuchos::ArrayRCP<GlobalOrdinal> lgMap_;
00383 
00396     std::map<GlobalOrdinal, LocalOrdinal> glMap_;
00397 
00406     Teuchos::RCP<Directory<LocalOrdinal,GlobalOrdinal,Node> > directory_;
00407 
00408   }; // Map class
00409 
00418   template <class LocalOrdinal, class GlobalOrdinal>
00419   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
00420   createLocalMap(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm);
00421 
00428   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00429   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
00430   createLocalMapWithNode(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node);
00431 
00440   template <class LocalOrdinal, class GlobalOrdinal>
00441   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
00442   createUniformContigMap(global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm);
00443 
00450   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00451   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
00452   createUniformContigMapWithNode(global_size_t numElements,
00453                                  const Teuchos::RCP< const Teuchos::Comm< int > > &comm, 
00454          const Teuchos::RCP< Node > &node);
00455 
00464   template <class LocalOrdinal, class GlobalOrdinal>
00465   Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
00466   createContigMap (global_size_t numElements, 
00467        size_t localNumElements, 
00468        const Teuchos::RCP<const Teuchos::Comm<int> > &comm);
00469 
00476   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00477   Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
00478   createContigMapWithNode (global_size_t numElements, 
00479          size_t localNumElements, 
00480          const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 
00481          const Teuchos::RCP<Node> &node);
00482 
00491   template <class LocalOrdinal, class GlobalOrdinal>
00492   Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
00493   createNonContigMap (const ArrayView<const GlobalOrdinal> &elementList,
00494           const RCP<const Teuchos::Comm<int> > &comm);
00495 
00502   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00503   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
00504   createNonContigMapWithNode (const ArrayView<const GlobalOrdinal> &elementList,
00505             const RCP<const Teuchos::Comm<int> > &comm, 
00506             const RCP<Node> &node);
00507 
00514   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00515   Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
00516   createWeightedContigMapWithNode (int thisNodeWeight, 
00517            global_size_t numElements, 
00518            const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 
00519            const Teuchos::RCP<Node> &node);
00520 
00521 } // Tpetra namespace
00522 
00525 template <class LocalOrdinal, class GlobalOrdinal, class Node>
00526 bool operator== (const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map1, 
00527      const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map2)
00528 { return map1.isSameAs(map2); }
00529 
00532 template <class LocalOrdinal, class GlobalOrdinal, class Node>
00533 bool operator!= (const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map1, 
00534      const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &map2)
00535 { return !map1.isSameAs(map2); }
00536 
00537 #endif // TPETRA_MAP_DECL_HPP
00538 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines