Tpetra Matrix/Vector Services Version of the Day
Tpetra_DirectoryImpl_decl.hpp
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_DirectoryImpl_decl_hpp
00043 #define __Tpetra_DirectoryImpl_decl_hpp
00044 
00045 #include <Teuchos_ArrayView.hpp>
00046 #include <Tpetra_Map_decl.hpp>
00047 
00048 namespace Tpetra {
00049   namespace Details {
00057     template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
00058     class Directory : public Teuchos::Describable {
00059     public:
00060       typedef LocalOrdinal local_ordinal_type;
00061       typedef GlobalOrdinal global_ordinal_type;
00062       typedef NodeType node_type;
00063       typedef Tpetra::Map<LocalOrdinal, GlobalOrdinal, NodeType> map_type;
00064 
00066       Directory (const Teuchos::RCP<const map_type>& map);
00067 
00095       LookupStatus 
00096       getEntries (const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs, 
00097       const Teuchos::ArrayView<int> &nodeIDs, 
00098       const Teuchos::ArrayView<LocalOrdinal> &localIDs, 
00099       const bool computeLIDs) const;
00100 
00101     protected:
00103       virtual LookupStatus 
00104       getEntriesImpl (const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs, 
00105           const Teuchos::ArrayView<int> &nodeIDs, 
00106           const Teuchos::ArrayView<LocalOrdinal> &localIDs, 
00107           const bool computeLIDs) const = 0;
00108 
00110       Teuchos::RCP<const map_type> getMap () const { return map_; }
00111 
00112     private:
00114       Teuchos::RCP<const map_type> map_;
00115     };
00116 
00119     template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
00120     class ReplicatedDirectory : 
00121       public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
00122     public:
00123       typedef Directory<LocalOrdinal, GlobalOrdinal, NodeType> base_type;
00124       typedef typename base_type::map_type map_type;
00125 
00127       ReplicatedDirectory (const Teuchos::RCP<const map_type>& map);
00128 
00130 
00131 
00133       std::string description () const;
00135     protected:
00137       LookupStatus 
00138       getEntriesImpl (const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs, 
00139           const Teuchos::ArrayView<int> &nodeIDs, 
00140           const Teuchos::ArrayView<LocalOrdinal> &localIDs, 
00141           const bool computeLIDs) const;
00142     };
00143 
00146     template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
00147     class DistributedContiguousDirectory : 
00148       public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
00149     public:
00150       typedef Directory<LocalOrdinal, GlobalOrdinal, NodeType> base_type;
00151       typedef typename base_type::map_type map_type;
00152 
00154       DistributedContiguousDirectory (const Teuchos::RCP<const map_type>& map);
00155 
00157 
00158 
00160       std::string description () const;
00162     protected:
00164       LookupStatus 
00165       getEntriesImpl (const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs, 
00166           const Teuchos::ArrayView<int> &nodeIDs, 
00167           const Teuchos::ArrayView<LocalOrdinal> &localIDs, 
00168           const bool computeLIDs) const;
00169     private:
00193       Teuchos::Array<GlobalOrdinal> allMinGIDs_; 
00194     };
00195 
00198     template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
00199     class DistributedNoncontiguousDirectory : 
00200       public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
00201     public:
00202       typedef Directory<LocalOrdinal, GlobalOrdinal, NodeType> base_type;
00203       typedef typename base_type::map_type map_type;
00204       
00206       DistributedNoncontiguousDirectory (const Teuchos::RCP<const map_type>& map);
00207 
00209 
00210 
00212       std::string description () const;
00214     protected:
00216       LookupStatus 
00217       getEntriesImpl (const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs, 
00218           const Teuchos::ArrayView<int> &nodeIDs, 
00219           const Teuchos::ArrayView<LocalOrdinal> &localIDs, 
00220           const bool computeLIDs) const;
00221     private:
00239       Teuchos::RCP<const map_type> directoryMap_;
00240 
00244       Teuchos::Array<int> nodeIDs_;
00245 
00249       Teuchos::Array<LocalOrdinal> LIDs_;
00250     };
00251   } // namespace Details
00252 } // namespace Tpetra
00253 
00254 #endif // __Tpetra_DirectoryImpl_decl_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines