All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Xpetra_TpetraMap.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 //
00003 // ***********************************************************************
00004 //
00005 //             Xpetra: A linear algebra interface package
00006 //                  Copyright 2012 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact
00039 //                    Jeremie Gaidamour (jngaida@sandia.gov)
00040 //                    Jonathan Hu       (jhu@sandia.gov)
00041 //                    Ray Tuminaro      (rstumin@sandia.gov)
00042 //
00043 // ***********************************************************************
00044 //
00045 // @HEADER
00046 #ifndef XPETRA_TPETRAMAP_HPP
00047 #define XPETRA_TPETRAMAP_HPP
00048 
00049 /* this file is automatically generated - do not edit (see script/tpetra.py) */
00050 
00051 #include "Xpetra_TpetraConfigDefs.hpp"
00052 
00053 #include <Tpetra_Map.hpp>
00054 
00055 #include "Xpetra_Map.hpp"
00056 #include "Xpetra_Utils.hpp"
00057 
00058 #include "Xpetra_Exceptions.hpp"
00059 
00060 namespace Xpetra {
00061 
00062   // TODO: move that elsewhere
00063   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00064   const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> & toTpetra(const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &);
00065 
00066   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00067   const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & toTpetra(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &);
00068 
00069   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00070   const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > toXpetra(const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &);
00071   //
00072 
00073   template <class LocalOrdinal, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
00074   class TpetraMap
00075     : public virtual Map<LocalOrdinal,GlobalOrdinal,Node> {
00076 
00077   public:
00078 
00080 
00081 
00083     TpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode())
00084       : map_(Teuchos::rcp(new Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node >(numGlobalElements, indexBase, comm, toTpetra(lg), node))) {  }
00085 
00087     TpetraMap(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode())
00088       : map_(Teuchos::rcp(new Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node >(numGlobalElements, numLocalElements, indexBase, comm, node))) {  }
00089 
00091     TpetraMap(global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode())
00092       : map_(Teuchos::rcp(new Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node >(numGlobalElements, elementList, indexBase, comm, node))) {  }
00093 
00095     ~TpetraMap() {  }
00096 
00098 
00100 
00101 
00103     global_size_t getGlobalNumElements() const { XPETRA_MONITOR("TpetraMap::getGlobalNumElements"); return map_->getGlobalNumElements(); }
00104 
00106     size_t getNodeNumElements() const { XPETRA_MONITOR("TpetraMap::getNodeNumElements"); return map_->getNodeNumElements(); }
00107 
00109     GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("TpetraMap::getIndexBase"); return map_->getIndexBase(); }
00110 
00112     LocalOrdinal getMinLocalIndex() const { XPETRA_MONITOR("TpetraMap::getMinLocalIndex"); return map_->getMinLocalIndex(); }
00113 
00115     LocalOrdinal getMaxLocalIndex() const { XPETRA_MONITOR("TpetraMap::getMaxLocalIndex"); return map_->getMaxLocalIndex(); }
00116 
00118     GlobalOrdinal getMinGlobalIndex() const { XPETRA_MONITOR("TpetraMap::getMinGlobalIndex"); return map_->getMinGlobalIndex(); }
00119 
00121     GlobalOrdinal getMaxGlobalIndex() const { XPETRA_MONITOR("TpetraMap::getMaxGlobalIndex"); return map_->getMaxGlobalIndex(); }
00122 
00124     GlobalOrdinal getMinAllGlobalIndex() const { XPETRA_MONITOR("TpetraMap::getMinAllGlobalIndex"); return map_->getMinAllGlobalIndex(); }
00125 
00127     GlobalOrdinal getMaxAllGlobalIndex() const { XPETRA_MONITOR("TpetraMap::getMaxAllGlobalIndex"); return map_->getMaxAllGlobalIndex(); }
00128 
00130     LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("TpetraMap::getLocalElement"); return map_->getLocalElement(globalIndex); }
00131 
00133     GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("TpetraMap::getGlobalElement"); return map_->getGlobalElement(localIndex); }
00134 
00136     LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const { XPETRA_MONITOR("TpetraMap::getRemoteIndexList"); return toXpetra(map_->getRemoteIndexList(GIDList, nodeIDList, LIDList)); }
00137 
00139     LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const { XPETRA_MONITOR("TpetraMap::getRemoteIndexList"); return toXpetra(map_->getRemoteIndexList(GIDList, nodeIDList)); }
00140 
00142     Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const { XPETRA_MONITOR("TpetraMap::getNodeElementList"); return map_->getNodeElementList(); }
00143 
00145 
00147 
00148 
00150     bool isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("TpetraMap::isNodeLocalElement"); return map_->isNodeLocalElement(localIndex); }
00151 
00153     bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("TpetraMap::isNodeGlobalElement"); return map_->isNodeGlobalElement(globalIndex); }
00154 
00156     bool isContiguous() const { XPETRA_MONITOR("TpetraMap::isContiguous"); return map_->isContiguous(); }
00157 
00159     bool isDistributed() const { XPETRA_MONITOR("TpetraMap::isDistributed"); return map_->isDistributed(); }
00160 
00162     bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("TpetraMap::isCompatible"); return map_->isCompatible(toTpetra(map)); }
00163 
00165     bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("TpetraMap::isSameAs"); return map_->isSameAs(toTpetra(map)); }
00166 
00168 
00170 
00171 
00173     const Teuchos::RCP< const Teuchos::Comm< int > >  getComm() const { XPETRA_MONITOR("TpetraMap::getComm"); return map_->getComm(); }
00174 
00176     const Teuchos::RCP< Node >  getNode() const { XPETRA_MONITOR("TpetraMap::getNode"); return map_->getNode(); }
00177 
00179 
00181 
00182 
00184     std::string description() const { XPETRA_MONITOR("TpetraMap::description"); return map_->description(); }
00185 
00187     void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const { XPETRA_MONITOR("TpetraMap::describe"); map_->describe(out, verbLevel); }
00188 
00190 
00192 
00193 
00195     TpetraMap(const Teuchos::RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node > > &map) 
00196       : map_(map) { }
00197 
00199     UnderlyingLib lib() const { return Xpetra::UseTpetra; }
00200 
00202     const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getTpetra_Map() const { return map_; }
00203 
00205    
00206   protected:
00207 
00208     RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > map_;
00209 
00210   }; // TpetraMap class
00211 
00212   // TODO: move that elsewhere
00213   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00214   const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> & toTpetra(const Map<LocalOrdinal,GlobalOrdinal,Node> &map) {
00215     // TODO: throw exception
00216     const TpetraMap<LocalOrdinal,GlobalOrdinal,Node> & tpetraMap = dynamic_cast<const TpetraMap<LocalOrdinal,GlobalOrdinal,Node> &>(map);
00217     return *tpetraMap.getTpetra_Map();
00218   }
00219 
00220   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00221   const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & toTpetra(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map) {
00222     typedef TpetraMap<LocalOrdinal, GlobalOrdinal, Node> TpetraMapClass;
00223     XPETRA_RCP_DYNAMIC_CAST(const TpetraMapClass, map, tpetraMap, "toTpetra");
00224     return tpetraMap->getTpetra_Map();
00225   }
00226 
00227   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00228   const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > toXpetra(const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map) {
00229     return rcp( new TpetraMap<LocalOrdinal, GlobalOrdinal, Node>(map));
00230   }
00231   //
00232 
00233   // TODO: removed (but currently used in unit test)
00234   namespace useTpetra {
00235 
00237     template <class LocalOrdinal, class GlobalOrdinal, class Node>
00238     Teuchos::RCP< const TpetraMap<LocalOrdinal,GlobalOrdinal,Node> >
00239     createLocalMapWithNode(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node) { 
00240       XPETRA_MONITOR("useTpetra::createLocalMapWithNode");
00241 
00242       return rcp(new TpetraMap<LocalOrdinal,GlobalOrdinal,Node>(Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(numElements, comm, node)));
00243     }
00244 
00246     template <class LocalOrdinal, class GlobalOrdinal>
00247     Teuchos::RCP< const TpetraMap<LocalOrdinal,GlobalOrdinal,Kokkos::DefaultNode::DefaultNodeType> >
00248     createContigMap(global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm) { 
00249       XPETRA_MONITOR("useTpetra::createContigMap");
00250 
00251       return rcp(new TpetraMap<LocalOrdinal,GlobalOrdinal>(Tpetra::createContigMap<LocalOrdinal,GlobalOrdinal>(numElements, localNumElements, comm)));
00252     }
00253 
00255     template <class LocalOrdinal, class GlobalOrdinal, class Node>
00256     Teuchos::RCP< const TpetraMap<LocalOrdinal,GlobalOrdinal,Node> >
00257     createContigMapWithNode(global_size_t numElements, size_t localNumElements, 
00258                             const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node) { 
00259       XPETRA_MONITOR("useTpetra::createContigMap");
00260       return rcp(new TpetraMap<LocalOrdinal,GlobalOrdinal,Node>(Tpetra::createContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(numElements, localNumElements, comm, node)));
00261     }
00262   } // useTpetra namespace
00263 
00264 } // Xpetra namespace
00265 
00266 // TODO: remove?
00268 template <class LocalOrdinal, class GlobalOrdinal, class Node>
00269 bool operator== (const Xpetra::TpetraMap<LocalOrdinal,GlobalOrdinal,Node> &map1, const Xpetra::TpetraMap<LocalOrdinal,GlobalOrdinal,Node> &map2) { 
00270   XPETRA_MONITOR("TpetraMap==TpetraMap");
00271   return map1.isSameAs(map2);
00272 }
00273 
00275 template <class LocalOrdinal, class GlobalOrdinal, class Node>
00276 bool operator!= (const Xpetra::TpetraMap<LocalOrdinal,GlobalOrdinal,Node> &map1, const Xpetra::TpetraMap<LocalOrdinal,GlobalOrdinal,Node> &map2) { 
00277   XPETRA_MONITOR("TpetraMap!=TpetraMap");
00278   return !map1.isSameAs(map2);
00279 }
00280 
00281 #define XPETRA_TPETRAMAP_SHORT
00282 #endif // XPETRA_TPETRAMAP_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines